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
Invalid empty() function handling #10991
Comments
|
Thanks |
Sorry, but that's simply not true. It will return any string you use in ini file or call to ini_set. php > ini_set('max_execution_time', 'G');
php > var_dump(ini_get('max_execution_time'));
string(1) "G"
php > var_dump(ini_get('removed_option'));
bool(false) The signature of a function is ini_get(string $option): string|false and it should be honored. |
Thanks - for some reason I thought that @ondrejmirtes @staabm the |
I think the extension already behaves like that. Some keys will never return false and the extension knows that. |
That's not the point I was making - it should not return |
hmm I wonder whether we should trust the developer to use proper php.ini settings. I think we should additionally validate the setter call. |
we narrow to all other keys use |
Bug report
ini_get returns string|false
empty checks for '0', '' and false.
empty($timeLimit) && $timeLimit !== '0' is the same as $timeLimit === '' || $timeLimit === false
Got irrelevant errors:
Result of && is always false.
Because the type is coming from a PHPDoc, you can turn off this check by setting treatPhpDocTypesAsCertain: false in your configuration file.
booleanAnd.alwaysFalse
Strict comparison using !== between '0' and '0' will always evaluate to false.
notIdentical.alwaysFalse
Code snippet that reproduces the problem
https://phpstan.org/r/b8833c6e-bfe6-4cdd-98e5-6db9d8fba38e
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
Hundreds of false positives
The text was updated successfully, but these errors were encountered: