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
while
The following snippet analysis should not trigger any error: https://phpstan.org/r/7ce1ea05-26eb-4ffc-aa6d-80a368bb0044
<?php declare(strict_types = 1); function produceIntOrNull(): ?int { return rand(0, 2) === 0 ? null : 0; } function expectInt(int $a): void {} $int = null; while (!is_int($int)) { $int = produceIntOrNull(); } expectInt($int);
The while (!is_int($int)) { } ensures that $int is an int after the loop.
while (!is_int($int)) { }
$int
We can note that if constructs handle this well: https://phpstan.org/r/7fda8056-a088-44ba-9ee0-08623ce532be
if
There could be some tricky corner cases, notably with break
break
The text was updated successfully, but these errors were encountered:
Hi, this is a no-brainer, thank you for the suggestion :) Implemented: phpstan/phpstan-src@3166ba3
Sorry, something went wrong.
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
The following snippet analysis should not trigger any error:
https://phpstan.org/r/7ce1ea05-26eb-4ffc-aa6d-80a368bb0044
The
while (!is_int($int)) { }
ensures that$int
is an int after the loop.We can note that
if
constructs handle this well: https://phpstan.org/r/7fda8056-a088-44ba-9ee0-08623ce532beThere could be some tricky corner cases, notably with
break
The text was updated successfully, but these errors were encountered: