mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2025-01-22 13:21:19 +01:00
commit
8552baf29f
@ -48,6 +48,8 @@ class Plugin implements PluginEntryPointInterface
|
||||
$registration->registerHooksFromClass(ReturnTypeProvider\RedirectReturnTypeProvider::class);
|
||||
require_once 'ReturnTypeProvider/ViewReturnTypeProvider.php';
|
||||
$registration->registerHooksFromClass(ReturnTypeProvider\ViewReturnTypeProvider::class);
|
||||
require_once 'ReturnTypeProvider/AppReturnTypeProvider.php';
|
||||
$registration->registerHooksFromClass(ReturnTypeProvider\AppReturnTypeProvider::class);
|
||||
require_once 'AppInterfaceProvider.php';
|
||||
$registration->registerHooksFromClass(AppInterfaceProvider::class);
|
||||
require_once 'PropertyProvider/ModelPropertyProvider.php';
|
||||
|
@ -6,6 +6,7 @@ use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface;
|
||||
use Psalm\StatementsSource;
|
||||
use Psalm\Type;
|
||||
use Psalm\Type\Atomic\TNamedObject;
|
||||
use Psalm\Type\Union;
|
||||
|
||||
@ -32,8 +33,15 @@ final class AppReturnTypeProvider implements FunctionReturnTypeProviderInterface
|
||||
}
|
||||
|
||||
// @todo: this should really proxy to \Illuminate\Foundation\Application::make, but i was struggling with that
|
||||
return new Union([
|
||||
new TNamedObject($call_args[0]->value),
|
||||
]);
|
||||
|
||||
$firstArgType = $statements_source->getNodeTypeProvider()->getType($call_args[0]->value);
|
||||
|
||||
if ($firstArgType && $firstArgType->isSingleStringLiteral()) {
|
||||
return new Union([
|
||||
new TNamedObject($firstArgType->getSingleStringLiteral()->value),
|
||||
]);
|
||||
}
|
||||
|
||||
return Type::getMixed();
|
||||
}
|
||||
}
|
||||
|
@ -54,9 +54,6 @@ Feature: Container
|
||||
"""
|
||||
<?php
|
||||
class Foo {
|
||||
public function resolveHelperGetContainer(): \Illuminate\Contracts\Foundation\Application {
|
||||
return resolve();
|
||||
}
|
||||
|
||||
public function resolveHelperResolvesTypes(): \Illuminate\Routing\Redirector
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user