Skip to content

Commit 115a62b

Browse files
Do not abort tree traversal
1 parent 05376d7 commit 115a62b

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

src/StaticAnalysis/IgnoredLinesFindingVisitor.php

+6-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use PhpParser\Node\Stmt\Function_;
1919
use PhpParser\Node\Stmt\Interface_;
2020
use PhpParser\Node\Stmt\Trait_;
21-
use PhpParser\NodeTraverser;
2221
use PhpParser\NodeVisitorAbstract;
2322

2423
/**
@@ -47,18 +46,18 @@ public function __construct(bool $useAnnotationsForIgnoringCode, bool $ignoreDep
4746
$this->ignoreDeprecated = $ignoreDeprecated;
4847
}
4948

50-
public function enterNode(Node $node): ?int
49+
public function enterNode(Node $node): void
5150
{
5251
if (!$node instanceof Class_ &&
5352
!$node instanceof Trait_ &&
5453
!$node instanceof Interface_ &&
5554
!$node instanceof ClassMethod &&
5655
!$node instanceof Function_) {
57-
return null;
56+
return;
5857
}
5958

6059
if ($node instanceof Class_ && $node->isAnonymous()) {
61-
return null;
60+
return;
6261
}
6362

6463
// Workaround for https://bugs.xdebug.org/view.php?id=1798
@@ -69,17 +68,17 @@ public function enterNode(Node $node): ?int
6968
}
7069

7170
if (!$this->useAnnotationsForIgnoringCode) {
72-
return null;
71+
return;
7372
}
7473

7574
if ($node instanceof Interface_) {
76-
return null;
75+
return;
7776
}
7877

7978
$docComment = $node->getDocComment();
8079

8180
if ($docComment === null) {
82-
return null;
81+
return;
8382
}
8483

8584
if (strpos($docComment->getText(), '@codeCoverageIgnore') !== false) {
@@ -95,12 +94,6 @@ public function enterNode(Node $node): ?int
9594
range($node->getStartLine(), $node->getEndLine())
9695
);
9796
}
98-
99-
if ($node instanceof ClassMethod || $node instanceof Function_) {
100-
return NodeTraverser::DONT_TRAVERSE_CHILDREN;
101-
}
102-
103-
return null;
10497
}
10598

10699
/**

0 commit comments

Comments
 (0)