Skip to content
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

False positive RedundantConditionGivenDocblockType when combining mixed and null-coalescing operator #8399

Open
blackwolf12333 opened this issue Aug 11, 2022 · 1 comment

Comments

@blackwolf12333
Copy link

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.

@psalm-github-bot
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants