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

False positive when using destructuring to set readonly properties in constructor #7399

Closed
ZebulanStanphill opened this issue Jun 4, 2022 · 2 comments

Comments

@ZebulanStanphill
Copy link
Contributor

Bug report

PHPStan complains about "Access to an uninitialized readonly property" when using destructuring to set a readonly property... even when doing so in a constructor.

And yes, this does actually work: https://3v4l.org/GjMjC#v8.1.6

This is probably related to #7155.

Code snippet that reproduces the problem

https://phpstan.org/r/faf5a79e-a7df-491f-9b61-b4139d1d27ba

Expected output

No errors should be reported for the provided snippet.

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

PHPStan helped me catch some dumb bugs while refactoring some classes to use readonly properties instead of magic methods.

@ondrejmirtes
Copy link
Member

Duplicate of #7119.

@github-actions
Copy link

github-actions bot commented Jul 8, 2022

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 Jul 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants