Skip to content

Commit

Permalink
Smarter reset
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh committed Oct 28, 2024
1 parent 7740b80 commit 29f8743
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,19 @@ protected function createPhpDocs($class)
$reflection->getParentClass()->getInterfaceNames()
);

$phpdoc = new DocBlock($reflection, new Context($namespace));
if ($this->reset) {
$phpdoc = new DocBlock('', new Context($namespace));
$phpdoc->setText(
(new DocBlock($reflection, new Context($namespace)))->getText()
);
} else {
$phpdoc = new DocBlock($reflection, new Context($namespace));
foreach ($phpdoc->getTags() as $tag) {
if (
in_array($tag->getName(), ['property', 'property-read', 'property-write', 'method', 'mixin'])
|| ($tag->getName() === 'noinspection' && in_array($tag->getContent(), ['PhpUnnecessaryFullyQualifiedNameInspection', 'PhpFullyQualifiedNameUsageInspection']))
) {
$phpdoc->deleteTag($tag);
}
}
}

$properties = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
/**
* Text of existing phpdoc
*
* @implements \ArrayAccess
* @noinspection PhpUnreachableStatementInspection
* @PhpFullyQualifiedNameUsageInspection PhpUnnecessaryFullyQualifiedNameInspection
* @property string $foo
* @mixin \Eloquent
*/
class Simple extends Model
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
/**
* Text of existing phpdoc
*
* @implements \ArrayAccess
* @noinspection PhpUnreachableStatementInspection
* @PhpFullyQualifiedNameUsageInspection PhpUnnecessaryFullyQualifiedNameInspection
* @property string $foo
* @property int $id
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
/**
* Text of existing phpdoc
*
* @implements \ArrayAccess
* @noinspection PhpUnreachableStatementInspection
* @PhpFullyQualifiedNameUsageInspection PhpUnnecessaryFullyQualifiedNameInspection
* @property int $id
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()
Expand Down

0 comments on commit 29f8743

Please sign in to comment.