diff --git a/resources/views/helper.php b/resources/views/helper.php index 7b39b52..450432c 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -9,14 +9,10 @@ */ $aliases): ?> -namespace { - - exit("This file should not be included, only analyzed by your IDE"); - - +namespace { - getClassType() ?> getShortName() ?> getExtends() ? 'extends ' . $alias->getExtends() : '' ?>{ + getClassType() ?> getShortName() ?>{ getMethods() as $method): ?> getDocComment(' ')) ?> @@ -30,14 +26,23 @@ namespace { } - } - + } - } - + + +namespace { + exit("This file should not be included, only analyzed by your IDE"); + + $aliases): ?> + + getClassType() ?> getShortName() ?> extends getExtends() ?>{} + + + +} namespace Illuminate\Support { @@ -63,4 +68,4 @@ namespace Illuminate\Support { */ class Fluent {} } - + \ No newline at end of file diff --git a/src/Alias.php b/src/Alias.php index bcdbc95..d1f9ca6 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -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 diff --git a/src/Generator.php b/src/Generator.php index d9b8068..2633f3d 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -209,7 +209,7 @@ class Generator $alias->addClass($this->extra[$name]); } - $namespace = $alias->getNamespace(); + $namespace = $alias->getExtendsNamespace() ?: $alias->getNamespace(); if (!isset($namespaces[$namespace])) { $namespaces[$namespace] = array(); }