diff --git a/tests/PHPStan/Rules/Properties/MissingReadOnlyPropertyAssignRuleTest.php b/tests/PHPStan/Rules/Properties/MissingReadOnlyPropertyAssignRuleTest.php index 391afc01d1d..3ff238edcf4 100644 --- a/tests/PHPStan/Rules/Properties/MissingReadOnlyPropertyAssignRuleTest.php +++ b/tests/PHPStan/Rules/Properties/MissingReadOnlyPropertyAssignRuleTest.php @@ -17,36 +17,39 @@ class MissingReadOnlyPropertyAssignRuleTest extends RuleTestCase protected function getRule(): Rule { - return new MissingReadOnlyPropertyAssignRule( - new ConstructorsHelper([ - 'MissingReadOnlyPropertyAssign\\TestCase::setUp', - ]), - new DirectReadWritePropertiesExtensionProvider([ - new class() implements ReadWritePropertiesExtension { + $extensions = []; + if (PHP_VERSION_ID >= 80100) { + $extensions[] = new class() implements ReadWritePropertiesExtension { - public function isAlwaysRead(PropertyReflection $property, string $propertyName): bool - { - return $this->isEntityId($property, $propertyName); - } + public function isAlwaysRead(PropertyReflection $property, string $propertyName): bool + { + return $this->isEntityId($property, $propertyName); + } - public function isAlwaysWritten(PropertyReflection $property, string $propertyName): bool - { - return $this->isEntityId($property, $propertyName); - } + public function isAlwaysWritten(PropertyReflection $property, string $propertyName): bool + { + return $this->isEntityId($property, $propertyName); + } - public function isInitialized(PropertyReflection $property, string $propertyName): bool - { - return $this->isEntityId($property, $propertyName); - } + public function isInitialized(PropertyReflection $property, string $propertyName): bool + { + return $this->isEntityId($property, $propertyName); + } - private function isEntityId(PropertyReflection $property, string $propertyName): bool - { - return $property->getDeclaringClass()->getName() === 'MissingReadOnlyPropertyAssign\\Entity' - && in_array($propertyName, ['id'], true); - } + private function isEntityId(PropertyReflection $property, string $propertyName): bool + { + return $property->getDeclaringClass()->getName() === 'MissingReadOnlyPropertyAssign\\Entity' + && in_array($propertyName, ['id'], true); + } - }, + }; + } + + return new MissingReadOnlyPropertyAssignRule( + new ConstructorsHelper([ + 'MissingReadOnlyPropertyAssign\\TestCase::setUp', ]), + new DirectReadWritePropertiesExtensionProvider($extensions), ); }