You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$a = 'ab';
if (substr($a, 0, PHP_INT_MAX) === 'x') {
exit(1);
}
if (strlen($a) === 2) {
echo('According to phpstan, this should not print because if will always evaluate to false');
}
Expected output of the snippet
https://3v4l.org/aqFoE According to phpstan, this should not print because if will always evaluate to false
Expected output
No warning should be shown or if a warning should be shown, it should be that it will always be true since the original string is not modified and is known to be of length 2. (Well, in this specific case, not if $a would be a dynamic string returned from a function.)
Did PHPStan help you today? Did it make you happy in any way?
Not today, but the previous weeks totally. In combination with the deprecation-rules, this tool has helped me a lot to prepare our codebase to upgrade some critical libraries before upgrading to the next major release.
It's the first issue we encounter and I just wanted to report it so you can strive to make this already excellent tool even more sublime.
The text was updated successfully, but these errors were encountered:
Bug report
A false positive is reported.
Code snippet that reproduces the problem
https://phpstan.org/r/5ae35ca9-5e05-40f8-a47f-892e50895e06
Line 9 is the second if-statement.
Expected output of the snippet
https://3v4l.org/aqFoE
According to phpstan, this should not print because if will always evaluate to false
Expected output
No warning should be shown or if a warning should be shown, it should be that it will always be true since the original string is not modified and is known to be of length 2. (Well, in this specific case, not if
$a
would be a dynamic string returned from a function.)Did PHPStan help you today? Did it make you happy in any way?
Not today, but the previous weeks totally. In combination with the deprecation-rules, this tool has helped me a lot to prepare our codebase to upgrade some critical libraries before upgrading to the next major release.
It's the first issue we encounter and I just wanted to report it so you can strive to make this already excellent tool even more sublime.
The text was updated successfully, but these errors were encountered: