mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8d5517f2c | ||
|
|
f518de4ae1 | ||
|
|
a89273d7ad | ||
|
|
d9004f98cc |
@@ -21,11 +21,13 @@ It's possible to generate a PhpStorm meta file, to [add support for factory desi
|
||||
php artisan ide-helper:meta
|
||||
|
||||
app('events')->fire();
|
||||
\App::make('events')->..
|
||||
\App::make('events')->fire();
|
||||
|
||||
/** @var \Illuminate\Foundation\Application $app */
|
||||
$app->make('events')->fire();
|
||||
|
||||
Pre-generated example: https://gist.github.com/barryvdh/bb6ffc5d11e0a75dba67
|
||||
|
||||
> Note: This is only available in the `@dev` stability, until a new release is tagged.
|
||||
> Note: You might need to restart PhpStorm and make sure `.phpstorm.meta.php` is indexed.
|
||||
> Note: When you receive a FatalException about a class that is not found, check your config (For example, remove S3 as cloud driver when you don't have S3 configured. Remove Redis ServiceProvider when you don't use it.)
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
*
|
||||
* @author Barry vd. Heuvel <[email protected]>
|
||||
* @see https://github.com/barryvdh/laravel-ide-helper
|
||||
* @noinspection PhpUnusedLocalVariableInspection
|
||||
* @noinspection PhpIllegalArrayKeyTypeInspection
|
||||
*/
|
||||
|
||||
/** @noinspection PhpIllegalArrayKeyTypeInspection */
|
||||
/** @noinspection PhpUnusedLocalVariableInspection */
|
||||
$STATIC_METHOD_TYPES = [
|
||||
<?php foreach($methods as $method): ?>
|
||||
<?= $method ?>('') => [
|
||||
|
||||
@@ -35,10 +35,10 @@ class MetaCommand extends Command {
|
||||
*/
|
||||
protected $description = 'Generate metadata for PhpStorm';
|
||||
|
||||
/** @var \Illuminate\Filesystem\Filesystem */
|
||||
/** @var \Illuminate\Contracts\Filesystem\Filesystem */
|
||||
protected $files;
|
||||
|
||||
/** @var \Illuminate\View\Factory */
|
||||
/** @var \Illuminate\Contracts\View\Factory */
|
||||
protected $view;
|
||||
|
||||
protected $methods = [
|
||||
@@ -52,8 +52,8 @@ class MetaCommand extends Command {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Illuminate\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\View\Factory $view
|
||||
* @param \Illuminate\Contracts\Filesystem\Filesystem $files
|
||||
* @param \Illuminate\Contracts\View\Factory $view
|
||||
*/
|
||||
public function __construct($files, $view) {
|
||||
$this->files = $files;
|
||||
@@ -68,11 +68,8 @@ class MetaCommand extends Command {
|
||||
*/
|
||||
public function fire()
|
||||
{
|
||||
$filename = $this->option('filename');
|
||||
|
||||
$bindings = array();
|
||||
|
||||
foreach ($this->laravel->getBindings() as $abstract => $options) {
|
||||
foreach ($this->getAbstracts() as $abstract) {
|
||||
try {
|
||||
$concrete = $this->laravel->make($abstract);
|
||||
if (is_object($concrete)) {
|
||||
@@ -88,6 +85,7 @@ class MetaCommand extends Command {
|
||||
'methods' => $this->methods,
|
||||
])->render();
|
||||
|
||||
$filename = $this->option('filename');
|
||||
$written = $this->files->put($filename, $content);
|
||||
|
||||
if ($written !== false) {
|
||||
@@ -97,6 +95,29 @@ class MetaCommand extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filtered list of abstracts from the Laravel Application.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getAbstracts()
|
||||
{
|
||||
$abstracts = $this->laravel->getBindings();
|
||||
|
||||
// Remove the S3 cloud driver when not available
|
||||
if (config('filesystems.cloud') === 's3' && !class_exists('League\Flysystem\AwsS3v2\AwsS3Adapter')) {
|
||||
unset($abstracts['filesystem.cloud']);
|
||||
}
|
||||
|
||||
// Remove Redis when not available
|
||||
if (isset($abstracts['redis']) && !class_exists('Predis\Client')) {
|
||||
unset($abstracts['redis']);
|
||||
}
|
||||
|
||||
// Return the abstract names only
|
||||
return array_keys($abstracts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the console command options.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user