Skip to content

Commit f465625

Browse files
authored
Fix non-facade classes will result in no autocomplete (#841)
* Filter out non-facade base classes * Remove Model as it is already skipped because it's not a facade
1 parent cc9ed44 commit f465625

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

resources/views/helper.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323
*/
2424

2525
<?php foreach ($namespaces_by_extends_ns as $namespace => $aliases) : ?>
26-
<?php if ($namespace == '\Illuminate\Database\Eloquent') :
27-
continue;
28-
endif; ?>
29-
namespace <?= $namespace == '__root' ? '' : trim($namespace, '\\') ?> {
26+
namespace <?= $namespace == '__root' ? '' : trim($namespace, '\\') ?> {
3027
<?php foreach ($aliases as $alias) : ?>
31-
<?= trim($alias->getDocComment(' ')) ?>
28+
<?= trim($alias->getDocComment(' ')) ?>
3229
<?= $alias->getClassType() ?> <?= $alias->getExtendsClass() ?> {
3330
<?php foreach ($alias->getMethods() as $method) : ?>
34-
<?= trim($method->getDocComment(' ')) ?>
31+
<?= trim($method->getDocComment(' ')) ?>
3532
public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>)
3633
{<?php if ($method->getDeclaringClass() !== $method->getRoot()) : ?>
3734
//Method inherited from <?= $method->getDeclaringClass() ?>
@@ -42,19 +39,19 @@ public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefau
4239
<?php endif?>
4340
<?= $method->shouldReturn() ? 'return ' : '' ?><?= $method->getRootMethodCall() ?>;
4441
}
45-
<?php endforeach; ?>
42+
<?php endforeach; ?>
4643
}
47-
<?php endforeach; ?>
44+
<?php endforeach; ?>
4845
}
4946

5047
<?php endforeach; ?>
5148

5249
<?php foreach ($namespaces_by_alias_ns as $namespace => $aliases) : ?>
53-
namespace <?= $namespace == '__root' ? '' : trim($namespace, '\\') ?> {
50+
namespace <?= $namespace == '__root' ? '' : trim($namespace, '\\') ?> {
5451
<?php foreach ($aliases as $alias) : ?>
5552
<?= $alias->getClassType() ?> <?= $alias->getShortName() ?> extends <?= $alias->getExtends() ?> {<?php if ($alias->getExtendsNamespace() == '\Illuminate\Database\Eloquent') : ?>
56-
<?php foreach ($alias->getMethods() as $method) : ?>
57-
<?= trim($method->getDocComment(' ')) ?>
53+
<?php foreach ($alias->getMethods() as $method) : ?>
54+
<?= trim($method->getDocComment(' ')) ?>
5855
public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>)
5956
{<?php if ($method->getDeclaringClass() !== $method->getRoot()) : ?>
6057
//Method inherited from <?= $method->getDeclaringClass() ?>
@@ -67,14 +64,14 @@ public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefau
6764
}
6865
<?php endforeach; ?>
6966
<?php endif; ?>}
70-
<?php endforeach; ?>
67+
<?php endforeach; ?>
7168
}
7269

7370
<?php endforeach; ?>
7471

7572
<?php if ($helpers) : ?>
7673
namespace {
77-
<?= $helpers ?>
74+
<?= $helpers ?>
7875
}
7976
<?php endif; ?>
8077

src/Generator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Illuminate\Foundation\AliasLoader;
1515
use Illuminate\Support\Collection;
16+
use Illuminate\Support\Facades\Facade;
1617
use Illuminate\Support\Str;
1718
use Illuminate\Support\Traits\Macroable;
1819
use ReflectionClass;
@@ -175,7 +176,9 @@ protected function getValidAliases()
175176
*/
176177
protected function getAliasesByExtendsNamespace()
177178
{
178-
$aliases = $this->getValidAliases();
179+
$aliases = $this->getValidAliases()->filter(static function (Alias $alias) {
180+
return is_subclass_of($alias->getExtends(), Facade::class);
181+
});
179182

180183
$this->addMacroableClasses($aliases);
181184

0 commit comments

Comments
 (0)