-
Notifications
You must be signed in to change notification settings - Fork 670
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
Psalm 5.7 started complaining about mb_strlen checks on array elements #9341
Comments
I found these snippets: https://psalm.dev/r/897a70d45b<?php
$GLOBALS['sql_query'] = rand(0,1) ? 'asd' : null;
if(!empty($GLOBALS['sql_query']) && mb_strlen($GLOBALS['sql_query']) > 2)
{
echo 'true';
}
|
It doesn't seem to happen on a plain variable though: https://psalm.dev/r/6178eba089
It's the other way around. Asserting non-emptyness doesn't mean the string can't be less than three chars (as in your example). |
I found these snippets: https://psalm.dev/r/6178eba089<?php
$query = rand(0,1) ? 'asd' : null;
if(!empty($query) && mb_strlen($query) > 2)
{
echo 'true';
}
|
cc: @LeoVie |
It also doesn't happen with nested ifs: https://psalm.dev/r/6ad10cdab0 |
I found these snippets: https://psalm.dev/r/6ad10cdab0<?php
$GLOBALS['sql_query'] = rand(0,1) ? 'asd' : null;
if (!empty($GLOBALS['sql_query'])) {
if (mb_strlen($GLOBALS['sql_query']) > 2) {
echo 'true';
}
}
|
It manifests as multiple different issues. Here's one example:
https://psalm.dev/r/897a70d45b
Asserting string length doesn't mean checking if the string is non-empty.
The text was updated successfully, but these errors were encountered: