diff --git a/src/ReturnTypeProvider/AppReturnTypeProvider.php b/src/ReturnTypeProvider/AppReturnTypeProvider.php index 57d1b40..ed373ea 100644 --- a/src/ReturnTypeProvider/AppReturnTypeProvider.php +++ b/src/ReturnTypeProvider/AppReturnTypeProvider.php @@ -4,11 +4,13 @@ namespace Psalm\LaravelPlugin\ReturnTypeProvider; use Psalm\CodeLocation; use Psalm\Context; +use Psalm\LaravelPlugin\ApplicationHelper; use Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface; use Psalm\StatementsSource; use Psalm\Type; use Psalm\Type\Atomic\TNamedObject; use Psalm\Type\Union; +use function get_class; final class AppReturnTypeProvider implements FunctionReturnTypeProviderInterface { @@ -28,7 +30,7 @@ final class AppReturnTypeProvider implements FunctionReturnTypeProviderInterface { if (!$call_args) { return new Union([ - new TNamedObject(\Illuminate\Contracts\Foundation\Application::class), + new TNamedObject(get_class(ApplicationHelper::getApp())), ]); } diff --git a/tests/acceptance/Container.feature b/tests/acceptance/Container.feature index e0104b6..e77e619 100644 --- a/tests/acceptance/Container.feature +++ b/tests/acceptance/Container.feature @@ -63,3 +63,18 @@ Feature: Container """ When I run Psalm Then I see no errors + + Scenario: app helper can be chained with make / makeWith + Given I have the following code + """ + make(\Illuminate\Routing\Redirector::class); + } + + function testMakeWith(): \Illuminate\Routing\Redirector { + return app()->makeWith(\Illuminate\Routing\Redirector::class); + } + """ + When I run Psalm + Then I see no errors