Re-format source code of Generator class

This commit is contained in:
Thach Nguyen
2018-01-27 03:21:08 +07:00
parent 501ef7045a
commit 042d341b65
+21 -11
View File
@@ -10,7 +10,7 @@
namespace Barryvdh\LaravelIdeHelper;
use Illuminate\Foundation\AliasLoader;
use /** @noinspection PhpUndefinedNamespaceInspection,PhpUndefinedClassInspection */Illuminate\Foundation\AliasLoader;
use Illuminate\Config\Repository as ConfigRepository;
use Symfony\Component\Console\Output\OutputInterface;
@@ -36,11 +36,8 @@ class Generator
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param string $helpers
*/
public function __construct(ConfigRepository $config,
/* Illuminate\View\Factory */ $view,
OutputInterface $output = null,
$helpers = ''
) {
public function __construct(ConfigRepository $config, $view, OutputInterface $output = null, $helpers = '')
{
$this->config = $config;
$this->view = $view;
@@ -50,6 +47,7 @@ class Generator
$this->extra = array_merge($this->extra, $this->config->get('laravel-ide-helper::extra'));
$this->magic = array_merge($this->magic, $this->config->get('laravel-ide-helper::magic'));
$this->interfaces = array_merge($this->interfaces, $this->config->get('laravel-ide-helper::interfaces'));
// Make all interface classes absolute
foreach ($this->interfaces as &$interface) {
$interface = '\\' . ltrim($interface, '\\');
@@ -115,6 +113,7 @@ class Generator
{
try {
if (class_exists('Auth') && is_a('Auth', '\Illuminate\Support\Facades\Auth', true)) {
/** @noinspection PhpUndefinedClassInspection */
$class = get_class(\Auth::driver());
$this->extra['Auth'] = array($class);
$this->interfaces['\Illuminate\Auth\UserProviderInterface'] = $class;
@@ -123,6 +122,7 @@ class Generator
try {
if (class_exists('DB') && is_a('DB', '\Illuminate\Support\Facades\DB', true)) {
/** @noinspection PhpUndefinedClassInspection */
$class = get_class(\DB::connection());
$this->extra['DB'] = array($class);
$this->interfaces['\Illuminate\Database\ConnectionInterface'] = $class;
@@ -131,7 +131,9 @@ class Generator
try {
if (class_exists('Cache') && is_a('Cache', '\Illuminate\Support\Facades\Cache', true)) {
/** @noinspection PhpUndefinedClassInspection */
$driver = get_class(\Cache::driver());
/** @noinspection PhpUndefinedClassInspection */
$store = get_class(\Cache::getStore());
$this->extra['Cache'] = array($driver, $store);
$this->interfaces['\Illuminate\Cache\StoreInterface'] = $store;
@@ -140,6 +142,7 @@ class Generator
try {
if (class_exists('Queue') && is_a('Queue', '\Illuminate\Support\Facades\Queue', true)) {
/** @noinspection PhpUndefinedClassInspection */
$class = get_class(\Queue::connection());
$this->extra['Queue'] = array($class);
$this->interfaces['\Illuminate\Queue\QueueInterface'] = $class;
@@ -148,6 +151,7 @@ class Generator
try {
if (class_exists('SSH') && is_a('SSH', '\Illuminate\Support\Facades\SSH', true)) {
/** @noinspection PhpUndefinedClassInspection */
$class = get_class(\SSH::connection());
$this->extra['SSH'] = array($class);
$this->interfaces['\Illuminate\Remote\ConnectionInterface'] = $class;
@@ -159,13 +163,14 @@ class Generator
/**
* Find all namespaces/aliases that are valid for us to render
*
* @return array
* @return array|Alias[][]
*/
protected function getNamespaces()
{
$namespaces = array();
// Get all aliases
/** @noinspection PhpUndefinedClassInspection */
foreach (AliasLoader::getInstance()->getAliases() as $name => $facade) {
$magicMethods = array_key_exists($name, $this->magic) ? $this->magic[$name] : array();
$alias = new Alias($name, $facade, $magicMethods, $this->interfaces);
@@ -197,15 +202,20 @@ class Generator
public function getDriver($alias)
{
try {
if ($alias == "Auth") {
if ($alias == 'Auth') {
/** @noinspection PhpUndefinedClassInspection */
$driver = \Auth::driver();
} elseif ($alias == "DB") {
} elseif ($alias == 'DB') {
/** @noinspection PhpUndefinedClassInspection */
$driver = \DB::connection();
} elseif ($alias == "Cache") {
} elseif ($alias == 'Cache') {
/** @noinspection PhpUndefinedClassInspection */
$driver = get_class(\Cache::driver());
/** @noinspection PhpUndefinedClassInspection */
$store = get_class(\Cache::getStore());
return array($driver, $store);
} elseif ($alias == "Queue") {
} elseif ($alias == 'Queue') {
/** @noinspection PhpUndefinedClassInspection */
$driver = \Queue::connection();
} else {
return false;