-
Notifications
You must be signed in to change notification settings - Fork 672
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
TypeDoesNotContainType false positive #4274
Labels
Comments
I found these snippets: https://psalm.dev/r/fe40e86258<?php
/**
* @param mixed[] $options
*/
function doStuff(bool $flag, array $values, array $options): void
{
$lengths = $flag ? $options['lengths'] : [];
foreach ($values as $_) {
$length = array_shift($lengths);
if ($length !== null) {
echo 1;
}
}
}
|
Simplified: https://psalm.dev/r/03258c2b11 |
I found these snippets: https://psalm.dev/r/03258c2b11<?php
/**
* @param mixed $options
* @psalm-suppress MixedAssignment,MixedArgument
*/
function doStuff($options): void
{
$options = rand(0,1) ? $options : [];
$opt = array_shift($options);
if (null === $opt) {}
}
|
muglug
added a commit
that referenced
this issue
Oct 12, 2020
danog
pushed a commit
to danog/psalm
that referenced
this issue
Jan 29, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please see the code example in https://psalm.dev/r/fe40e86258.
Depending on the values of
$flag
and$options
, a call toarray_shift()
may return a non-null value but this code is reported as:The text was updated successfully, but these errors were encountered: