Skip to content

Commit 5a4626d

Browse files
Slamdunksebastianbergmann
authored andcommitted
Fix interface precedence over method handling
1 parent 14ceade commit 5a4626d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/StaticAnalysis/ExecutableLinesFindingVisitor.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,17 @@ public function enterNode(Node $node): void
129129
$node instanceof Node\Expr\Closure ||
130130
$node instanceof Node\Stmt\Trait_) {
131131
if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) {
132+
$unsets = [];
133+
132134
foreach ($node->getParams() as $param) {
133135
foreach (range($param->getStartLine(), $param->getEndLine()) as $line) {
134-
$this->unsets[$line] = true;
136+
$unsets[$line] = true;
135137
}
136138
}
137139

138-
unset($this->unsets[$node->getEndLine()]);
140+
unset($unsets[$node->getEndLine()]);
141+
142+
$this->unsets += $unsets;
139143
}
140144

141145
$isConcreteClassLike = $node instanceof Node\Stmt\Enum_ || $node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Trait_;

tests/_files/source_for_branched_exec_lines.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,12 +572,17 @@ interface MyInterface
572572
'string',
573573
];
574574
public function myMethod();
575+
public function multiline(
576+
\stdClass $var
577+
): \stdClass;
578+
public function multilineVoid(
579+
): void;
575580
}
576581

577582
trait MyTrait
578583
{
579584
public function myTrait()
580-
{} // +3
585+
{} // +5
581586
}
582587

583588
abstract class MyAbstractClass implements MyInterface

0 commit comments

Comments
 (0)