Skip to content

Commit

Permalink
Merge reset/smart reset, don't set class (#1523)
Browse files Browse the repository at this point in the history
* Merge reset/smart reset, don't set class

* Add changelog
  • Loading branch information
barryvdh committed Feb 19, 2024
1 parent d7ed749 commit 02af2a2
Show file tree
Hide file tree
Showing 38 changed files with 49 additions and 59 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- Support for Laravel 11 [#1520 / KentarouTakeda](https://github.com/barryvdh/laravel-ide-helper/pull/1520)

### Changed
- 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)
- Use short types (`int` and `bool` instead of `integer` and `boolean`) [#1524 / barryvdh](https://github.com/barryvdh/laravel-ide-helper/pull/1524)

### Removed
Expand All @@ -20,7 +21,6 @@ All notable changes to this project will be documented in this file.
- 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
- Minimum PHP version, due to Laravel 10, is now PHP 8.1


2024-02-15, 2.15.1
------------------

Expand Down
22 changes: 6 additions & 16 deletions src/Console/ModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class ModelsCommand extends Command
protected $write_mixin = false;
protected $dirs = [];
protected $reset;
protected $keep_text;
protected $phpstorm_noinspections;
protected $write_model_external_builder_methods;
/**
Expand Down Expand Up @@ -151,11 +150,8 @@ public function handle()
);
$model = $this->argument('model');
$ignore = $this->option('ignore');
$this->reset = $this->option('reset');
$this->reset = $this->option('reset') || $this->option('smart-reset');
$this->phpstorm_noinspections = $this->option('phpstorm-noinspections');
if ($this->option('smart-reset')) {
$this->keep_text = $this->reset = true;
}
$this->write_model_magic_where = $this->laravel['config']->get('ide-helper.write_model_magic_where', true);
$this->write_model_external_builder_methods = $this->laravel['config']->get('ide-helper.write_model_external_builder_methods', true);
$this->write_model_relation_count_properties =
Expand Down Expand Up @@ -218,8 +214,8 @@ protected function getOptions()
"Write models to {$this->filename} and adds @mixin to each model, avoiding IDE duplicate declaration warnings",
],
['nowrite', 'N', InputOption::VALUE_NONE, 'Don\'t write to Model file'],
['reset', 'R', InputOption::VALUE_NONE, 'Remove the original phpdocs instead of appending'],
['smart-reset', 'r', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'],
['reset', 'R', InputOption::VALUE_NONE, 'Refresh the properties/methods list, but keep the text'],
['smart-reset', 'r', InputOption::VALUE_NONE, 'Deprecated: same as --reset'],
['phpstorm-noinspections', 'p', InputOption::VALUE_NONE,
'Add PhpFullyQualifiedNameUsageInspection and PhpUnnecessaryFullyQualifiedNameInspection PHPStorm ' .
'noinspection tags',
Expand Down Expand Up @@ -889,19 +885,13 @@ protected function createPhpDocs($class)

if ($this->reset) {
$phpdoc = new DocBlock('', new Context($namespace));
if ($this->keep_text) {
$phpdoc->setText(
(new DocBlock($reflection, new Context($namespace)))->getText()
);
}
$phpdoc->setText(
(new DocBlock($reflection, new Context($namespace)))->getText()
);
} else {
$phpdoc = new DocBlock($reflection, new Context($namespace));
}

if (!$phpdoc->getText()) {
$phpdoc->setText($class);
}

$properties = [];
$methods = [];
foreach ($phpdoc->getTags() as $tag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AdvancedCasts\Models\AdvancedCast
*
*
* @property \Illuminate\Support\Carbon $cast_to_date_serialization
* @property \Illuminate\Support\Carbon $cast_to_datetime_serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\AllowGlobDirectory\Services\Post\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ArrayCastsWithComment\Models\ArrayCastsWithComment
*
*
* @property array<int, string>|null $cast_to_array -- These three should not be duplicated
* @property array<int, string> $cast_to_json some-description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Attributes\Models\Simple
*
*
* @property int $id
* @property int $diverging_type_hinted_get_and_set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Illuminate\Database\Eloquent\Relations\MorphTo;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Comment\Models\Simple
*
*
* @property int $id
* @property string $both_same_name I'm a getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomCollection\Models\Simple
*
*
* @property int $id
* @property-read SimpleCollection<int, Simple> $relationHasMany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\CustomDate\Models\CustomDate
*
*
* @property \Carbon\CarbonImmutable|null $created_at
* @property \Carbon\CarbonImmutable|null $updated_at
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DoesNotGeneratePhpdocWithExternalEloquentBuilder\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DoesNotGeneratePhpdocWithExternalEloquentBuilder\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\DynamicRelations\Models\Dynamic
*
*
* @property-read \Illuminate\Database\Eloquent\Collection<int, Dynamic> $regularHasMany
* @property-read int|null $regular_has_many_count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithCustomNamespace
*
*
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\CustomSpace\ModelWithCustomNamespaceFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithCustomNamespace newModelQuery()
Expand Down Expand Up @@ -41,7 +41,7 @@ protected static function newFactory()
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithFactory
*
*
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Factories\ModelWithFactoryFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithFactory newModelQuery()
Expand All @@ -60,7 +60,7 @@ class ModelWithFactory extends Model
namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithNestedFactory
*
*
* @method static \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Factories\ModelWithNestedFactoryFactory factory($count = null, $state = [])
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithNestedFactory newModelQuery()
Expand All @@ -81,7 +81,7 @@ class ModelWithNestedFactory extends ModelWithFactory
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Factories\Models\ModelWithoutFactory
*
*
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithoutFactory newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|ModelWithoutFactory newQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpDocWithEnumDefaults\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdoc\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocCamel\Models\Post
*
*
* @property int $id
* @property string|null $charNullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenerateBasicPhpdocFinal\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithExternalEloquentBuilder\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithExternalEloquentBuilder\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithExternalEloquentBuilderWithFqn\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Database\Eloquent\SoftDeletes;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Illuminate\Support\Carbon;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithFqn\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithFqnInExternalFile\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithFqnInExternalFile\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Post extends Model

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithMixin\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithMixin\Models\FinalPost
*
*
* @property $someProp
* @method someMethod(string $method)
Expand All @@ -60,7 +60,7 @@ final class IdeHelperFinalPost {}

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithMixin\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithMixin\Models\Post
*
*
* @property $someProp
* @method someMethod(string $method)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GenericsSyntaxDisabled\Models\Simple
*
*
* @property int $id
* @property-read \Illuminate\Database\Eloquent\Collection|Simple[] $regularBelongsToMany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Getter\Models\Simple
*
*
* @property int $id
* @property-read int|null $attribute_return_type_int_or_null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Ignored\Models\NotIgnored
*
*
* @method static \Illuminate\Database\Eloquent\Builder|NotIgnored newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|NotIgnored newQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models{
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Interfaces\Models\User
*
*
* @method static \Illuminate\Database\Eloquent\Builder|User newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|User newQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Models\CustomCast
*
*
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_return_type
* @property \Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\LaravelCustomCasts\Casts\CastedProperty $casted_property_with_return_docblock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\MagicWhere\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down
2 changes: 1 addition & 1 deletion tests/Console/ModelsCommand/ModelHooks/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function test(): void
use Illuminate\Database\Eloquent\Model;
/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\ModelHooks\Models\Simple
*
*
* @property int $id
* @property-read string $custom
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple
*
*
* @property int $id
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Database\Eloquent\Model;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\PHPStormNoInspection\Models\Simple
*
*
* @property int $id
* @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Eloquent\Relations\HasMany;

/**
* Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\RelationCountProperties\Models\Post
*
*
* @property int $id
* @property string|null $char_nullable
Expand Down

0 comments on commit 02af2a2

Please sign in to comment.