mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Merge pull request #6612 from orklah/empty-array_is_list
array_is_list on empty array returns true
This commit is contained in:
commit
d40335ff37
@ -1897,6 +1897,13 @@ class SimpleAssertionReconciler extends \Psalm\Type\Reconciler
|
||||
}
|
||||
}
|
||||
|
||||
if ($type->type_params[0]->isEmpty()
|
||||
|| $type->type_params[1]->isEmpty()
|
||||
) {
|
||||
//we allow an empty array to pass as a list. We keep the type as empty array though (more precise)
|
||||
$array_types[] = $type;
|
||||
}
|
||||
|
||||
$did_remove_type = true;
|
||||
} elseif ($type instanceof TCallable) {
|
||||
$array_types[] = new TCallableKeyedArray([
|
||||
|
@ -1632,6 +1632,18 @@ class FunctionCallTest extends TestCase
|
||||
[],
|
||||
'8.1',
|
||||
],
|
||||
'array_is_list_on_empty_array' => [
|
||||
'<?php
|
||||
$a = [];
|
||||
if(array_is_list($a)) {
|
||||
//$a is still empty array
|
||||
}
|
||||
',
|
||||
[],
|
||||
[],
|
||||
'8.1',
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user