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:
Florian Lefèvre
2017-02-01 07:21:31 +01:00
committed by Barry vd. Heuvel
parent a7fc2ec489
commit 525733122e
3 changed files with 41 additions and 12 deletions
+24
View File
@@ -15,6 +15,7 @@ class Alias
protected $alias;
protected $facade;
protected $extends = null;
protected $extendsNamespace = null;
protected $classType = 'class';
protected $short;
protected $namespace = '__root';
@@ -53,6 +54,7 @@ class Alias
$this->addClass($this->root);
$this->detectNamespace();
$this->detectClassType();
$this->detectExtendsNamespace();
if ($facade === '\Illuminate\Database\Eloquent\Model') {
$this->usedMethods = array('decrement', 'increment');
@@ -104,6 +106,16 @@ class Alias
{
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
@@ -157,6 +169,18 @@ class 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