From ea3d4f164337d11e757a0348d5445efb4b6d5b2f Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 7 May 2023 21:09:23 +0200 Subject: [PATCH] Defer type-resolving in SideEffectNodeDetector (#3762) --- rules/DeadCode/SideEffect/SideEffectNodeDetector.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php index f4033c9b271..9d92202e7ac 100644 --- a/rules/DeadCode/SideEffect/SideEffectNodeDetector.php +++ b/rules/DeadCode/SideEffect/SideEffectNodeDetector.php @@ -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); }