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
When iterating on 2 (or more) dimensional array the error: Comparison operation ">" between int<1, max> and 0 is always true. is incorrectly returned.
Comparison operation ">" between int<1, max> and 0 is always true.
<?php declare(strict_types = 1); $map = [ 1 => 'foo', 2 => 'foo', 3 => 'bar', ]; $names = ['foo', 'bar', 'baz']; $array = ['foo' => [], 'bar' => [], 'baz' => []]; foreach ($map as $value => $name) { $array[$name][] = $value; } foreach ($array as $name => $elements) { echo sprintf('"%s" -> "%d".' . PHP_EOL, $name, count($elements) > 0); }
(https://phpstan.org/r/8787a548-d915-4658-832f-dc3e7575884e)
No error, as it is false positive: https://3v4l.org/6eAMe
Real life case can be found here: https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5805/files#diff-a809d26a7ee19fceeb074078036812dc5c022e0a52d7ef0cc27d13cd161b33dfR569 - when you remove the condition that is claimed to be always true some tests start to fail
The text was updated successfully, but these errors were encountered:
@kubawerlos After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@ -17: Comparison operation ">" between int<1, max> and 0 is always true. +No errors
Sorry, something went wrong.
phpstan/phpstan-src@ebfe7cf
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
When iterating on 2 (or more) dimensional array the error:
Comparison operation ">" between int<1, max> and 0 is always true.
is incorrectly returned.Code snippet that reproduces the problem
(https://phpstan.org/r/8787a548-d915-4658-832f-dc3e7575884e)
Expected output
No error, as it is false positive: https://3v4l.org/6eAMe
Real life case can be found here: https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5805/files#diff-a809d26a7ee19fceeb074078036812dc5c022e0a52d7ef0cc27d13cd161b33dfR569 - when you remove the condition that is claimed to be always true some tests start to fail
The text was updated successfully, but these errors were encountered: