diff --git a/build/target-repository/composer.json b/build/target-repository/composer.json index c0847b5610b..fc0daff5961 100644 --- a/build/target-repository/composer.json +++ b/build/target-repository/composer.json @@ -9,7 +9,7 @@ ], "require": { "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.18" + "phpstan/phpstan": "^2.1.26" }, "autoload": { "files": [ diff --git a/composer.json b/composer.json index 477fed0e024..032bceb95a7 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "ocramius/package-versions": "^2.10", "ondram/ci-detector": "^4.2", "phpstan/phpdoc-parser": "^2.2", - "phpstan/phpstan": "^2.1.18", + "phpstan/phpstan": "^2.1.26", "react/event-loop": "^1.5", "react/promise": "^3.2", "react/socket": "^1.16", diff --git a/rules/CodeQuality/NodeAnalyzer/MissingPropertiesResolver.php b/rules/CodeQuality/NodeAnalyzer/MissingPropertiesResolver.php index 1a461072065..65c9b1aacab 100644 --- a/rules/CodeQuality/NodeAnalyzer/MissingPropertiesResolver.php +++ b/rules/CodeQuality/NodeAnalyzer/MissingPropertiesResolver.php @@ -34,7 +34,7 @@ public function resolve(Class_ $class, ClassReflection $classReflection, array $ } // 2. is part of class docblock or another magic, skip it - if ($classReflection->hasProperty($definedPropertyWithType->getName())) { + if ($classReflection->hasInstanceProperty($definedPropertyWithType->getName())) { continue; } diff --git a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php index fb12cebc991..303d6a348ae 100644 --- a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php +++ b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php @@ -143,7 +143,7 @@ private function shouldSkip( // native members. $hasMember = match (true) { $node instanceof StaticPropertyFetch => $isFinal - ? $classReflection->hasProperty($name) + ? $classReflection->hasStaticProperty($name) : $classReflection->hasNativeProperty($name), $node instanceof StaticCall => $isFinal ? $classReflection->hasMethod($name) @@ -157,7 +157,7 @@ private function shouldSkip( $reflection = match (true) { $node instanceof StaticPropertyFetch => $isFinal - ? $classReflection->getProperty($name, $scope) + ? $classReflection->getStaticProperty($name) : $classReflection->getNativeProperty($name), $node instanceof StaticCall => $isFinal ? $classReflection->getMethod($name, $scope) diff --git a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php index d7a88ccdbf1..52f0b4374b1 100644 --- a/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php +++ b/rules/CodeQuality/Rector/Isset_/IssetOnPropertyObjectToPropertyExistsRector.php @@ -131,7 +131,7 @@ public function refactor(Node $node): ?Node continue; } - if (! $classReflection->hasProperty($propertyFetchName) || $classReflection->isBuiltin()) { + if (! $classReflection->hasInstanceProperty($propertyFetchName) || $classReflection->isBuiltin()) { $newNodes[] = $this->replaceToPropertyExistsWithNullCheck( $issetExpr->var, $propertyFetchName, diff --git a/rules/Privatization/Guard/ParentPropertyLookupGuard.php b/rules/Privatization/Guard/ParentPropertyLookupGuard.php index ea1556d6c91..dc93446a0c8 100644 --- a/rules/Privatization/Guard/ParentPropertyLookupGuard.php +++ b/rules/Privatization/Guard/ParentPropertyLookupGuard.php @@ -128,7 +128,7 @@ private function isFoundInMethodStmts(array $stmts, string $propertyName, string private function isGuardedByParents(array $parentClassReflections, string $propertyName, string $className): bool { foreach ($parentClassReflections as $parentClassReflection) { - if ($parentClassReflection->hasProperty($propertyName)) { + if ($parentClassReflection->hasInstanceProperty($propertyName) || $parentClassReflection->hasStaticProperty($propertyName)) { return false; } diff --git a/src/NodeManipulator/PropertyManipulator.php b/src/NodeManipulator/PropertyManipulator.php index 754ff344414..defc0fa3209 100644 --- a/src/NodeManipulator/PropertyManipulator.php +++ b/src/NodeManipulator/PropertyManipulator.php @@ -155,7 +155,7 @@ public function isUsedByTrait(ClassReflection $classReflection, string $property public function hasTraitWithSamePropertyOrWritten(ClassReflection $classReflection, string $propertyName): bool { foreach ($classReflection->getTraits() as $traitUse) { - if ($traitUse->hasProperty($propertyName)) { + if ($traitUse->hasInstanceProperty($propertyName) || $traitUse->hasStaticProperty($propertyName)) { return true; } diff --git a/src/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php b/src/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php index 249bf783f53..cfcb2b15e5f 100644 --- a/src/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php +++ b/src/NodeTypeResolver/NodeTypeResolver/PropertyFetchTypeResolver.php @@ -82,7 +82,7 @@ private function getVendorPropertyFetchType(PropertyFetch $propertyFetch): Type } $classReflection = $this->reflectionProvider->getClass($varType->getClassName()); - if (! $classReflection->hasProperty($propertyName)) { + if (! $classReflection->hasInstanceProperty($propertyName)) { return new MixedType(); } @@ -91,7 +91,7 @@ private function getVendorPropertyFetchType(PropertyFetch $propertyFetch): Type return new MixedType(); } - $extendedPropertyReflection = $classReflection->getProperty($propertyName, $propertyFetchScope); + $extendedPropertyReflection = $classReflection->getInstanceProperty($propertyName, $propertyFetchScope); return $extendedPropertyReflection->getReadableType(); }