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