From ae99f13c3bb546659ee87450de554585a6c7974c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 21 Apr 2023 14:29:08 +0700 Subject: [PATCH] [Performance] Using cheap chekc first on UndefinedVariableResolver::shouldSkipVariable() (#3643) --- .../NodeAnalyzer/UndefinedVariableResolver.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php b/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php index b68ef68c19c..ee9c6381991 100644 --- a/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php +++ b/rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php @@ -146,10 +146,6 @@ private function shouldSkipVariable(Variable $variable, Node $parentNode): bool return true; } - if ($this->variableAnalyzer->isStaticOrGlobal($variable)) { - return true; - } - if ($this->isAssign($parentNode)) { return true; } @@ -163,10 +159,6 @@ private function shouldSkipVariable(Variable $variable, Node $parentNode): bool return true; } - if ($this->isDifferentWithOriginalNodeOrNoScope($variable)) { - return true; - } - $variableName = $this->nodeNameResolver->getName($variable); // skip $this, as probably in outer scope @@ -178,6 +170,14 @@ private function shouldSkipVariable(Variable $variable, Node $parentNode): bool return true; } + if ($this->isDifferentWithOriginalNodeOrNoScope($variable)) { + return true; + } + + if ($this->variableAnalyzer->isStaticOrGlobal($variable)) { + return true; + } + if ($this->hasPreviousCheckedWithIsset($variable)) { return true; }