diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php index b47953b10..9eca88ea3 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/ArgumentAnalyzer.php @@ -459,7 +459,9 @@ class ArgumentAnalyzer ) { $arg_type = clone $unpacked_atomic_array->properties[$unpacked_argument_offset]; } 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) { $arg_type = $unpacked_atomic_array->type_param; diff --git a/tests/ArgTest.php b/tests/ArgTest.php index 3d565def7..3682133bc 100644 --- a/tests/ArgTest.php +++ b/tests/ArgTest.php @@ -268,6 +268,11 @@ class ArgTest extends TestCase [], '8.0' ], + 'variadicArgsOptional' => [ + '