phpstan-src icon indicating copy to clipboard operation
phpstan-src copied to clipboard

Support `@readonly` PHPDoc on the class as alternative to `@immutable`

Open herndlm opened this issue 1 year ago • 2 comments

Closes https://github.com/phpstan/phpstan/issues/11775 Docs PR: https://github.com/phpstan/phpstan/pull/11783

I decided to directly adapt ClassReflection::isImmutable() because there is already ClassReflection::isReadonly() for native readonly and that would clash. An alternative would be to add a new ClassReflection::isReadonlyPhpDoc() or so, but I dislike that isImmutable is also PHPDoc only and it then feels somewhat inconsistent / even more complicated :)

the rules are still, as before, only enabled with the readOnlyByPhpDoc feature toggle.

herndlm avatar Oct 02 '24 12:10 herndlm

You've opened the pull request against the latest branch 2.0.x. PHPStan 2.0 is not going to be released for months. If your code is relevant on 1.12.x and you want it to be released sooner, please rebase your pull request and change its target to 1.12.x.

phpstan-bot avatar Oct 02 '24 12:10 phpstan-bot

love it!

keradus avatar Oct 14 '24 17:10 keradus

Thank you.

ondrejmirtes avatar Nov 06 '24 19:11 ondrejmirtes