We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The empty function is not treated as a !isset inside a foreach loop
empty
!isset
foreach
This works: https://phpstan.org/r/c102939c-132d-44c9-a159-f93b35d83ac1 This doesn't works: https://phpstan.org/r/26cf5f07-d39c-4d81-bbd8-80850dc57411
I expect no errors to be reported by PHPStan because empty also does an isset check
isset
The text was updated successfully, but these errors were encountered:
It doesn't even matter if there is a foreach loop or not. empty checked on array offset don't seem to work like isset at all: https://phpstan.org/r/7fb590e6-2122-4f99-9ac3-66de38d7c0b1
Sorry, something went wrong.
@ste93cry After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@ -21: Offset 'host' does not exist on array(?'scheme' => string, ?'host' => string, ?'port' => int, ?'user' => string, ?'pass' => string, ?'path' => string, ?'query' => string, ?'fragment' => string). +No errors
@mtorromeo After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@ -6: Offset 'test' does not exist on array(?'test' => string). +No errors
phpstan/phpstan-src@3c3ea2f
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.
No branches or pull requests
Bug report
The
empty
function is not treated as a!isset
inside aforeach
loopCode snippet that reproduces the problem
This works: https://phpstan.org/r/c102939c-132d-44c9-a159-f93b35d83ac1
This doesn't works: https://phpstan.org/r/26cf5f07-d39c-4d81-bbd8-80850dc57411
Expected output
I expect no errors to be reported by PHPStan because
empty
also does anisset
checkThe text was updated successfully, but these errors were encountered: