Skip to content

Commit 08e321e

Browse files
committed
fix array processing in another post/returns analysis
1 parent f0e43a9 commit 08e321e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,19 @@ private function computeReturns(): void
137137
*/
138138
private function getLines(NodeAbstract $node, bool $fromReturns): array
139139
{
140+
// ugly fix for non-fully AST based processing
141+
// self::afterTraverse()/self::computeReturns() should be rewritten using self::leaveNode()
142+
if ($node instanceof Array_ && [] !== $node->items) {
143+
$parentNode = $node->getAttribute('parent');
144+
if ($parentNode instanceof Return_ ||
145+
$parentNode instanceof Expression ||
146+
$parentNode instanceof Assign ||
147+
$parentNode instanceof Array_
148+
) {
149+
return [];
150+
}
151+
}
152+
140153
if (!$fromReturns && (
141154
$node instanceof Return_ ||
142155
$node instanceof Expression ||

tests/tests/Data/RawCodeCoverageDataTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ public function testReturnStatementWithConstantExprOnlyReturnTheLineOfLast(): vo
492492
404,
493493
414,
494494
416,
495-
423, // should be 424 as reported by xdebug
496495
425,
497496
437,
498497
442,

0 commit comments

Comments
 (0)