Skip to content

Commit

Permalink
Add a promoted property test
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed Jun 3, 2022
1 parent 4cdc22f commit 2e93957
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Expand Up @@ -4,6 +4,7 @@

use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use const PHP_VERSION_ID;

/**
* @extends RuleTestCase<ReadOnlyByPhpDocPropertyRule>
Expand All @@ -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.',
Expand Down
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.1

namespace ReadOnlyPropertyPhpDoc;

Expand All @@ -21,3 +21,13 @@ class Foo
private $baz = 0;

}

final class ErrorResponse
{
public function __construct(
/** @readonly */
public string $message = ''
)
{
}
}

0 comments on commit 2e93957

Please sign in to comment.