Skip to content

Commit

Permalink
[Performance] Using cheap chekc first on UndefinedVariableResolver::s…
Browse files Browse the repository at this point in the history
…houldSkipVariable() (#3643)
  • Loading branch information
samsonasik committed Apr 21, 2023
1 parent 79a6309 commit ae99f13
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit ae99f13

Please sign in to comment.