Generate cleaner model mixin classes (#1268)

* Generate cleaner model mixin classes

* Fix test
This commit is contained in:
George Boot
2021-10-25 13:44:43 +02:00
committed by GitHub
parent ae48e1e467
commit dd12b7cdcb
2 changed files with 16 additions and 5 deletions
+15 -4
View File
@@ -918,6 +918,13 @@ class ModelsCommand extends Command
if (!$phpdocMixin->getText()) {
$mixinDocComment = preg_replace("/\s\*\s*\n/", '', $mixinDocComment);
}
foreach ($phpdoc->getTagsByName('mixin') as $tag) {
if (Str::startsWith($tag->getContent(), 'IdeHelper')) {
$phpdoc->deleteTag($tag);
}
}
$docComment = $serializer->getDocComment($phpdoc);
}
if ($this->write) {
@@ -939,11 +946,15 @@ class ModelsCommand extends Command
}
$classname = $this->write_mixin ? $mixinClassName : $classname;
$output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}class {$classname} extends \Eloquent ";
$output = "namespace {$namespace}{\n{$docComment}\n\t{$keyword}class {$classname} ";
if ($interfaceNames) {
$interfaces = implode(', \\', $interfaceNames);
$output .= "implements \\{$interfaces} ";
if (!$this->write_mixin) {
$output .= "extends \Eloquent ";
if ($interfaceNames) {
$interfaces = implode(', \\', $interfaceNames);
$output .= "implements \\{$interfaces} ";
}
}
return $output . "{}\n}\n\n";
@@ -183,6 +183,6 @@ namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWi
* @method static \Illuminate\Database\Eloquent\Builder|Post whereYearNullable($value)
* @mixin \Eloquent
*/
class IdeHelperPost extends \Eloquent {}
class IdeHelperPost {}
}