Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jun 11, 2022
1 parent 1e50564 commit 5e3643b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/NodeAnalyzer/PropertyFetchAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,15 @@ public function countLocalPropertyFetchName(ClassLike $class, string $propertyNa
}

$parentClassLike = $this->betterNodeFinder->findParentType($subNode, ClassLike::class);
if ($parentClassLike !== $class) {
return;

// property fetch in Trait cannot get parent ClassLike
if (! $parentClassLike instanceof ClassLike) {
++$total;
}

++$total;
if ($parentClassLike === $class) {
++$total;
}
});

return $total;
Expand All @@ -108,6 +112,12 @@ function (Node $node) use ($classLike, $propertyName): bool {
}

$parentClassLike = $this->betterNodeFinder->findParentType($node, ClassLike::class);

// property fetch in Trait cannot get parent ClassLike
if (! $parentClassLike instanceof ClassLike) {
return true;
}

return $parentClassLike === $classLike;
}
);
Expand Down

0 comments on commit 5e3643b

Please sign in to comment.