-
-
Notifications
You must be signed in to change notification settings - Fork 887
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
Error recognizing key value in array in case of union #6728
Comments
This is basically a duplicate of #6469, but I'm gonna keep this open too. |
For a simple fix change the conditon to: https://phpstan.org/r/8c941b81-4c25-4852-9d33-9516666296a9 |
@janbarasek After the latest push in 1.8.x, PHPStan now reports different result with your code snippet: @@ @@
-22: Offset 'errorReason' does not exist on array{success: false, errorReason: string}|array{success: false, id: int}.
+19: Call to function assert() with true will always evaluate to true.
+19: Offset 'id' on array{success: true, id: int} in isset() always exists and is not nullable. Full report
|
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
PhpStan will incorrectly overwrite the value of the key in the array if it was defined as union.
Code snippet that reproduces the problem
https://phpstan.org/r/b9b6eddd-b448-4642-bc09-8bfc4555712f
Expected output
In the case of a union of multiple different arrays, the context should correctly identify which array I just used.
The text was updated successfully, but these errors were encountered: