Skip to content

Commit 7549f58

Browse files
authored
Smarter reset (#1603)
* Smarter reset * Changelog * Fix phpdocs
1 parent 7740b80 commit 7549f58

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file.
66
--------------
77

88
### Changed
9-
Add support for multiple pivot types when using the same accessor.
9+
- Add support for multiple pivot types when using the same accessor.
10+
- Smarter reset, keep tags that IDE helper doesn't use
1011

1112
2024-10-18, 3.2.0
1213
--------------

src/Console/ModelsCommand.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -945,13 +945,19 @@ protected function createPhpDocs($class)
945945
$reflection->getParentClass()->getInterfaceNames()
946946
);
947947

948+
$phpdoc = new DocBlock($reflection, new Context($namespace));
948949
if ($this->reset) {
949-
$phpdoc = new DocBlock('', new Context($namespace));
950950
$phpdoc->setText(
951951
(new DocBlock($reflection, new Context($namespace)))->getText()
952952
);
953-
} else {
954-
$phpdoc = new DocBlock($reflection, new Context($namespace));
953+
foreach ($phpdoc->getTags() as $tag) {
954+
if (
955+
in_array($tag->getName(), ['property', 'property-read', 'property-write', 'method', 'mixin'])
956+
|| ($tag->getName() === 'noinspection' && in_array($tag->getContent(), ['PhpUnnecessaryFullyQualifiedNameInspection', 'PhpFullyQualifiedNameUsageInspection']))
957+
) {
958+
$phpdoc->deleteTag($tag);
959+
}
960+
}
955961
}
956962

957963
$properties = [];

tests/Console/ModelsCommand/ResetAndSmartReset/Models/Simple.php

+6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
/**
1010
* Text of existing phpdoc
1111
*
12+
* @implements \ArrayAccess
13+
* @noinspection PhpUnreachableStatementInspection
14+
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
1215
* @property string $foo
16+
* @property-read string $bar
17+
* @method fooBar()
18+
* @mixin \Eloquent
1319
*/
1420
class Simple extends Model
1521
{

tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testNoReset__1.php

+5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
/**
1010
* Text of existing phpdoc
1111
*
12+
* @implements \ArrayAccess
13+
* @noinspection PhpUnreachableStatementInspection
14+
* @noinspection PhpUnnecessaryFullyQualifiedNameInspection
1215
* @property string $foo
16+
* @property-read string $bar
17+
* @method fooBar()
1318
* @property int $id
1419
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
1520
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()

tests/Console/ModelsCommand/ResetAndSmartReset/__snapshots__/Test__testReset__1.php

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/**
1010
* Text of existing phpdoc
1111
*
12+
* @implements \ArrayAccess
13+
* @noinspection PhpUnreachableStatementInspection
1214
* @property int $id
1315
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newModelQuery()
1416
* @method static \Illuminate\Database\Eloquent\Builder<static>|Simple newQuery()

0 commit comments

Comments
 (0)