mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-26 20:34:48 +01:00
chore: create util namespace
This commit is contained in:
parent
937fb50f33
commit
dea68b56ba
@ -7,6 +7,8 @@ use Illuminate\Support\Facades\RateLimiter;
|
||||
use PhpParser;
|
||||
use Psalm\Context;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\LaravelPlugin\Util\ApplicationProvider;
|
||||
use Psalm\LaravelPlugin\Util\ContainerResolver;
|
||||
use Psalm\Plugin\EventHandler\AfterClassLikeVisitInterface;
|
||||
use Psalm\Plugin\EventHandler\Event\AfterClassLikeVisitEvent;
|
||||
use Psalm\Type;
|
||||
@ -84,7 +86,7 @@ class AppInterfaceProvider implements
|
||||
if ($statements_source) {
|
||||
if ($method_name_lowercase === 'offsetget' || $method_name_lowercase === 'offsetset') {
|
||||
return $statements_source->getCodebase()->getMethodParams(
|
||||
ApplicationHelper::getAppFullyQualifiedClassName() . '::' . $method_name_lowercase
|
||||
ApplicationProvider::getAppFullyQualifiedClassName() . '::' . $method_name_lowercase
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -113,7 +115,7 @@ class AppInterfaceProvider implements
|
||||
|
||||
if ($method_name_lowercase === 'offsetset') {
|
||||
return $source->getCodebase()->getMethodReturnType(
|
||||
ApplicationHelper::getAppFullyQualifiedClassName() . '::' . $method_name_lowercase,
|
||||
ApplicationProvider::getAppFullyQualifiedClassName() . '::' . $method_name_lowercase,
|
||||
$fq_classlike_name
|
||||
);
|
||||
}
|
||||
@ -126,9 +128,9 @@ class AppInterfaceProvider implements
|
||||
// @see https://github.com/psalm/psalm-plugin-symfony/issues/25
|
||||
// psalm needs to know about any classes that could be returned before analysis begins. This is a naive first approach
|
||||
if (in_array($event->getStorage()->name, self::getClassLikeNames())) {
|
||||
$appClassName = ApplicationHelper::getAppFullyQualifiedClassName();
|
||||
$appClassName = ApplicationProvider::getAppFullyQualifiedClassName();
|
||||
|
||||
$facades = ApplicationHelper::getApp()->make('config')->get('app.aliases', []);
|
||||
$facades = ApplicationProvider::getApp()->make('config')->get('app.aliases', []);
|
||||
// I'm not sure why this isn't included by default, but this is a hack that fixes the bug
|
||||
$facades['rl'] = RateLimiter::class;
|
||||
|
||||
|
@ -9,6 +9,7 @@ use Psalm\LaravelPlugin\ReturnTypeProvider\ModelReturnTypeProvider;
|
||||
use Psalm\LaravelPlugin\ReturnTypeProvider\PathHelpersReturnTypeProvider;
|
||||
use Psalm\LaravelPlugin\ReturnTypeProvider\RelationReturnTypeProvider;
|
||||
use Psalm\LaravelPlugin\ReturnTypeProvider\UrlReturnTypeProvider;
|
||||
use Psalm\LaravelPlugin\Util\ApplicationProvider;
|
||||
use Psalm\Plugin\PluginEntryPointInterface;
|
||||
use Psalm\Plugin\RegistrationInterface;
|
||||
use SimpleXMLElement;
|
||||
@ -26,7 +27,7 @@ class Plugin implements PluginEntryPointInterface
|
||||
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null) : void
|
||||
{
|
||||
try {
|
||||
$app = ApplicationHelper::bootApp();
|
||||
$app = ApplicationProvider::bootApp();
|
||||
$fake_filesystem = new FakeFilesystem();
|
||||
$view_factory = $this->getViewFactory($app, $fake_filesystem);
|
||||
$cache_dir = __DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR;
|
||||
|
@ -5,8 +5,8 @@ namespace Psalm\LaravelPlugin\ReturnTypeProvider;
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\Internal\MethodIdentifier;
|
||||
use Psalm\LaravelPlugin\ApplicationHelper;
|
||||
use Psalm\LaravelPlugin\ContainerResolver;
|
||||
use Psalm\LaravelPlugin\Util\ApplicationProvider;
|
||||
use Psalm\LaravelPlugin\Util\ContainerResolver;
|
||||
use Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface;
|
||||
use Psalm\Plugin\Hook\MethodReturnTypeProviderInterface;
|
||||
use Psalm\StatementsSource;
|
||||
@ -35,7 +35,7 @@ final class AppReturnTypeProvider implements FunctionReturnTypeProviderInterface
|
||||
{
|
||||
if (!$call_args) {
|
||||
return new Union([
|
||||
new TNamedObject(get_class(ApplicationHelper::getApp())),
|
||||
new TNamedObject(get_class(ApplicationProvider::getApp())),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ final class AppReturnTypeProvider implements FunctionReturnTypeProviderInterface
|
||||
|
||||
public static function getClassLikeNames(): array
|
||||
{
|
||||
return [get_class(ApplicationHelper::getApp())];
|
||||
return [get_class(ApplicationProvider::getApp())];
|
||||
}
|
||||
|
||||
public static function getMethodReturnType(
|
||||
|
@ -4,7 +4,7 @@ namespace Psalm\LaravelPlugin\ReturnTypeProvider;
|
||||
|
||||
use Psalm\CodeLocation;
|
||||
use Psalm\Context;
|
||||
use Psalm\LaravelPlugin\ApplicationHelper;
|
||||
use Psalm\LaravelPlugin\Util\ApplicationProvider;
|
||||
use Psalm\Plugin\Hook\FunctionReturnTypeProviderInterface;
|
||||
use Psalm\Plugin\Hook\MethodReturnTypeProviderInterface;
|
||||
use Psalm\StatementsSource;
|
||||
@ -39,7 +39,7 @@ final class PathHelpersReturnTypeProvider implements FunctionReturnTypeProviderI
|
||||
public static function getClassLikeNames(): array
|
||||
{
|
||||
return [
|
||||
get_class(ApplicationHelper::getApp()),
|
||||
get_class(ApplicationProvider::getApp()),
|
||||
];
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ final class PathHelpersReturnTypeProvider implements FunctionReturnTypeProviderI
|
||||
* @psalm-suppress MissingClosureReturnType
|
||||
*/
|
||||
return self::resolveReturnType($call_args, function (array $args = []) use ($method_name_lowercase) {
|
||||
return ApplicationHelper::getApp()->{$method_name_lowercase}(...$args);
|
||||
return ApplicationProvider::getApp()->{$method_name_lowercase}(...$args);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Psalm\LaravelPlugin;
|
||||
namespace Psalm\LaravelPlugin\Util;
|
||||
|
||||
use Illuminate\Foundation\Application as LaravelApplication;
|
||||
use Orchestra\Testbench\Concerns\CreatesApplication;
|
||||
@ -8,7 +8,7 @@ use function file_exists;
|
||||
use function getcwd;
|
||||
use function get_class;
|
||||
|
||||
final class ApplicationHelper
|
||||
final class ApplicationProvider
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Psalm\LaravelPlugin;
|
||||
namespace Psalm\LaravelPlugin\Util;
|
||||
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Psalm\NodeTypeProvider;
|
||||
@ -36,7 +36,7 @@ final class ContainerResolver
|
||||
|
||||
// dynamic analysis to resolve the actual type from the container
|
||||
try {
|
||||
$concrete = ApplicationHelper::getApp()->make($abstract);
|
||||
$concrete = ApplicationProvider::getApp()->make($abstract);
|
||||
} catch (BindingResolutionException | ReflectionException $e) {
|
||||
return null;
|
||||
}
|
Loading…
Reference in New Issue
Block a user