diff --git a/src/Rules/Properties/AccessStaticPropertiesRule.php b/src/Rules/Properties/AccessStaticPropertiesRule.php index 4ae0bdf44f..4233156fdf 100644 --- a/src/Rules/Properties/AccessStaticPropertiesRule.php +++ b/src/Rules/Properties/AccessStaticPropertiesRule.php @@ -142,17 +142,6 @@ private function processSingleProperty(Scope $scope, StaticPropertyFetch $node, $classType = $scope->resolveTypeByName($node->class); } - - $classReflection = $classType->getClassReflection(); - if ($classReflection !== null && $classReflection->isTrait()) { - return [ - RuleErrorBuilder::message(sprintf( - 'Access to static property $%s on trait %s.', - $name, - $classReflection->getName() - ))->build(), - ]; - } } else { $classTypeResult = $this->ruleLevelHelper->findTypeToCheck( $scope, diff --git a/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php b/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php index 8d0736c71d..cf1b46e976 100644 --- a/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php +++ b/tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php @@ -186,4 +186,9 @@ public function testClassExists(): void $this->analyse([__DIR__ . '/data/static-properties-class-exists.php'], []); } + public function testBug5143(): void + { + $this->analyse([__DIR__ . '/data/bug-5143.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Properties/data/bug-5143.php b/tests/PHPStan/Rules/Properties/data/bug-5143.php new file mode 100644 index 0000000000..78c8572ee5 --- /dev/null +++ b/tests/PHPStan/Rules/Properties/data/bug-5143.php @@ -0,0 +1,18 @@ +