Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support @readonly PHPDoc on the class as alternative to @immutable #3523

Open
wants to merge 1 commit into
base: 1.12.x
Choose a base branch
from

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Oct 2, 2024

Closes phpstan/phpstan#11775
Docs PR: phpstan/phpstan#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 herndlm changed the base branch from 2.0.x to 1.12.x October 2, 2024 12:46
@phpstan-bot
Copy link
Collaborator

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.

@keradus
Copy link

keradus commented Oct 14, 2024

love it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@readonly above class
3 participants