psalm
psalm copied to clipboard
False positive RedundantConditionGivenDocblockType when combining mixed and null-coalescing operator
https://psalm.dev/r/1d89182ec6
I think this should not infer that the string length is always 0. With mixed
as type I don't think you can know that it always reduces to 0.
I found these snippets:
https://psalm.dev/r/1d89182ec6
<?php
/** @var array<array-key, mixed> $array */
$array = [];
$iLen = strlen($array['offset'] ?? '');
if ($iLen === 0) {
}
Psalm output (using commit ffc8c80):
INFO: MixedArgument - 6:16 - Argument 1 of strlen cannot be ''|mixed, expecting string
ERROR: RedundantConditionGivenDocblockType - 8:5 - Docblock-defined type 0 for $iLen is always =int(0)