-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Description
Bug report
After upgrading from 2.1.27 to 2.1.28, PHPStan started to report strange false positives on my projects. Apparently, when comparing the result of a trim($value) operation, the $value variable is narrowed to a string.
function doSomething(mixed $value): void
{
if (trim($value) === '') {
return;
}
\PHPStan\dumpType($value);
}Here, PHPStan believes that $value must be a non-empty-string which I believe is wrong. $value could be anything that can be cast to a string, such as an integer or a Stringable object.
Code snippet that reproduces the problem
https://phpstan.org/r/8cbb0de1-d0c3-4c13-bcf5-7cbd1b1fd69a
Expected output
$value should still be mixed.
Did PHPStan help you today? Did it make you happy in any way?
No response
garvinhicking
Metadata
Metadata
Assignees
Labels
No labels