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 during list initialization of readonly properties #7284

Closed
hemberger opened this issue May 22, 2022 · 2 comments
Closed

False positive during list initialization of readonly properties #7284

hemberger opened this issue May 22, 2022 · 2 comments

Comments

@hemberger
Copy link

Bug report

During list initialization of readonly properties, PHPStan incorrectly reports that we are trying to access the properties before initialization.

Code snippet that reproduces the problem

class Foo {
    private int $x;
    private int $y;
	
    public function __construct() {
        [$this->x, $this->y] = [1, 2];
    }
}

Access to an uninitialized readonly property Foo::$x.
Access to an uninitialized readonly property Foo::$y.

https://phpstan.org/r/285b0af3-5c96-4a5c-9e3f-b6f1c1f35bdd

Expected output

No errors!

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

I am slowly working my way to higher PHPStan levels, and eagerly looking forward to level 9 some day. Thank you so much to everyone who has made PHPStan possible!

@hemberger
Copy link
Author

Duplicate of #7119. Sorry for the noise!

@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 Jun 23, 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

1 participant