diff --git a/src/Console/MetaCommand.php b/src/Console/MetaCommand.php index 23e29bb..f236f82 100644 --- a/src/Console/MetaCommand.php +++ b/src/Console/MetaCommand.php @@ -17,21 +17,18 @@ use Symfony\Component\Console\Input\InputOption; * A command to generate phpstorm meta data * * @author Barry vd. Heuvel + * @property \Illuminate\Container\Container $laravel */ class MetaCommand extends Command { /** - * The console command name. - * - * @var string + * {@inheritdoc} */ protected $name = 'ide-helper:meta'; protected $filename = '.phpstorm.meta.php'; /** - * The console command description. - * - * @var string + * {@inheritdoc} */ protected $description = 'Generate metadata for PhpStorm'; @@ -40,22 +37,26 @@ class MetaCommand extends Command { /** @var \Illuminate\View\Factory */ protected $view; - + protected $methods = array( - '\Illuminate\Foundation\Application::make', - '\Illuminate\Container\Container::make', - '\App::make', - 'app', + '\Illuminate\Foundation\Application::make', + 'new \Illuminate\Foundation\Application', + '\Illuminate\Container\Container::make', + 'new \Illuminate\Container\Container', + '\App::make', + 'app', ); /** + * {@inheritdoc} * - * @param \Illuminate\Filesystem\Filesystem $files - * @param \Illuminate\View\Factory $view + * @param \Illuminate\Container\Container $app */ - public function __construct($files, $view) { - $this->files = $files; - $this->view = $view; + public function __construct($app) + { + $this->laravel = $app; + $this->files = $app['files']; + $this->view = $app['view']; parent::__construct(); } @@ -73,16 +74,16 @@ class MetaCommand extends Command { if (is_object($concrete)) { $bindings[$abstract] = get_class($concrete); } - }catch (\Exception $e) { - $this->error("Cannot make $abstract: ".$e->getMessage()); + } catch (\Exception $e) { + $this->error("Cannot make $abstract: " . $e->getMessage()); } } - + $content = $this->view->make('laravel-ide-helper::meta', array( - 'bindings' => $bindings, - 'methods' => $this->methods, + 'bindings' => $bindings, + 'methods' => $this->methods, ))->render(); - + $filename = $this->option('filename'); $written = $this->files->put($filename, $content); @@ -92,10 +93,10 @@ class MetaCommand extends Command { $this->error("The meta file could not be created at $filename"); } } - + /** * Get a list of abstracts from the Laravel Application. - * + * * @return array */ protected function getAbstracts() @@ -104,9 +105,7 @@ class MetaCommand extends Command { } /** - * Get the console command options. - * - * @return array + * {@inheritdoc} */ protected function getOptions() { diff --git a/src/IdeHelperServiceProvider.php b/src/IdeHelperServiceProvider.php index ceace1e..7d70d5d 100644 --- a/src/IdeHelperServiceProvider.php +++ b/src/IdeHelperServiceProvider.php @@ -15,20 +15,19 @@ use Barryvdh\LaravelIdeHelper\Console\MetaCommand; use Barryvdh\LaravelIdeHelper\Console\ModelsCommand; use Barryvdh\LaravelIdeHelper\Console\GeneratorCommand; +/** + * @property \Illuminate\Container\Container $app + */ class IdeHelperServiceProvider extends ServiceProvider { /** - * Indicates if loading of the provider is deferred. - * - * @var bool + * {@inheritdoc} */ protected $defer = true; /** - * Bootstrap the application events. - * - * @return void + * {@inheritdoc} */ public function boot() { @@ -36,9 +35,7 @@ class IdeHelperServiceProvider extends ServiceProvider } /** - * Register the service provider. - * - * @return void + * {@inheritdoc} */ public function register() { @@ -49,60 +46,34 @@ class IdeHelperServiceProvider extends ServiceProvider ); $this->app['command.ide-helper.models'] = $this->app->share( - function () { - return new ModelsCommand(); + function ($app) { + return new ModelsCommand($app); } ); - + $this->app['command.ide-helper.meta'] = $this->app->share( - function ($app) { - return new MetaCommand($app['files'], $app['view']); - } + function ($app) { + return new MetaCommand($app); + } ); $this->commands('command.ide-helper.generate', 'command.ide-helper.models', 'command.ide-helper.meta'); } /** - * Get the services provided by the provider. - * - * @return array + * {@inheritdoc} */ public function provides() { - return array('command.ide-helper.generate', 'command.ide-helper.models'); + return array('command.ide-helper.generate', 'command.ide-helper.models', 'command.ide-helper.meta'); } - + /** - * Register the package's component namespaces. - * - * @param string $package - * @param string $namespace - * @param string $path - * @return void + * {@inheritdoc} */ - public function package($package, $namespace = null, $path = null) + protected function getAppViewPath($package, $namespace = null) { - - // Is it possible to register the config? - if (method_exists($this->app['config'], 'package')) { - $this->app['config']->package($package, $path.'/config', $namespace); - } else { - // Load the config for now.. - $config = $this->app['files']->getRequire($path .'/config/config.php'); - foreach($config as $key => $value){ - $this->app['config']->set($namespace.'::'.$key, $value); - } - } - - // Register view files - $appView = $this->app['path']."/views/packages/{$package}"; - if ($this->app['files']->isDirectory($appView)) - { - $this->app['view']->addNamespace($namespace, $appView); - } - - $this->app['view']->addNamespace($namespace, $path.'/views'); + return $this->app['path'] . "/views/packages/{$package}"; } } diff --git a/src/views/meta.php b/src/views/meta.php index c51754a..7f32ead 100644 --- a/src/views/meta.php +++ b/src/views/meta.php @@ -1,22 +1,22 @@ namespace PHPSTORM_META { - /** - * PhpStorm Meta file, to provide autocomplete information for PhpStorm - * Generated on . - * - * @author Barry vd. Heuvel - * @see https://github.com/barryvdh/laravel-ide-helper - */ + /** + * PhpStorm Meta file, to provide autocomplete information for PhpStorm + * Generated on . + * + * @author Barry vd. Heuvel + * @see https://github.com/barryvdh/laravel-ide-helper + */ - /** @noinspection PhpIllegalArrayKeyTypeInspection */ - /** @noinspection PhpUnusedLocalVariableInspection */ - /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ - $STATIC_METHOD_TYPES = array( - - ('') => array( - $class): ?> - '' instanceof \, - ), + /** @noinspection PhpIllegalArrayKeyTypeInspection,PhpUnusedLocalVariableInspection,PhpUnnecessaryFullyQualifiedNameInspection */ + $STATIC_METHOD_TYPES = array( + + => array( + $class): ?> + '' instanceof \, - ); + ), + + ); + }