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
Array shapes are not properly checked when appending arrays #6356
Comments
@phinor After the latest commit in 1.6.x, PHPStan now reports different result with your code snippet: @@ @@
17: Property HelloWorld::$details (array{name: string, age: int}) does not accept array{name: string, age: 'Forty-two'}.
19: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Eleventy-one'|int}>.
24: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Twelve'|int}>.
-27: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Five'|int}>.
+27: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{age: 'Five'|int, name: string}>. Full report
|
Another code snippet that replicates this issue: https://phpstan.org/r/ecb4ac1d-91f9-4522-9631-23ce4ed3e310 |
@phinor After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
17: Property HelloWorld::$details (array{name: string, age: int}) does not accept array{name: string, age: 'Forty-two'}.
19: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Eleventy-one'|int}>.
-24: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Twelve'|int}>.
-27: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Five'|int}>.
+24: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Twelve'|int}>. Full report
|
@phinor After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
17: Property HelloWorld::$details (array{name: string, age: int}) does not accept array{name: string, age: 'Forty-two'}.
-19: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Eleventy-one'|int}>.
-24: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Twelve'|int}>.
-27: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Five'|int}>.
+19: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: 'Bilbo Baggins', age: 'Eleventy-one'}|array{name: string, age: int}>.
+24: Property HelloWorld::$nestedDetails (array<array{name: string, age: int}>) does not accept non-empty-array<array{name: string, age: 'Twelve'}|array{name: string, age: int}>. Full report
|
@allejo After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
-17: Property HelloWorld::$lists (array<0|1|2|3, array<int, bool>>) does not accept non-empty-array<int<0, 3>, array<int, bool>>.
+No errors |
Bug report
When appending records to an array, the array shapes are not checked / reported properly.
Code snippet that reproduces the problem
https://phpstan.org/r/871e400d-6df0-4cc0-91a6-3b9c5798b987
Expected output
Line 25 does not produce an error (and I believe it should), but this error seemingly is reported on line 27 which should not generate an error.
The text was updated successfully, but these errors were encountered: