Skip to content

Commit 61fd354

Browse files
committed
Add phpstorm meta hints
1 parent 2a41415 commit 61fd354

File tree

2 files changed

+38
-15
lines changed

2 files changed

+38
-15
lines changed

resources/views/meta.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,12 @@
6565
override(\tap(0), type(0));
6666
override(\optional(0), type(0));
6767

68+
<?php if (isset($expectedArguments)) : ?>
69+
<?php foreach ($expectedArguments as $function => $arguments) : ?>
70+
<?php foreach ($arguments as $index => $argumentList) : ?>
71+
expectedArguments(\<?= $function ?>(), <?= $index ?>,<?php foreach ($argumentList as $i => $arg) : ?><?php if($i % 10 == 0) { echo "\n"; } ?><?= var_export($arg, true); ?>,<?php endforeach; ?>
72+
);
73+
<?php endforeach; ?>
74+
<?php endforeach; ?>
75+
<?php endif; ?>
6876
}

src/Console/MetaCommand.php

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,17 @@ class MetaCommand extends Command
5151
protected $config;
5252

5353
protected $methods = [
54-
'new \Illuminate\Contracts\Container\Container',
55-
'\Illuminate\Container\Container::makeWith(0)',
56-
'\Illuminate\Contracts\Container\Container::get(0)',
57-
'\Illuminate\Contracts\Container\Container::make(0)',
58-
'\Illuminate\Contracts\Container\Container::makeWith(0)',
59-
'\App::get(0)',
60-
'\App::make(0)',
61-
'\App::makeWith(0)',
62-
'\app(0)',
63-
'\resolve(0)',
64-
'\Psr\Container\ContainerInterface::get(0)',
54+
'new \Illuminate\Contracts\Container\Container',
55+
'\Illuminate\Container\Container::makeWith(0)',
56+
'\Illuminate\Contracts\Container\Container::get(0)',
57+
'\Illuminate\Contracts\Container\Container::make(0)',
58+
'\Illuminate\Contracts\Container\Container::makeWith(0)',
59+
'\App::get(0)',
60+
'\App::make(0)',
61+
'\App::makeWith(0)',
62+
'\app(0)',
63+
'\resolve(0)',
64+
'\Psr\Container\ContainerInterface::get(0)',
6565
];
6666

6767
/**
@@ -108,7 +108,7 @@ public function handle()
108108
}
109109

110110
$reflectionClass = new \ReflectionClass($concrete);
111-
if (is_object($concrete) && !$reflectionClass->isAnonymous()) {
111+
if (is_object($concrete) && !$reflectionClass->isAnonymous() && $abstract !== get_class($concrete)) {
112112
$bindings[$abstract] = get_class($concrete);
113113
}
114114
} catch (\Throwable $e) {
@@ -121,9 +121,10 @@ public function handle()
121121
$this->unregisterClassAutoloadExceptions($ourAutoloader);
122122

123123
$content = $this->view->make('meta', [
124-
'bindings' => $bindings,
125-
'methods' => $this->methods,
126-
'factories' => $factories,
124+
'bindings' => $bindings,
125+
'methods' => $this->methods,
126+
'factories' => $factories,
127+
'expectedArguments' => $this->getExpectedArguments()
127128
])->render();
128129

129130
$filename = $this->option('filename');
@@ -167,6 +168,20 @@ protected function registerClassAutoloadExceptions(): callable
167168
return $autoloader;
168169
}
169170

171+
protected function getExpectedArguments()
172+
{
173+
return [
174+
'config' => [
175+
0 => $this->getConfigHints()
176+
]
177+
];
178+
}
179+
180+
protected function getConfigHints()
181+
{
182+
return collect($this->config->all())->dot()->keys()->toArray();
183+
}
184+
170185
/**
171186
* Get the console command options.
172187
*

0 commit comments

Comments
 (0)