Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/views/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<?php foreach ($namespaces_by_extends_ns as $namespace => $aliases) : ?>
namespace <?= $namespace === '__root' ? '' : trim($namespace, '\\') ?> {
<?php foreach ($aliases as $alias) : ?>
<?php echo trim($alias->getDocComment($s1)) . "\n{$s1}" . $alias->getClassType() ?> <?= $alias->getExtendsClass() ?> {
<?php echo trim($alias->getDocComment($s1)) . "\n{$s1}" . $alias->getClassType() ?> <?= $alias->getExtendsClass() ?><?php if($alias->shouldExtendParentClass()): ?> extends <?= $alias->getParentClass() ?><?php endif; ?> {
<?php foreach ($alias->getMethods() as $method) : ?>
<?= trim($method->getDocComment($s2)) . "\n{$s2}" ?>public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>)
{<?php if ($method->getDeclaringClass() !== $method->getRoot()) : ?>
Expand Down
33 changes: 33 additions & 0 deletions src/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Alias
protected $classType = 'class';
protected $short;
protected $namespace = '__root';
protected $parentClass;
protected $root = null;
protected $classes = [];
protected $methods = [];
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*/
Expand Down
Loading