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
is_* with null coalesce on array value does not reduce the type #5304
Labels
Milestone
Comments
@BackEndTea After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
- 9: Dumped type: array(?'foo' => string)
-13: Dumped type: array('foo' => string)
+No errors |
@BackEndTea After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
- 9: Dumped type: array(?'foo' => string)
-13: Dumped type: array('foo' => string)
+ 9: Dumped type: array{foo?: string}
+13: Dumped type: array{foo: string} 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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
When doing an
is_string
check on an array access, within an if with a null coalesce (in case the key is not present), does not make PHPStan understand that they key must be there.Code snippet that reproduces the problem
https://phpstan.org/r/d3ff8430-a6ae-498a-b09e-fed774f9099d
Expected output
I expected both outputs to be
Dumped type: array('foo' => string)
I know this isn't the best code, and an isset would've been better here, but i noticed this in our code base.
The text was updated successfully, but these errors were encountered: