Add phpstorm meta hints

This commit is contained in:
Barry vd. Heuvel
2024-12-29 14:19:05 +01:00
parent 2a41415f01
commit 61fd354706
2 changed files with 38 additions and 15 deletions
+8
View File
@@ -65,4 +65,12 @@ namespace PHPSTORM_META {
override(\tap(0), type(0));
override(\optional(0), type(0));
<?php if (isset($expectedArguments)) : ?>
<?php foreach ($expectedArguments as $function => $arguments) : ?>
<?php foreach ($arguments as $index => $argumentList) : ?>
expectedArguments(\<?= $function ?>(), <?= $index ?>,<?php foreach ($argumentList as $i => $arg) : ?><?php if($i % 10 == 0) { echo "\n"; } ?><?= var_export($arg, true); ?>,<?php endforeach; ?>
);
<?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>
}
+16 -1
View File
@@ -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) {
@@ -124,6 +124,7 @@ class MetaCommand extends Command
'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.
*