Skip to content

Commit 5a91561

Browse files
Slamdunkmvorisek
authored andcommitted
Test against heredocs to ensure first line gets always counted correctly
1 parent d457c77 commit 5a91561

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private function getLines(NodeAbstract $node, bool $fromReturns): array
170170
$node->left instanceof Node\Expr\Variable ||
171171
$node->right instanceof Node\Expr\Variable
172172
)) {
173-
return [$node->right->getStartLine()];
173+
return [$this->getNodeStartLine($node->right)];
174174
}
175175

176176
return $fromReturns ? $this->getLines($node->right, $fromReturns) : [];

tests/_files/source_with_multiline_constant_return.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,19 @@ public function concatWithVar(): string
498498
$var1 = 'start';
499499

500500
$var1 =
501-
'right'
501+
<<<'EOF'
502+
right
503+
EOF
502504
.
503505
$var1
504506
;
505507

506508
$var1 =
507509
$var1
508510
.
509-
'left'
511+
<<<'EOF'
512+
left
513+
EOF
510514
;
511515

512516
return $var1;

tests/tests/Data/RawCodeCoverageDataTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,10 +500,10 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
500500
490,
501501
498,
502502
500,
503-
503,
504-
506,
505-
509, // This is correct: not the line with the $var1, but the right operand of the Concat
506-
512,
503+
505,
504+
508,
505+
512, // This is correct: not the line with the $var1, but the right operand of the Concat
506+
516,
507507
],
508508
array_keys(RawCodeCoverageData::fromUncoveredFile($file, new ParsingFileAnalyser(true, true))->lineCoverage()[$file])
509509
);

0 commit comments

Comments
 (0)