mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-19 10:33:11 +00:00
Generate cleaner model mixin classes (#1268)
* Generate cleaner model mixin classes * Fix test
This commit is contained in:
@@ -918,6 +918,13 @@ class ModelsCommand extends Command
|
|||||||
if (!$phpdocMixin->getText()) {
|
if (!$phpdocMixin->getText()) {
|
||||||
$mixinDocComment = preg_replace("/\s\*\s*\n/", '', $mixinDocComment);
|
$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) {
|
if ($this->write) {
|
||||||
@@ -939,11 +946,15 @@ class ModelsCommand extends Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
$classname = $this->write_mixin ? $mixinClassName : $classname;
|
$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) {
|
if (!$this->write_mixin) {
|
||||||
$interfaces = implode(', \\', $interfaceNames);
|
$output .= "extends \Eloquent ";
|
||||||
$output .= "implements \\{$interfaces} ";
|
|
||||||
|
if ($interfaceNames) {
|
||||||
|
$interfaces = implode(', \\', $interfaceNames);
|
||||||
|
$output .= "implements \\{$interfaces} ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $output . "{}\n}\n\n";
|
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)
|
* @method static \Illuminate\Database\Eloquent\Builder|Post whereYearNullable($value)
|
||||||
* @mixin \Eloquent
|
* @mixin \Eloquent
|
||||||
*/
|
*/
|
||||||
class IdeHelperPost extends \Eloquent {}
|
class IdeHelperPost {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user