Skip to content

Commit

Permalink
Defer type-resolving in SideEffectNodeDetector (#3762)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed May 7, 2023
1 parent ce46293 commit ea3d4f1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions rules/DeadCode/SideEffect/SideEffectNodeDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ public function detect(Expr $expr): bool
return true;
}

$exprStaticType = $this->nodeTypeResolver->getType($expr);
if ($exprStaticType instanceof ConstantType) {
return false;
}

foreach (self::SIDE_EFFECT_NODE_TYPES as $sideEffectNodeType) {
if ($expr instanceof $sideEffectNodeType) {
return false;
}
}

$exprStaticType = $this->nodeTypeResolver->getType($expr);
if ($exprStaticType instanceof ConstantType) {
return false;
}

if ($expr instanceof FuncCall) {
return ! $this->pureFunctionDetector->detect($expr);
}
Expand Down

0 comments on commit ea3d4f1

Please sign in to comment.