-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
Invalid array key type for 3-nested for loops #3044
Labels
Milestone
Comments
@spl1nes PHPStan now reports different result with your code snippet: @@ @@
-36: Method HelloWorld::invalidType() should return array<int, array<int, float>> but returns array<int|string, array<int, float>>.
+PHP 8.0 (2 errors)
+==========
+
+ 8: Method HelloWorld::getIntArrayFloatArray() return type has no value type specified in iterable type array.
+20: Method HelloWorld::invalidType() return type has no value type specified in iterable type array.
+
+PHP 7.4 (1 error)
+==========
+
+36: Method HelloWorld::invalidType() should return array<int, array<int, float>> but returns array<int|string, array<int, float>>.
+
+PHP 7.1 – 7.3 (2 errors)
+==========
+
+ 8: Method HelloWorld::getIntArrayFloatArray() return type has no value type specified in iterable type array.
+20: Method HelloWorld::invalidType() return type has no value type specified in iterable type array. Full reportPHP 8.0 (2 errors)
PHP 7.4 (1 error)
PHP 7.1 – 7.3 (2 errors)
|
@spl1nes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-36: Method HelloWorld::invalidType() should return array<int, array<int, float>> but returns array<int|string, array<int, float>>.
+No errors |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
When using 3 nested for loops on an
array<int, array<int, float>>
and assigning them to an array phpstan believes the first index can beint|string
.Code snippet that reproduces the problem
https://phpstan.org/r/899f83f5-5deb-4335-b8e7-54c4f3315abb
Expected output
No error.
The text was updated successfully, but these errors were encountered: