@@ -31,14 +31,19 @@ final class ExecutableLinesFindingVisitor extends NodeVisitorAbstract
3131 */
3232 private $ executableLinesGroupedByBranch = [];
3333
34- /**
35- * @var array
36- */
37- private $ unsets = [];
38-
3934 public function enterNode (Node $ node ): void
4035 {
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+ ) {
4247 return ;
4348 }
4449
@@ -240,32 +245,13 @@ public function enterNode(Node $node): void
240245 return ;
241246 }
242247
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-
253248 if (isset ($ this ->executableLinesGroupedByBranch [$ node ->getStartLine ()])) {
254249 return ;
255250 }
256251
257252 $ this ->setLineBranch ($ node ->getStartLine (), $ node ->getEndLine (), 1 );
258253 }
259254
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-
269255 public function executableLinesGroupedByBranch (): array
270256 {
271257 return $ this ->executableLinesGroupedByBranch ;
0 commit comments