From 61fd354706f2233a3e695c532eef54c5db326ee9 Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Sun, 29 Dec 2024 14:19:05 +0100 Subject: [PATCH] Add phpstorm meta hints --- resources/views/meta.php | 8 +++++++ src/Console/MetaCommand.php | 45 ++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/resources/views/meta.php b/resources/views/meta.php index 5b7b9c2..68d37d5 100644 --- a/resources/views/meta.php +++ b/resources/views/meta.php @@ -65,4 +65,12 @@ namespace PHPSTORM_META { override(\tap(0), type(0)); override(\optional(0), type(0)); + + $arguments) : ?> + $argumentList) : ?> +expectedArguments(\(), , $arg) : ?>, +); + + + } diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index 72f20f1..c467d65 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -51,17 +51,17 @@ class MetaCommand extends Command protected $config; protected $methods = [ - 'new \Illuminate\Contracts\Container\Container', - '\Illuminate\Container\Container::makeWith(0)', - '\Illuminate\Contracts\Container\Container::get(0)', - '\Illuminate\Contracts\Container\Container::make(0)', - '\Illuminate\Contracts\Container\Container::makeWith(0)', - '\App::get(0)', - '\App::make(0)', - '\App::makeWith(0)', - '\app(0)', - '\resolve(0)', - '\Psr\Container\ContainerInterface::get(0)', + 'new \Illuminate\Contracts\Container\Container', + '\Illuminate\Container\Container::makeWith(0)', + '\Illuminate\Contracts\Container\Container::get(0)', + '\Illuminate\Contracts\Container\Container::make(0)', + '\Illuminate\Contracts\Container\Container::makeWith(0)', + '\App::get(0)', + '\App::make(0)', + '\App::makeWith(0)', + '\app(0)', + '\resolve(0)', + '\Psr\Container\ContainerInterface::get(0)', ]; /** @@ -108,7 +108,7 @@ class MetaCommand extends Command } $reflectionClass = new \ReflectionClass($concrete); - if (is_object($concrete) && !$reflectionClass->isAnonymous()) { + if (is_object($concrete) && !$reflectionClass->isAnonymous() && $abstract !== get_class($concrete)) { $bindings[$abstract] = get_class($concrete); } } catch (\Throwable $e) { @@ -121,9 +121,10 @@ class MetaCommand extends Command $this->unregisterClassAutoloadExceptions($ourAutoloader); $content = $this->view->make('meta', [ - 'bindings' => $bindings, - 'methods' => $this->methods, - 'factories' => $factories, + 'bindings' => $bindings, + 'methods' => $this->methods, + 'factories' => $factories, + 'expectedArguments' => $this->getExpectedArguments() ])->render(); $filename = $this->option('filename'); @@ -167,6 +168,20 @@ class MetaCommand extends Command return $autoloader; } + protected function getExpectedArguments() + { + return [ + 'config' => [ + 0 => $this->getConfigHints() + ] + ]; + } + + protected function getConfigHints() + { + return collect($this->config->all())->dot()->keys()->toArray(); + } + /** * Get the console command options. *