mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Add facades fullpath autocomplete (#437)
* Add method to retrieve namespace of extended class * Regroup classes by namespace of the class they extends * Restore facades shortnames
This commit is contained in:
committed by
Barry vd. Heuvel
parent
a7fc2ec489
commit
525733122e
+16
-11
@@ -9,14 +9,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
<?php foreach($namespaces as $namespace => $aliases): ?>
|
<?php foreach($namespaces as $namespace => $aliases): ?>
|
||||||
namespace <?= $namespace == '__root' ? '' : $namespace ?>{
|
namespace <?= $namespace == '__root' ? '' : trim($namespace, '\\') ?>{
|
||||||
<?php if($namespace == '__root'): ?>
|
|
||||||
exit("This file should not be included, only analyzed by your IDE");
|
|
||||||
<?= $helpers ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php foreach($aliases as $alias): ?>
|
<?php foreach($aliases as $alias): ?>
|
||||||
|
|
||||||
<?= $alias->getClassType() ?> <?= $alias->getShortName() ?> <?= $alias->getExtends() ? 'extends ' . $alias->getExtends() : '' ?>{
|
<?= $alias->getClassType() ?> <?= $alias->getShortName() ?>{
|
||||||
<?php foreach($alias->getMethods() as $method): ?>
|
<?php foreach($alias->getMethods() as $method): ?>
|
||||||
|
|
||||||
<?= trim($method->getDocComment(' ')) ?>
|
<?= trim($method->getDocComment(' ')) ?>
|
||||||
@@ -30,14 +26,23 @@ namespace <?= $namespace == '__root' ? '' : $namespace ?>{
|
|||||||
}
|
}
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
exit("This file should not be included, only analyzed by your IDE");
|
||||||
|
<?= $helpers ?>
|
||||||
|
|
||||||
|
<?php foreach($namespaces as $namespace => $aliases): ?>
|
||||||
|
<?php foreach($aliases as $alias): ?>
|
||||||
|
<?= $alias->getClassType() ?> <?= $alias->getShortName() ?> extends <?= $alias->getExtends() ?>{}
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
}
|
||||||
|
|
||||||
<?php if($include_fluent): ?>
|
<?php if($include_fluent): ?>
|
||||||
namespace Illuminate\Support {
|
namespace Illuminate\Support {
|
||||||
@@ -63,4 +68,4 @@ namespace Illuminate\Support {
|
|||||||
*/
|
*/
|
||||||
class Fluent {}
|
class Fluent {}
|
||||||
}
|
}
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
@@ -15,6 +15,7 @@ class Alias
|
|||||||
protected $alias;
|
protected $alias;
|
||||||
protected $facade;
|
protected $facade;
|
||||||
protected $extends = null;
|
protected $extends = null;
|
||||||
|
protected $extendsNamespace = null;
|
||||||
protected $classType = 'class';
|
protected $classType = 'class';
|
||||||
protected $short;
|
protected $short;
|
||||||
protected $namespace = '__root';
|
protected $namespace = '__root';
|
||||||
@@ -53,6 +54,7 @@ class Alias
|
|||||||
$this->addClass($this->root);
|
$this->addClass($this->root);
|
||||||
$this->detectNamespace();
|
$this->detectNamespace();
|
||||||
$this->detectClassType();
|
$this->detectClassType();
|
||||||
|
$this->detectExtendsNamespace();
|
||||||
|
|
||||||
if ($facade === '\Illuminate\Database\Eloquent\Model') {
|
if ($facade === '\Illuminate\Database\Eloquent\Model') {
|
||||||
$this->usedMethods = array('decrement', 'increment');
|
$this->usedMethods = array('decrement', 'increment');
|
||||||
@@ -104,6 +106,16 @@ class Alias
|
|||||||
{
|
{
|
||||||
return $this->extends;
|
return $this->extends;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the namespace of the class which this alias extends
|
||||||
|
*
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public function getExtendsNamespace()
|
||||||
|
{
|
||||||
|
return $this->extendsNamespace;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Alias by which this class is called
|
* Get the Alias by which this class is called
|
||||||
@@ -157,6 +169,18 @@ class Alias
|
|||||||
$this->short = $this->alias;
|
$this->short = $this->alias;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detect the extends namespace
|
||||||
|
*/
|
||||||
|
protected function detectExtendsNamespace()
|
||||||
|
{
|
||||||
|
if (strpos($this->extends, '\\') !== false) {
|
||||||
|
$nsParts = explode('\\', $this->extends);
|
||||||
|
array_pop($nsParts);
|
||||||
|
$this->extendsNamespace = implode('\\', $nsParts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect the class type
|
* Detect the class type
|
||||||
|
|||||||
+1
-1
@@ -209,7 +209,7 @@ class Generator
|
|||||||
$alias->addClass($this->extra[$name]);
|
$alias->addClass($this->extra[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$namespace = $alias->getNamespace();
|
$namespace = $alias->getExtendsNamespace() ?: $alias->getNamespace();
|
||||||
if (!isset($namespaces[$namespace])) {
|
if (!isset($namespaces[$namespace])) {
|
||||||
$namespaces[$namespace] = array();
|
$namespaces[$namespace] = array();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user