diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php index a9d27ba8774..4632eaecefa 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReduceReturnTypeProvider.php @@ -100,7 +100,7 @@ public static function getFunctionReturnType(FunctionReturnTypeProviderEvent $ev $initial_type = $reduce_return_type; - if ($closure_types = $function_call_arg_type->getClosureTypes()) { + if ($closure_types = $function_call_arg_type->getClosureTypes() ?: $function_call_arg_type->getCallableTypes()) { $closure_atomic_type = reset($closure_types); $closure_return_type = $closure_atomic_type->return_type ?: Type::getMixed(); diff --git a/tests/ClosureTest.php b/tests/ClosureTest.php index 53e5cc3f9b2..cbd3b3360c4 100644 --- a/tests/ClosureTest.php +++ b/tests/ClosureTest.php @@ -565,6 +565,22 @@ function maker(string $className) { '$result' => 'array{stdClass}' ], ], + 'CallableWithArrayReduce' => [ + ' [ + '$result' => 'int' + ], + ], 'FirstClassCallable:NamedFunction:is_int' => [ '