Skip to content

Commit

Permalink
[Core] Improve PropertyFetchAnalyzer::PropertyFetchAnalyzer() to chec…
Browse files Browse the repository at this point in the history
…k against Variable and Name (#2237)
  • Loading branch information
samsonasik committed May 5, 2022
1 parent d8c5236 commit aa6524e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/NodeAnalyzer/PropertyFetchAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PhpParser\Node\Expr\PropertyFetch;
use PhpParser\Node\Expr\StaticPropertyFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Name;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
Expand Down Expand Up @@ -38,14 +39,18 @@ public function __construct(
public function isLocalPropertyFetch(Node $node): bool
{
if ($node instanceof PropertyFetch) {
if ($node->var instanceof MethodCall) {
if (! $node->var instanceof Variable) {
return false;
}

return $this->nodeNameResolver->isName($node->var, self::THIS);
}

if ($node instanceof StaticPropertyFetch) {
if (! $node->class instanceof Name) {
return false;
}

return $this->nodeNameResolver->isName($node->class, ObjectReference::SELF()->getValue());
}

Expand Down

0 comments on commit aa6524e

Please sign in to comment.