File tree Expand file tree Collapse file tree
rules/DeadCode/Rector/Stmt Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313use PhpParser \Node \Stmt \If_ ;
1414use PhpParser \Node \Stmt \Return_ ;
1515use Rector \Contract \PhpParser \Node \StmtsAwareInterface ;
16+ use Rector \DeadCode \SideEffect \SideEffectNodeDetector ;
1617use Rector \Rector \AbstractRector ;
1718use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
1819use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
2223 */
2324final class RemoveConditionExactReturnRector extends AbstractRector
2425{
26+ public function __construct (
27+ private readonly SideEffectNodeDetector $ sideEffectNodeDetector
28+ ) {
29+ }
30+
2531 public function getRuleDefinition (): RuleDefinition
2632 {
2733 return new RuleDefinition (
@@ -94,12 +100,8 @@ public function refactor(Node $node): ?Node
94100 }
95101
96102 $ identicalOrEqual = $ stmt ->cond ;
97- // skip obvious complexity
98- if ($ identicalOrEqual ->right instanceof MethodCall) {
99- continue ;
100- }
101103
102- if ($ identicalOrEqual ->right instanceof StaticCall ) {
104+ if ($ this -> sideEffectNodeDetector -> detect ( $ identicalOrEqual ->right ) ) {
103105 continue ;
104106 }
105107
You can’t perform that action at this time.
0 commit comments