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

@immutable is not inherrited from extending or implemeting #7506

Closed
BackEndTea opened this issue Jun 22, 2022 · 3 comments · Fixed by phpstan/phpstan-src#1489
Closed

@immutable is not inherrited from extending or implemeting #7506

BackEndTea opened this issue Jun 22, 2022 · 3 comments · Fixed by phpstan/phpstan-src#1489

Comments

@BackEndTea
Copy link
Contributor

Feature request

Modifying properties on the immutable class does cause an error. But i expected the @immutable prop to be inherrited by its children.

In my example i would've expected the assignment of a property in the B class to also cause an issue. The same should probably be the case for interfaces.

https://phpstan.org/r/bd80b15d-5af1-4d10-8f36-20968ecacd45

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

I'm loving the immutable so far.

@herndlm
Copy link
Contributor

herndlm commented Jul 1, 2022

I'll open a PR for this very soon but I just wondered - is it a good idea to basically force @immutable on inheriting classes? E.g. what about somebody extending some vendor class that has the immutable phpdoc, but they actually don't want their newly added props in the child class to be readonly?

@BackEndTea
Copy link
Contributor Author

Id say there is a baseline of ignore comment for that. The immutable annotation means the class is intended to be immutable.

@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 Aug 11, 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.

3 participants