Conversation
|
Maybe you can cherry-pick 🍒 some test from this solution? https://github.com/svnldwg/phpstan-rules/ |
|
Really really nice! Feel free to mark it as ready to be merged :) About readonly properties and traits - yeah, it's a mystery, I have no idea why it would be broken. There are already some issue about it: phpstan/phpstan#7219, phpstan/phpstan#7198 Would be great to solve that in a follow-up :) |
|
Ok then, will mark it as ready since I think this is already adding value like that. I'll try to look into some of the more potentially headache-inducing edge/trait cases in follow-ups. |
|
Thank you! |
|
What do you think of people using native |
|
It's fine I guess. How we modeled it it means those are two separate errors which is correct. Imagine that people will want to ignore one but not the other - the current model supports that. Also once you're on 8.1, it's easy to upgrade to 8.2 at which point you can use the native readonly class. |
Closes phpstan/phpstan#4600
See also https://psalm.dev/docs/annotating_code/supported_annotations/#psalm-immutable
first draft, not sure about some edge cases yet. e.g. inheritance. most likely more tests are needed in a dedicated file maybe
does also not support traits because it looks like traits are currently not fully working with native or phpdoc readonly (e.g. readonly property in trait, missing assignment in class that uses that trait). maybe a good follow-up / separate feature/fix? I created phpstan/phpstan#7271
I'm also still not sure if this should be also settable via
@readonlyon class-level maybe too?