diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 29dc20893..d42afbc66 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -215,7 +215,6 @@ - diff --git a/src/Reflection/ReflectionProperty.php b/src/Reflection/ReflectionProperty.php index 6e2945d58..1aba925a3 100644 --- a/src/Reflection/ReflectionProperty.php +++ b/src/Reflection/ReflectionProperty.php @@ -707,10 +707,10 @@ private function computeImmediateVirtual(PropertyNode $node): bool return true; } - return $this->computeImmediateVirtualBasedOnGetHook($node, $getHook); + return $this->computeImmediateVirtualBasedOnGetHook($getHook); } - private function computeImmediateVirtualBasedOnGetHook(PropertyNode $node, Node\PropertyHook $getHook): bool + private function computeImmediateVirtualBasedOnGetHook(Node\PropertyHook $getHook): bool { $getHookBody = $getHook->getStmts(); @@ -719,10 +719,6 @@ private function computeImmediateVirtualBasedOnGetHook(PropertyNode $node, Node\ return true; } - if (! $node->isPublic()) { - return true; - } - return ! $this->isHookUsingThisProperty($getHook); } diff --git a/test/unit/Fixture/PropertyHooks.php b/test/unit/Fixture/PropertyHooks.php index 74d9181ed..0da82eae3 100644 --- a/test/unit/Fixture/PropertyHooks.php +++ b/test/unit/Fixture/PropertyHooks.php @@ -35,15 +35,9 @@ abstract class ToBeVirtualOrNotToBeVirtualThatIsTheQuestion { public string $notVirtualBecauseNoHooks = 'string'; - public string $notVirtualBecauseOfPublicVisibilityAndThePropertyIsUsedInGet { + public string $notVirtualBecauseThePropertyIsUsedInGet { get { - return strtoupper($this->notVirtualBecauseOfPublicVisibilityAndThePropertyIsUsedInGet); - } - } - - protected string $virtualBecauseOfNotPublicVisibilityAndNoSet { - get { - return strtoupper($this->virtualBecauseOfNotPublicVisibilityAndNoSet); + return strtoupper($this->notVirtualBecauseThePropertyIsUsedInGet); } } diff --git a/test/unit/Reflection/ReflectionPropertyTest.php b/test/unit/Reflection/ReflectionPropertyTest.php index 45c8f0e7c..1659f54ea 100644 --- a/test/unit/Reflection/ReflectionPropertyTest.php +++ b/test/unit/Reflection/ReflectionPropertyTest.php @@ -1094,8 +1094,7 @@ public static function virtualProvider(): array { return [ ['notVirtualBecauseNoHooks', false], - ['notVirtualBecauseOfPublicVisibilityAndThePropertyIsUsedInGet', false], - ['virtualBecauseOfNotPublicVisibilityAndNoSet', true], + ['notVirtualBecauseThePropertyIsUsedInGet', false], ['notVirtualBecauseOfShortSyntax', false], ['virtualBecauseThePropertyIsNotUsedInGet', true], ['virtualBecauseSetWorksWithDifferentProperty', true],