Description
Succession issue for closed #981
Phpunit uses diffs to make objects or json strings comparable.
--- Expected
+++ Actual
@@ @@
'rangeInSource' => Parser\Source\Range Object (
'start' => Parser\Source\Position Object (...)
'end' => Parser\Source\Position Object (
- 'lineNumber' => 2
+ 'lineNumber' => 3
'columnNumber' => 0
)
)
@@ @@
'rangeInSource' => Parser\Source\Range Object (
'start' => Parser\Source\Position Object (...)
'end' => Parser\Source\Position Object (
- 'lineNumber' => 2
+ 'lineNumber' => 3
'columnNumber' => 0
)
)
@@ @@
Now if some value objects in a deep structure are not equal (imagine the positions in a big AST) its funny to find out in the above output where the problem lies.
This can be made easier with a higher context size (like diff: -u, -U NUM, --unified[=NUM]
). By default this is set to 3 as shown in the above output.
Now phpunit uses in https://github.com/sebastianbergmann/phpunit/blob/main/src/Framework/Constraint/String/StringMatchesFormatDescription.php#L133 the hardcoded UnifiedDiffOutputBuilder
which again has a hardcoded context size of 3 https://github.com/sebastianbergmann/diff/blob/main/src/Output/UnifiedDiffOutputBuilder.php#L38.
There is already a pr to make the hard coded context size of 3 adjustable in the UnifiedDiffOutputBuilder
sebastianbergmann/diff#122 but the pr is stale because it was said users should prefer the StrictUnifiedDiffOutputBuilder
which would support this feature too.
Anyway i dont know what the preferred solution should be, i can volunteer to make the changes but for now just an locally increased context size like 8 allowed me to debug the assertions:
--- Expected
+++ Actual
@@ @@
Language\AST\Node\Module\ModuleNode Object (
'rangeInSource' => Parser\Source\Range Object (
'start' => Parser\Source\Position Object (...)
'end' => Parser\Source\Position Object (
- 'lineNumber' => 2
+ 'lineNumber' => 3
'columnNumber' => 0
)
)
'imports' => Language\AST\Node\Import\ImportNodes Object (...)
'export' => Language\AST\Node\Export\ExportNode Object (
'rangeInSource' => Parser\Source\Range Object (
'start' => Parser\Source\Position Object (...)
'end' => Parser\Source\Position Object (
- 'lineNumber' => 2
+ 'lineNumber' => 3
'columnNumber' => 0
)
)
'declaration' => Language\AST\Node\ComponentDeclaration\ComponentDeclarationNode Object (
'rangeInSource' => Parser\Source\Range Object (
'start' => Parser\Source\Position Object (...)