mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2025-01-22 13:21:19 +01:00
fix: get the actual class of the app depending on if its lumen vs. laravel
This commit is contained in:
parent
1010f65905
commit
6a48722ab7
@ -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())),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
"""
|
||||
<?php
|
||||
function testMake(): \Illuminate\Routing\Redirector {
|
||||
return app()->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
|
||||
|
Loading…
x
Reference in New Issue
Block a user