@@ -31,14 +31,19 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
31
31
*/
32
32
private $ executableLinesGroupedByBranch = [];
33
33
34
- /**
35
- * @var array
36
- */
37
- private $ unsets = [];
38
-
39
34
public function enterNode (Node $ node ): void
40
35
{
41
- if ($ node instanceof Node \Stmt \Class_) {
36
+ if ($ node instanceof Node \Stmt \Declare_ ||
37
+ $ node instanceof Node \Stmt \DeclareDeclare ||
38
+ $ node instanceof Node \Stmt \Class_ ||
39
+ $ node instanceof Node \Stmt \ClassConst ||
40
+ $ node instanceof Node \Stmt \Property ||
41
+ $ node instanceof Node \Stmt \PropertyProperty ||
42
+ $ node instanceof Node \Const_ ||
43
+ $ node instanceof Node \Scalar ||
44
+ $ node instanceof Node \Identifier ||
45
+ $ node instanceof Node \VarLikeIdentifier
46
+ ) {
42
47
return ;
43
48
}
44
49
@@ -240,32 +245,13 @@ public function enterNode(Node $node): void
240
245
return ;
241
246
}
242
247
243
- if ($ node instanceof Node \Stmt \Declare_) {
244
- $ this ->unsets [] = range ($ node ->getStartLine (), $ node ->getEndLine ());
245
-
246
- return ;
247
- }
248
-
249
- if ($ node instanceof Node \Identifier) {
250
- return ;
251
- }
252
-
253
248
if (isset ($ this ->executableLinesGroupedByBranch [$ node ->getStartLine ()])) {
254
249
return ;
255
250
}
256
251
257
252
$ this ->setLineBranch ($ node ->getStartLine (), $ node ->getEndLine (), 1 );
258
253
}
259
254
260
- public function afterTraverse (array $ nodes ): void
261
- {
262
- foreach ($ this ->unsets as $ unset ) {
263
- foreach ($ unset as $ line ) {
264
- unset($ this ->executableLinesGroupedByBranch [$ line ]);
265
- }
266
- }
267
- }
268
-
269
255
public function executableLinesGroupedByBranch (): array
270
256
{
271
257
return $ this ->executableLinesGroupedByBranch ;
0 commit comments