mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +01:00
Fix #5078 - when unpacking with missing array item, Use the param’s default type if param has one
This commit is contained in:
parent
2b39ab02a0
commit
822464cbaf
@ -459,7 +459,9 @@ class ArgumentAnalyzer
|
|||||||
) {
|
) {
|
||||||
$arg_type = clone $unpacked_atomic_array->properties[$unpacked_argument_offset];
|
$arg_type = clone $unpacked_atomic_array->properties[$unpacked_argument_offset];
|
||||||
} else {
|
} else {
|
||||||
$arg_type = Type::getMixed();
|
$arg_type = $function_param->is_optional
|
||||||
|
? ($function_param->default_type ?: Type::getMixed())
|
||||||
|
: Type::getMixed();
|
||||||
}
|
}
|
||||||
} elseif ($unpacked_atomic_array instanceof Type\Atomic\TList) {
|
} elseif ($unpacked_atomic_array instanceof Type\Atomic\TList) {
|
||||||
$arg_type = $unpacked_atomic_array->type_param;
|
$arg_type = $unpacked_atomic_array->type_param;
|
||||||
|
@ -268,6 +268,11 @@ class ArgTest extends TestCase
|
|||||||
[],
|
[],
|
||||||
'8.0'
|
'8.0'
|
||||||
],
|
],
|
||||||
|
'variadicArgsOptional' => [
|
||||||
|
'<?php
|
||||||
|
bar(...["aaaaa"]);
|
||||||
|
function bar(string $p1, int $p3 = 10) : void {}'
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user