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

Make @psalm-readonly-allow-private-mutation as alias of readonly #7774

Closed
zonuexe opened this issue Aug 11, 2022 · 5 comments · Fixed by phpstan/phpstan-src#1609
Closed

Make @psalm-readonly-allow-private-mutation as alias of readonly #7774

zonuexe opened this issue Aug 11, 2022 · 5 comments · Fixed by phpstan/phpstan-src#1609

Comments

@zonuexe
Copy link
Contributor

zonuexe commented Aug 11, 2022

Feature request

In Psalm, @psalm-readonly-allow-private-mutation is shorthand for combining @readonly and @psalm-allow-private-mutation. Adding @psalm-readonly-allow-private-mutation to PHPStan as an alias for @readonly improves interoperability.

I liked Psalm's @psalm-allow-private-mutation so I looked into PHPStan's implementation to bring the same functionality into PHPStan, but found that ReadOnlyByPhpDocPropertyAssignRule implicitly behaves as a private mutation. So we don't need to add @phpstan-allow-private-mutation.

Did PHPStan help you today? Did it make you happy in any way?

I've been working on a major refactoring for the last few days and I'm really grateful for PHPStan.

@zonuexe
Copy link
Contributor Author

zonuexe commented Aug 11, 2022

@phpstan-disallow-private-mutation is required for Psalm compatibility, but I don't have that use case 😄. https://phpstan.org/r/9002912b-4c80-43bb-8184-4ab6d1437b83

@zonuexe
Copy link
Contributor Author

zonuexe commented Aug 11, 2022

@ondrejmirtes
I missed that readOnlyByPhpDoc is enabled by bleedingEdge. Are you sure you want to add @phpstan-allow-private-mutation and @phpstan-readonly-allow-private-mutation like Psalm?

@ondrejmirtes
Copy link
Member

I don't want these extra features now, I just want to be cross-compatible with Psalm. Just test the code you added 😊

@zonuexe
Copy link
Contributor Author

zonuexe commented Aug 11, 2022

Ok, I'll make a proposal in another issue to add the feature.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants