Skip to content

Commit d0b4a27

Browse files
jakubtobiaszondrejmirtes
authored andcommitted
Add a test covering a hooked property in a readonly class
1 parent da5754c commit d0b4a27

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tests/PHPStan/Rules/Properties/PropertyInClassRuleTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ public function testPhp84AndReadonlyHookedProperties(): void
174174
'Hooked properties cannot be readonly.',
175175
19,
176176
],
177+
[
178+
'Hooked properties cannot be readonly.',
179+
24,
180+
],
177181
]);
178182
}
179183

tests/PHPStan/Rules/Properties/data/readonly-property-hooks.php

+8
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,11 @@ abstract class HiWorld
1818
{
1919
public abstract readonly string $firstName { get { return 'jake'; } set; }
2020
}
21+
22+
readonly class GoodMorningWorld
23+
{
24+
public string $firstName {
25+
get => $this->firstName;
26+
set => $this->firstName;
27+
}
28+
}

0 commit comments

Comments
 (0)