diff --git a/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_readonly_new_static.php.inc b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_readonly_new_static.php.inc new file mode 100644 index 00000000000..c8bfd2a58cf --- /dev/null +++ b/rules-tests/Php81/Rector/Property/ReadOnlyPropertyRector/Fixture/skip_readonly_new_static.php.inc @@ -0,0 +1,18 @@ +method = 'hi'; + $self->method = 'hello'; + return $self; + } +} + +?> diff --git a/src/PhpParser/NodeFinder/PropertyFetchFinder.php b/src/PhpParser/NodeFinder/PropertyFetchFinder.php index e82b43e1793..df68d3f15d6 100644 --- a/src/PhpParser/NodeFinder/PropertyFetchFinder.php +++ b/src/PhpParser/NodeFinder/PropertyFetchFinder.php @@ -141,10 +141,11 @@ public function isLocalPropertyFetchByName(Expr $expr, Class_|Trait_ $class, str } $type = $this->nodeTypeResolver->getType($expr->var); - return $type instanceof FullyQualifiedObjectType && $this->nodeNameResolver->isName( - $class, - $type->getClassName() - ); + if ($type instanceof \PHPStan\Type\StaticType || $type instanceof FullyQualifiedObjectType) { + return $this->nodeNameResolver->isName($class, $type->getClassName()); + } + + return false; } /**