From 45eaea1ed903475de740b25410ba022ec84e17ab Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Fri, 5 Jan 2018 11:50:27 -0500 Subject: [PATCH] Flesh out callmap type --- src/Psalm/Checker/Statements/Expression/CallChecker.php | 7 +++++++ tests/MethodCallTest.php | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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', ], ], ];