Skip to content

Commit 122ccfa

Browse files
Slamdunksebastianbergmann
authored andcommitted
Executable lines: skip Attributes
1 parent e70f9f8 commit 122ccfa

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/StaticAnalysis/Visitor/ExecutableLinesFindingVisitor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ public function enterNode(Node $node): null
8383
return null;
8484
}
8585

86-
if ($node instanceof Node\Stmt\Interface_) {
86+
if ($node instanceof Node\Stmt\Interface_ ||
87+
$node instanceof Node\Attribute
88+
) {
8789
foreach (range($node->getStartLine(), $node->getEndLine()) as $line) {
8890
$this->unsets[$line] = true;
8991
}

tests/_files/source_for_branched_exec_lines.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,18 @@ public function m4(): void
609609
{
610610
} // +1
611611
}
612+
613+
#[\Attribute]
614+
class AttributeWithCtor
615+
{
616+
public function __construct(array $myArray)
617+
{} // +2
618+
}
619+
620+
#[AttributeWithCtor(myArray: [
621+
'foo' => [
622+
'bar' => 'baz',
623+
],
624+
])]
625+
class MyClassWithAttribute
626+
{}

0 commit comments

Comments
 (0)