Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interface precedence over method handling #1019

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/StaticAnalysis/ExecutableLinesFindingVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,17 @@ public function enterNode(Node $node): void
$node instanceof Node\Expr\Closure ||
$node instanceof Node\Stmt\Trait_) {
if ($node instanceof Node\Stmt\Function_ || $node instanceof Node\Stmt\ClassMethod) {
$unsets = [];

foreach ($node->getParams() as $param) {
foreach (range($param->getStartLine(), $param->getEndLine()) as $line) {
$this->unsets[$line] = true;
$unsets[$line] = true;
}
}

unset($this->unsets[$node->getEndLine()]);
unset($unsets[$node->getEndLine()]);

$this->unsets += $unsets;
}

$isConcreteClassLike = $node instanceof Node\Stmt\Enum_ || $node instanceof Node\Stmt\Class_ || $node instanceof Node\Stmt\Trait_;
Expand Down
7 changes: 6 additions & 1 deletion tests/_files/source_for_branched_exec_lines.php
Original file line number Diff line number Diff line change
Expand Up @@ -572,12 +572,17 @@ interface MyInterface
'string',
];
public function myMethod();
public function multiline(
\stdClass $var
): \stdClass;
public function multilineVoid(
): void;
}

trait MyTrait
{
public function myTrait()
{} // +3
{} // +5
}

abstract class MyAbstractClass implements MyInterface
Expand Down