diff --git a/CHANGELOG.md b/CHANGELOG.md index f473a14..0d323e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file. -------------- ### Changed -Add support for multiple pivot types when using the same accessor. +- Add support for multiple pivot types when using the same accessor. +- Smarter reset, keep tags that IDE helper doesn't use 2024-10-18, 3.2.0 -------------- diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index b915e03..ddf1dea 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -945,13 +945,19 @@ class ModelsCommand extends Command $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 = []; diff --git a/tests/Console/ModelsCommand/ResetAndSmartReset/Models/Simple.php b/tests/Console/ModelsCommand/ResetAndSmartReset/Models/Simple.php index 86646d3..86d86bf 100644 --- a/tests/Console/ModelsCommand/ResetAndSmartReset/Models/Simple.php +++ b/tests/Console/ModelsCommand/ResetAndSmartReset/Models/Simple.php @@ -9,7 +9,13 @@ use Illuminate\Database\Eloquent\Model; /** * Text of existing phpdoc * + * @implements \ArrayAccess + * @noinspection PhpUnreachableStatementInspection + * @noinspection PhpUnnecessaryFullyQualifiedNameInspection * @property string $foo + * @property-read string $bar + * @method fooBar() + * @mixin \Eloquent */ class Simple extends Model { diff --git a/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testNoReset__1.php b/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testNoReset__1.php index 21a8199..ed7be44 100644 --- a/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testNoReset__1.php +++ b/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testNoReset__1.php @@ -9,7 +9,12 @@ use Illuminate\Database\Eloquent\Model; /** * Text of existing phpdoc * + * @implements \ArrayAccess + * @noinspection PhpUnreachableStatementInspection + * @noinspection PhpUnnecessaryFullyQualifiedNameInspection * @property string $foo + * @property-read string $bar + * @method fooBar() * @property int $id * @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery() diff --git a/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testReset__1.php b/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testReset__1.php index e00f9e9..390bbf1 100644 --- a/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testReset__1.php +++ b/tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testReset__1.php @@ -9,6 +9,8 @@ use Illuminate\Database\Eloquent\Model; /** * Text of existing phpdoc * + * @implements \ArrayAccess + * @noinspection PhpUnreachableStatementInspection * @property int $id * @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery()