diff --git a/src/Psalm/Checker/Statements/Expression/CallChecker.php b/src/Psalm/Checker/Statements/Expression/CallChecker.php index 802a14eba..2ae930307 100644 --- a/src/Psalm/Checker/Statements/Expression/CallChecker.php +++ b/src/Psalm/Checker/Statements/Expression/CallChecker.php @@ -986,6 +986,13 @@ class CallChecker $return_type_candidate = Type::getString(); } elseif (FunctionChecker::inCallMap($cased_method_id)) { $return_type_candidate = FunctionChecker::getReturnTypeFromCallMap($method_id); + + $return_type_candidate = ExpressionChecker::fleshOutType( + $project_checker, + $return_type_candidate, + $fq_class_name, + $method_id + ); } else { if (MethodChecker::checkMethodVisibility( $method_id, diff --git a/tests/MethodCallTest.php b/tests/MethodCallTest.php index 6bf0a3c97..8b23227fb 100644 --- a/tests/MethodCallTest.php +++ b/tests/MethodCallTest.php @@ -74,9 +74,12 @@ class MethodCallTest extends TestCase final class MyDate extends DateTimeImmutable {} $today = new MyDate(); - $yesterday = $today->sub(new DateInterval("P1D"));', + $yesterday = $today->sub(new DateInterval("P1D")); + + $b = (new DateTimeImmutable())->modify("+3 hours");', 'assertions' => [ '$yesterday' => 'MyDate', + '$b' => 'DateTimeImmutable', ], ], ];