Skip to content

Commit 99afffd

Browse files
committed
Refactoring - extract isNoopExpr
1 parent a1fffb3 commit 99afffd

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/Rules/DeadCode/NoopRule.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,7 @@ public function processNode(Node $node, Scope $scope): array
4545
->build(),
4646
];
4747
}
48-
if (
49-
!$expr instanceof Node\Expr\Variable
50-
&& !$expr instanceof Node\Expr\PropertyFetch
51-
&& !$expr instanceof Node\Expr\StaticPropertyFetch
52-
&& !$expr instanceof Node\Expr\NullsafePropertyFetch
53-
&& !$expr instanceof Node\Expr\ArrayDimFetch
54-
&& !$expr instanceof Node\Scalar
55-
&& !$expr instanceof Node\Expr\Isset_
56-
&& !$expr instanceof Node\Expr\Empty_
57-
&& !$expr instanceof Node\Expr\ConstFetch
58-
&& !$expr instanceof Node\Expr\ClassConstFetch
59-
) {
48+
if (!$this->isNoopExpr($expr)) {
6049
return [];
6150
}
6251

@@ -74,4 +63,18 @@ public function processNode(Node $node, Scope $scope): array
7463
];
7564
}
7665

66+
public function isNoopExpr(Node\Expr $expr): bool
67+
{
68+
return $expr instanceof Node\Expr\Variable
69+
|| $expr instanceof Node\Expr\PropertyFetch
70+
|| $expr instanceof Node\Expr\StaticPropertyFetch
71+
|| $expr instanceof Node\Expr\NullsafePropertyFetch
72+
|| $expr instanceof Node\Expr\ArrayDimFetch
73+
|| $expr instanceof Node\Scalar
74+
|| $expr instanceof Node\Expr\Isset_
75+
|| $expr instanceof Node\Expr\Empty_
76+
|| $expr instanceof Node\Expr\ConstFetch
77+
|| $expr instanceof Node\Expr\ClassConstFetch;
78+
}
79+
7780
}

0 commit comments

Comments
 (0)