diff --git a/CHANGELOG.md b/CHANGELOG.md index 248b88a..0be42ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ All notable changes to this project will be documented in this file. ### Fixed - Use platformName to determine db type when casting boolean types [\#1212 / stockalexander](https://github.com/barryvdh/laravel-ide-helper/pull/1212) +### Added +- Add support of variadic parameters in `ide-helper:models` [\#1234 / shaffe-fr](https://github.com/barryvdh/laravel-ide-helper/pull/1234) + 2021-04-09, 2.10.0 ------------------ ### Added diff --git a/README.md b/README.md index c227fe7..91906c9 100644 --- a/README.md +++ b/README.md @@ -166,6 +166,7 @@ php artisan ide-helper:models "App\Models\Post" * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post newQuery() * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post query() * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post whereTitle($value) + * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post forAuthors(\User ...$authors) * … */ ``` diff --git a/src/Console/ModelsCommand.php b/src/Console/ModelsCommand.php index 3f3cd31..57b8fea 100644 --- a/src/Console/ModelsCommand.php +++ b/src/Console/ModelsCommand.php @@ -935,7 +935,8 @@ class ModelsCommand extends Command $paramsWithDefault = []; /** @var \ReflectionParameter $param */ foreach ($method->getParameters() as $param) { - $paramStr = '$' . $param->getName(); + $paramStr = $param->isVariadic() ? '...$' . $param->getName() : '$' . $param->getName(); + if ($paramType = $this->getParamType($method, $param)) { $paramStr = $paramType . ' ' . $paramStr; } diff --git a/tests/Console/ModelsCommand/Variadic/Models/Simple.php b/tests/Console/ModelsCommand/Variadic/Models/Simple.php new file mode 100644 index 0000000..7932295 --- /dev/null +++ b/tests/Console/ModelsCommand/Variadic/Models/Simple.php @@ -0,0 +1,20 @@ +app->make(ModelsCommand::class); + + $tester = $this->runCommand($command, [ + '--write' => true, + ]); + + $this->assertSame(0, $tester->getStatusCode()); + $this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay()); + $this->assertMatchesMockedSnapshot(); + } +} diff --git a/tests/Console/ModelsCommand/Variadic/__snapshots__/Test__test__1.php b/tests/Console/ModelsCommand/Variadic/__snapshots__/Test__test__1.php new file mode 100644 index 0000000..80d773a --- /dev/null +++ b/tests/Console/ModelsCommand/Variadic/__snapshots__/Test__test__1.php @@ -0,0 +1,32 @@ +