diff --git a/resources/views/helper.php b/resources/views/helper.php index c3f583ca5..74af90c0e 100644 --- a/resources/views/helper.php +++ b/resources/views/helper.php @@ -29,7 +29,7 @@ $aliases) : ?> namespace { -getDocComment($s1)) . "\n{$s1}" . $alias->getClassType() ?> getExtendsClass() ?> { +getDocComment($s1)) . "\n{$s1}" . $alias->getClassType() ?> getExtendsClass() ?>shouldExtendParentClass()): ?> extends getParentClass() ?> { getMethods() as $method) : ?> getDocComment($s2)) . "\n{$s2}" ?>public static function getName() ?>(getParamsWithDefault() ?>) {getDeclaringClass() !== $method->getRoot()) : ?> diff --git a/src/Alias.php b/src/Alias.php index 1ff2faed9..dae3bd04b 100644 --- a/src/Alias.php +++ b/src/Alias.php @@ -36,6 +36,7 @@ class Alias protected $classType = 'class'; protected $short; protected $namespace = '__root'; + protected $parentClass; protected $root = null; protected $classes = []; protected $methods = []; @@ -87,6 +88,7 @@ public function __construct($config, $alias, $facade, $magicMethods = [], $inter $this->detectNamespace(); $this->detectClassType(); $this->detectExtendsNamespace(); + $this->detectParentClass(); if (!empty($this->namespace)) { try { @@ -171,6 +173,25 @@ public function getExtendsNamespace() return $this->extendsNamespace; } + /** + * Get the parent class of the class which this alias extends + * + * @return null|string + */ + public function getParentClass() + { + return $this->parentClass; + } + + /** + * Check if this class should extend the parent class + */ + public function shouldExtendParentClass() + { + return $this->parentClass + && $this->getExtendsNamespace() !== '\\Illuminate\\Support\\Facades'; + } + /** * Get the Alias by which this class is called * @@ -268,6 +289,18 @@ protected function detectExtendsNamespace() } } + /** + * Detect the parent class + */ + protected function detectParentClass() + { + $reflection = new ReflectionClass($this->root); + + $parentClass = $reflection->getParentClass(); + + $this->parentClass = $parentClass ? '\\' . $parentClass->getName() : null; + } + /** * Detect the class type */