diff --git a/tests/PHPStan/Rules/Properties/ReadOnlyByPhpDocPropertyRuleTest.php b/tests/PHPStan/Rules/Properties/ReadOnlyByPhpDocPropertyRuleTest.php index b13c566b4f..94f906d60c 100644 --- a/tests/PHPStan/Rules/Properties/ReadOnlyByPhpDocPropertyRuleTest.php +++ b/tests/PHPStan/Rules/Properties/ReadOnlyByPhpDocPropertyRuleTest.php @@ -4,6 +4,7 @@ use PHPStan\Rules\Rule; use PHPStan\Testing\RuleTestCase; +use const PHP_VERSION_ID; /** * @extends RuleTestCase @@ -18,6 +19,10 @@ protected function getRule(): Rule public function testRule(): void { + if (PHP_VERSION_ID < 80100) { + $this->markTestSkipped('Test requires PHP 8.1.'); + } + $this->analyse([__DIR__ . '/data/read-only-property-phpdoc.php'], [ [ '@readonly property cannot have a default value.', diff --git a/tests/PHPStan/Rules/Properties/data/read-only-property-phpdoc.php b/tests/PHPStan/Rules/Properties/data/read-only-property-phpdoc.php index 6522f2668b..bb730d8e01 100644 --- a/tests/PHPStan/Rules/Properties/data/read-only-property-phpdoc.php +++ b/tests/PHPStan/Rules/Properties/data/read-only-property-phpdoc.php @@ -1,4 +1,4 @@ -= 8.1 namespace ReadOnlyPropertyPhpDoc; @@ -21,3 +21,13 @@ class Foo private $baz = 0; } + +final class ErrorResponse +{ + public function __construct( + /** @readonly */ + public string $message = '' + ) + { + } +}