Compare commits

..
4 Commits
Author SHA1 Message Date
Barry vd. Heuvel d8d5517f2c Tweak @noinspection 2015-03-17 09:00:28 +01:00
Barry vd. Heuvel f518de4ae1 Filter abstracts for common errors
Fixes #184
2015-03-17 08:57:14 +01:00
Barry vd. Heuvel a89273d7ad Add non-static 2015-03-16 14:56:44 +01:00
Barry vd. Heuvel d9004f98cc Update readme 2015-03-16 14:55:13 +01:00
3 changed files with 36 additions and 12 deletions
+4 -2
View File
@@ -21,11 +21,13 @@ It's possible to generate a PhpStorm meta file, to [add support for factory desi
php artisan ide-helper:meta php artisan ide-helper:meta
app('events')->fire(); 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 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: 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.) > 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.)
+3 -2
View File
@@ -6,9 +6,10 @@
* *
* @author Barry vd. Heuvel <[email protected]> * @author Barry vd. Heuvel <[email protected]>
* @see https://github.com/barryvdh/laravel-ide-helper * @see https://github.com/barryvdh/laravel-ide-helper
* @noinspection PhpUnusedLocalVariableInspection
* @noinspection PhpIllegalArrayKeyTypeInspection
*/ */
/** @noinspection PhpIllegalArrayKeyTypeInspection */
/** @noinspection PhpUnusedLocalVariableInspection */
$STATIC_METHOD_TYPES = [ $STATIC_METHOD_TYPES = [
<?php foreach($methods as $method): ?> <?php foreach($methods as $method): ?>
<?= $method ?>('') => [ <?= $method ?>('') => [
+29 -8
View File
@@ -35,10 +35,10 @@ class MetaCommand extends Command {
*/ */
protected $description = 'Generate metadata for PhpStorm'; protected $description = 'Generate metadata for PhpStorm';
/** @var \Illuminate\Filesystem\Filesystem */ /** @var \Illuminate\Contracts\Filesystem\Filesystem */
protected $files; protected $files;
/** @var \Illuminate\View\Factory */ /** @var \Illuminate\Contracts\View\Factory */
protected $view; protected $view;
protected $methods = [ protected $methods = [
@@ -52,8 +52,8 @@ class MetaCommand extends Command {
/** /**
* *
* @param \Illuminate\Filesystem\Filesystem $files * @param \Illuminate\Contracts\Filesystem\Filesystem $files
* @param \Illuminate\View\Factory $view * @param \Illuminate\Contracts\View\Factory $view
*/ */
public function __construct($files, $view) { public function __construct($files, $view) {
$this->files = $files; $this->files = $files;
@@ -68,11 +68,8 @@ class MetaCommand extends Command {
*/ */
public function fire() public function fire()
{ {
$filename = $this->option('filename');
$bindings = array(); $bindings = array();
foreach ($this->getAbstracts() as $abstract) {
foreach ($this->laravel->getBindings() as $abstract => $options) {
try { try {
$concrete = $this->laravel->make($abstract); $concrete = $this->laravel->make($abstract);
if (is_object($concrete)) { if (is_object($concrete)) {
@@ -88,6 +85,7 @@ class MetaCommand extends Command {
'methods' => $this->methods, 'methods' => $this->methods,
])->render(); ])->render();
$filename = $this->option('filename');
$written = $this->files->put($filename, $content); $written = $this->files->put($filename, $content);
if ($written !== false) { 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. * Get the console command options.
* *