From 07f5eaea73d7b4ddbdec322d76df79351d144509 Mon Sep 17 00:00:00 2001 From: KentarouTakeda Date: Thu, 11 Aug 2022 19:36:43 +0900 Subject: [PATCH] Fix return type of methods provided by `SoftDeletes` (#1345) * Fix return type of methods provided by `SoftDeletes` * Update CHANGELOG * fix test / update snapshot --- CHANGELOG.md | 1 + src/Console/ModelsCommand.php | 2 +- .../__snapshots__/Test__test__1.php | 6 +++--- .../GeneratePhpdocWithFqn/__snapshots__/Test__test__1.php | 6 +++--- .../SoftDeletes/__snapshots__/Test__test__1.php | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6066eec..b65ebc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. -------------- ### Fixes +- Fix return type of methods provided by `SoftDeletes` [#1345 / KentarouTakeda](https://github.com/barryvdh/laravel-ide-helper/pull/1345) - Handle PHP 8.1 deprecation warnings when passing `null` to `new \ReflectionClass` [#1351 / mfn](https://github.com/barryvdh/laravel-ide-helper/pull/1351) - Fix model factory method arguments for Laravel >= 9 [#1361 / wimski](https://github.com/barryvdh/laravel-ide-helper/pull/1361) diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 97fa6c0..3d38806 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -1208,7 +1208,7 @@ class ModelsCommand extends Command $traits = class_uses_recursive($model); if (in_array('Illuminate\\Database\\Eloquent\\SoftDeletes', $traits)) { $modelName = $this->getClassNameInDestinationFile($model, get_class($model)); - $builder = $this->getClassNameInDestinationFile($model, \Illuminate\Database\Query\Builder::class); + $builder = $this->getClassNameInDestinationFile($model, \Illuminate\Database\Eloquent\Builder::class); $this->setMethod('withTrashed', $builder . '|' . $modelName, []); $this->setMethod('withoutTrashed', $builder . '|' . $modelName, []); $this->setMethod('onlyTrashed', $builder . '|' . $modelName, []); diff --git a/tests/Console/ModelsCommand/GeneratePhpdocWithForcedFqn/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/GeneratePhpdocWithForcedFqn/__snapshots__/Test__test__1.php index 2733d99..a96e024 100644 --- a/tests/Console/ModelsCommand/GeneratePhpdocWithForcedFqn/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/GeneratePhpdocWithForcedFqn/__snapshots__/Test__test__1.php @@ -89,7 +89,7 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post newQuery() * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post null(string $unusedParam) - * @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post onlyTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post query() * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post whereBigIntegerNotNullable($value) * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post whereBigIntegerNullable($value) @@ -164,8 +164,8 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post whereUuidNullable($value) * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post whereYearNotNullable($value) * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post whereYearNullable($value) - * @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post withTrashed() - * @method static \Illuminate\Database\Query\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post withoutTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post withTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|\Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\GeneratePhpdocWithForcedFqn\Models\Post withoutTrashed() * @mixin \Eloquent */ class Post extends Model diff --git a/tests/Console/ModelsCommand/GeneratePhpdocWithFqn/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/GeneratePhpdocWithFqn/__snapshots__/Test__test__1.php index 453e933..6a5ff8a 100644 --- a/tests/Console/ModelsCommand/GeneratePhpdocWithFqn/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/GeneratePhpdocWithFqn/__snapshots__/Test__test__1.php @@ -95,7 +95,7 @@ use Illuminate\Support\Carbon; * @method static EloquentBuilder|Post newModelQuery() * @method static EloquentBuilder|Post newQuery() * @method static EloquentBuilder|Post null(string $unusedParam) - * @method static QueryBuilder|Post onlyTrashed() + * @method static EloquentBuilder|Post onlyTrashed() * @method static EloquentBuilder|Post query() * @method static EloquentBuilder|Post whereBigIntegerNotNullable($value) * @method static EloquentBuilder|Post whereBigIntegerNullable($value) @@ -170,8 +170,8 @@ use Illuminate\Support\Carbon; * @method static EloquentBuilder|Post whereUuidNullable($value) * @method static EloquentBuilder|Post whereYearNotNullable($value) * @method static EloquentBuilder|Post whereYearNullable($value) - * @method static QueryBuilder|Post withTrashed() - * @method static QueryBuilder|Post withoutTrashed() + * @method static EloquentBuilder|Post withTrashed() + * @method static EloquentBuilder|Post withoutTrashed() * @mixin Eloquent */ class Post extends Model diff --git a/tests/Console/ModelsCommand/SoftDeletes/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/SoftDeletes/__snapshots__/Test__test__1.php index 167fa0c..0409634 100644 --- a/tests/Console/ModelsCommand/SoftDeletes/__snapshots__/Test__test__1.php +++ b/tests/Console/ModelsCommand/SoftDeletes/__snapshots__/Test__test__1.php @@ -13,11 +13,11 @@ use Illuminate\Database\Eloquent\SoftDeletes; * @property integer $id * @method static \Illuminate\Database\Eloquent\Builder|Simple newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery() - * @method static \Illuminate\Database\Query\Builder|Simple onlyTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|Simple onlyTrashed() * @method static \Illuminate\Database\Eloquent\Builder|Simple query() * @method static \Illuminate\Database\Eloquent\Builder|Simple whereId($value) - * @method static \Illuminate\Database\Query\Builder|Simple withTrashed() - * @method static \Illuminate\Database\Query\Builder|Simple withoutTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|Simple withTrashed() + * @method static \Illuminate\Database\Eloquent\Builder|Simple withoutTrashed() * @mixin \Eloquent */ class Simple extends Model