Skip to content

Commit 02af2a2

Browse files
authored
Merge reset/smart reset, don't set class (#1523)
* Merge reset/smart reset, don't set class * Add changelog
1 parent d7ed749 commit 02af2a2

File tree

38 files changed

+49
-59
lines changed

38 files changed

+49
-59
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111
- Support for Laravel 11 [#1520 / KentarouTakeda](https://github.com/barryvdh/laravel-ide-helper/pull/1520)
1212

1313
### Changed
14+
- Merge --reset and --smart-reset, to always keep the text. Always skipp the classname [#1523 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1523)
1415
- Use short types (`int` and `bool` instead of `integer` and `boolean`) [#1524 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1524)
1516

1617
### Removed
@@ -20,7 +21,6 @@ All notable changes to this project will be documented in this file.
2021
- You _might_ have top-level dependency on doctrine/dbal. This may have been in the past due to ide-helper, we suggest to check if you still need it and remove it otherwise
2122
- Minimum PHP version, due to Laravel 10, is now PHP 8.1
2223

23-
2424
2024-02-15, 2.15.1
2525
------------------
2626

src/Console/ModelsCommand.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ class ModelsCommand extends Command
105105
protected $write_mixin = false;
106106
protected $dirs = [];
107107
protected $reset;
108-
protected $keep_text;
109108
protected $phpstorm_noinspections;
110109
protected $write_model_external_builder_methods;
111110
/**
@@ -151,11 +150,8 @@ public function handle()
151150
);
152151
$model = $this->argument('model');
153152
$ignore = $this->option('ignore');
154-
$this->reset = $this->option('reset');
153+
$this->reset = $this->option('reset') || $this->option('smart-reset');
155154
$this->phpstorm_noinspections = $this->option('phpstorm-noinspections');
156-
if ($this->option('smart-reset')) {
157-
$this->keep_text = $this->reset = true;
158-
}
159155
$this->write_model_magic_where = $this->laravel['config']->get('ide-helper.write_model_magic_where', true);
160156
$this->write_model_external_builder_methods = $this->laravel['config']->get('ide-helper.write_model_external_builder_methods', true);
161157
$this->write_model_relation_count_properties =
@@ -218,8 +214,8 @@ protected function getOptions()
218214
"Write models to {$this->filename} and adds @mixin to each model, avoiding IDE duplicate declaration warnings",
219215
],
220216
['nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'],
221-
['reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'],
222-
['smart-reset', 'r', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'],
217+
['reset', 'R', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'],
218+
['smart-reset', 'r', InputOption::VALUE_NONE, 'Deprecated: same as --reset'],
223219
['phpstorm-noinspections', 'p', InputOption::VALUE_NONE,
224220
'Add PhpFullyQualifiedNameUsageInspection and PhpUnnecessaryFullyQualifiedNameInspection PHPStorm ' .
225221
'noinspection tags',
@@ -889,19 +885,13 @@ protected function createPhpDocs($class)
889885

890886
if ($this->reset) {
891887
$phpdoc = new DocBlock('', new Context($namespace));
892-
if ($this->keep_text) {
893-
$phpdoc->setText(
894-
(new DocBlock($reflection, new Context($namespace)))->getText()
895-
);
896-
}
888+
$phpdoc->setText(
889+
(new DocBlock($reflection, new Context($namespace)))->getText()
890+
);
897891
} else {
898892
$phpdoc = new DocBlock($reflection, new Context($namespace));
899893
}
900894

901-
if (!$phpdoc->getText()) {
902-
$phpdoc->setText($class);
903-
}
904-
905895
$properties = [];
906896
$methods = [];
907897
foreach ($phpdoc->getTags() as $tag) {

tests/Console/ModelsCommand/AdvancedCasts/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Database\Eloquent\Model;
1010

1111
/**
12-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models\AdvancedCast
12+
*
1313
*
1414
* @property \Illuminate\Support\Carbon $cast_to_date_serialization
1515
* @property \Illuminate\Support\Carbon $cast_to_datetime_serialization

tests/Console/ModelsCommand/AllowGlobDirectory/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Database\Eloquent\Model;
88

99
/**
10-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AllowGlobDirectory\Services\Post\Models\Post
10+
*
1111
*
1212
* @property int $id
1313
* @property string|null $char_nullable

tests/Console/ModelsCommand/ArrayCastsWithComment/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Database\Eloquent\Model;
88

99
/**
10-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models\ArrayCastsWithComment
10+
*
1111
*
1212
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated
1313
* @property array<int, string> $cast_to_json some-description

tests/Console/ModelsCommand/Attributes/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Illuminate\Database\Eloquent\Model;
99

1010
/**
11-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Attributes\Models\Simple
11+
*
1212
*
1313
* @property int $id
1414
* @property int $diverging_type_hinted_get_and_set

tests/Console/ModelsCommand/Comment/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Illuminate\Database\Eloquent\Relations\MorphTo;
1111

1212
/**
13-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Comment\Models\Simple
13+
*
1414
*
1515
* @property int $id
1616
* @property string $both_same_name I'm a getter

tests/Console/ModelsCommand/CustomCollection/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Illuminate\Database\Eloquent\Relations\HasMany;
1010

1111
/**
12-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple
12+
*
1313
*
1414
* @property int $id
1515
* @property-read SimpleCollection<int, Simple> $relationHasMany

tests/Console/ModelsCommand/CustomDate/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Illuminate\Database\Eloquent\Model;
88

99
/**
10-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomDate\Models\CustomDate
10+
*
1111
*
1212
* @property \Carbon\CarbonImmutable|null $created_at
1313
* @property \Carbon\CarbonImmutable|null $updated_at

tests/Console/ModelsCommand/DoesNotGeneratePhpdocWithExternalEloquentBuilder/__snapshots__/Test__test__1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DoesNotGeneratePhpdocWithExternalEloquentBuilder\Models{
1515
/**
16-
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DoesNotGeneratePhpdocWithExternalEloquentBuilder\Models\Post
16+
*
1717
*
1818
* @property int $id
1919
* @property string|null $char_nullable

0 commit comments

Comments
 (0)