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

Add @readonly rule that disallows default values #1391

Merged

Conversation

herndlm
Copy link
Contributor

@herndlm herndlm commented Jun 2, 2022

The counter-part to ReadOnlyPropertyRule. I looked at that one already and thought it deals with only native readonly behaviour, but forbidding default values too might make sense in regard to use @readonly for smoother upgrades to native readonly?

E.g. https://phpstan.org/r/0e1cd73e-6a9b-486f-8ae2-1781c0ff2eb4

feel free to just close this if you disagree, I thought it's easier to open the PR instead of starting a discussion / opening an issue :)

@herndlm herndlm force-pushed the read-only-by-php-doc-property-rule branch from b1c59da to 4fdea78 Compare June 2, 2022 18:43
@herndlm herndlm force-pushed the read-only-by-php-doc-property-rule branch from 4fdea78 to 8f39f88 Compare June 3, 2022 13:08
Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise perfect :)

@herndlm
Copy link
Contributor Author

herndlm commented Jun 3, 2022

btw sorry, I didn't want to "summon" you with the force-push ;)

@ondrejmirtes
Copy link
Member

Maybe test promoted property with @readonly and a default parameter value too - and it should actually be allowed, because it's not really a property with a default value...

@herndlm herndlm force-pushed the read-only-by-php-doc-property-rule branch from 8f39f88 to 98d1615 Compare June 3, 2022 19:55
@herndlm herndlm force-pushed the read-only-by-php-doc-property-rule branch from 98d1615 to 61ad35f Compare June 3, 2022 19:57
@herndlm herndlm marked this pull request as ready for review June 3, 2022 20:05
@herndlm herndlm requested a review from ondrejmirtes June 3, 2022 20:05
@herndlm herndlm force-pushed the read-only-by-php-doc-property-rule branch from 61ad35f to 2e93957 Compare June 3, 2022 20:13
@ondrejmirtes ondrejmirtes merged commit 04b22f9 into phpstan:1.7.x Jun 6, 2022
@ondrejmirtes
Copy link
Member

Thank you very much!

@herndlm herndlm deleted the read-only-by-php-doc-property-rule branch June 7, 2022 07:48
@herndlm herndlm restored the read-only-by-php-doc-property-rule branch June 30, 2022 11:49
@herndlm herndlm deleted the read-only-by-php-doc-property-rule branch July 19, 2022 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants