nodeNameResolver = $nodeNameResolver;
$this->betterNodeFinder = $betterNodeFinder;
$this->astResolver = $astResolver;
$this->nodeTypeResolver = $nodeTypeResolver;
$this->reflectionResolver = $reflectionResolver;
}
public function isLocalPropertyFetch(Node $node) : bool
{
if (!$node instanceof PropertyFetch && !$node instanceof StaticPropertyFetch && !$node instanceof NullsafePropertyFetch) {
return \false;
}
$variableType = $node instanceof StaticPropertyFetch ? $this->nodeTypeResolver->getType($node->class) : $this->nodeTypeResolver->getType($node->var);
if ($variableType instanceof ObjectType) {
$classReflection = $this->reflectionResolver->resolveClassReflection($node);
if ($classReflection instanceof ClassReflection) {
return $classReflection->getName() === $variableType->getClassName();
}
return \false;
}
if (!$variableType instanceof ThisType) {
return $this->isTraitLocalPropertyFetch($node);
}
return \true;
}
public function isLocalPropertyFetchName(Node $node, string $desiredPropertyName) : bool
{
if (!$node instanceof PropertyFetch && !$node instanceof StaticPropertyFetch && !$node instanceof NullsafePropertyFetch) {
return \false;
}
if (!$this->nodeNameResolver->isName($node->name, $desiredPropertyName)) {
return \false;
}
return $this->isLocalPropertyFetch($node);
}
public function containsLocalPropertyFetchName(Trait_ $trait, string $propertyName) : bool
{
if ($trait->getProperty($propertyName) instanceof Property) {
return \true;
}
return (bool) $this->betterNodeFinder->findFirst($trait, function (Node $node) use($propertyName) : bool {
return $this->isLocalPropertyFetchName($node, $propertyName);
});
}
/**
* @phpstan-assert-if-true PropertyFetch|StaticPropertyFetch $node
*/
public function isPropertyFetch(Node $node) : bool
{
if ($node instanceof PropertyFetch) {
return \true;
}
return $node instanceof StaticPropertyFetch;
}
/**
* Matches:
* "$this->someValue = $