Skip to content

Commit

Permalink
Fixed 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Nov 15, 2021
1 parent badfee1 commit 059526d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rules/Php56/NodeAnalyzer/UndefinedVariableResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Isset_;
use PhpParser\Node\Expr\List_;
use PhpParser\Node\Expr\Ternary;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down Expand Up @@ -116,9 +115,9 @@ private function issetOrUnsetParent(Node $parentNode): bool
return in_array($parentNode::class, [Unset_::class, UnsetCast::class, Isset_::class], true);
}

private function conditionParent(Node $parentNode): bool
private function isAsCoalesceLeft(Node $parentNode, Variable $variable): bool
{
return in_array($parentNode::class, [Ternary::class, Coalesce::class], true);
return $parentNode instanceof Coalesce && $parentNode->left === $variable;
}

private function isAssignOrStaticVariableParent(Node $parentNode): bool
Expand Down Expand Up @@ -149,6 +148,10 @@ private function shouldSkipVariable(Variable $variable): bool
return true;
}

if ($this->isAsCoalesceLeft($parentNode, $variable)) {
return true;
}

// list() = | [$values] = defines variables as null
if ($this->isListAssign($parentNode)) {
return true;
Expand Down

0 comments on commit 059526d

Please sign in to comment.