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
wrongly reporting error on non existing array keys #6783
Comments
Added dumped types to see where it goes wrong: https://phpstan.org/r/2a1fef8b-0e9e-4d3c-bead-ab21416254be (after the |
maybe it's not an "wrong" error (it depends on the confidence you have in the returned data) // no error with
$data = (array)($data['foo'] ?? []); |
@quazardous After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
-26: Offset 'bar' does not exist on array{formatted: bool}.
+No errors |
@ondrejmirtes After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
18: Dumped type: array<string, mixed>
20: Dumped type: mixed
-24: Dumped type: *ERROR*
-28: Dumped type: array{formatted: bool}
-30: Offset 'bar' does not exist on array{formatted: bool}.
+24: Dumped type: non-empty-array
+28: Dumped type: hasOffsetValue('formatted', bool)&non-empty-array Full report
|
@staabm Regression test please. |
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. |
Bug report
PPHStan is reporting error on non existing array keys.
Code snippet that reproduces the problem
https://phpstan.org/r/f765334e-f883-4721-a742-7ea798cf9d4c
Expected output
No error
The text was updated successfully, but these errors were encountered: