mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #4274 - don’t ignore mixed union in array_shift operation
This commit is contained in:
parent
6e3546d900
commit
78380c591b
@ -33,6 +33,7 @@ class ArrayPopReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTyp
|
||||
$first_arg_array = $first_arg
|
||||
&& ($first_arg_type = $statements_source->node_data->getType($first_arg))
|
||||
&& $first_arg_type->hasType('array')
|
||||
&& !$first_arg_type->hasMixed()
|
||||
&& ($array_atomic_type = $first_arg_type->getAtomicTypes()['array'])
|
||||
&& ($array_atomic_type instanceof Type\Atomic\TArray
|
||||
|| $array_atomic_type instanceof Type\Atomic\TKeyedArray
|
||||
|
@ -1847,6 +1847,17 @@ class ArrayFunctionCallTest extends TestCase
|
||||
$list = array_filter($list);
|
||||
if (!empty($list)) {}'
|
||||
],
|
||||
'arrayShiftOnMixedOrEmptyArray' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param mixed|array<empty, empty> $lengths
|
||||
*/
|
||||
function doStuff($lengths): void {
|
||||
/** @psalm-suppress MixedArgument, MixedAssignment */
|
||||
$length = array_shift($lengths);
|
||||
if ($length !== null) {}
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user