File tree Expand file tree Collapse file tree 6 files changed +82
-1
lines changed
tests/Console/ModelsCommand/Variadic Expand file tree Collapse file tree 6 files changed +82
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ All notable changes to this project will be documented in this file.
10
10
### Fixed
11
11
- Use platformName to determine db type when casting boolean types [ \# 1212 / stockalexander] ( https://github.com/barryvdh/laravel-ide-helper/pull/1212 )
12
12
13
+ ### Added
14
+ - Add support of variadic parameters in ` ide-helper:models ` [ \# 1234 / shaffe-fr] ( https://github.com/barryvdh/laravel-ide-helper/pull/1234 )
15
+
13
16
2021-04-09, 2.10.0
14
17
------------------
15
18
### Added
Original file line number Diff line number Diff line change @@ -166,6 +166,7 @@ php artisan ide-helper:models "App\Models\Post"
166
166
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post newQuery()
167
167
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post query()
168
168
* @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post whereTitle($value)
169
+ * @method static \Illuminate\Database\Eloquent\Builder|\App\Models\Post forAuthors(\User ...$authors)
169
170
* …
170
171
*/
171
172
```
Original file line number Diff line number Diff line change @@ -935,7 +935,8 @@ public function getParameters($method)
935
935
$ paramsWithDefault = [];
936
936
/** @var \ReflectionParameter $param */
937
937
foreach ($ method ->getParameters () as $ param ) {
938
- $ paramStr = '$ ' . $ param ->getName ();
938
+ $ paramStr = $ param ->isVariadic () ? '...$ ' . $ param ->getName () : '$ ' . $ param ->getName ();
939
+
939
940
if ($ paramType = $ this ->getParamType ($ method , $ param )) {
940
941
$ paramStr = $ paramType . ' ' . $ paramStr ;
941
942
}
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Barryvdh \LaravelIdeHelper \Tests \Console \ModelsCommand \Variadic \Models ;
6
+
7
+ use DateTime ;
8
+ use Illuminate \Database \Eloquent \Builder ;
9
+ use Illuminate \Database \Eloquent \Model ;
10
+
11
+ class Simple extends Model
12
+ {
13
+ public function scopeWhereVariadic (Builder $ query , ...$ values ): void
14
+ {
15
+ }
16
+
17
+ public function scopeWhereTypedVariadic (Builder $ query , int ...$ values ): void
18
+ {
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Barryvdh \LaravelIdeHelper \Tests \Console \ModelsCommand \Variadic ;
6
+
7
+ use Barryvdh \LaravelIdeHelper \Console \ModelsCommand ;
8
+ use Barryvdh \LaravelIdeHelper \Tests \Console \ModelsCommand \AbstractModelsCommand ;
9
+
10
+ class Test extends AbstractModelsCommand
11
+ {
12
+ public function test (): void
13
+ {
14
+ $ command = $ this ->app ->make (ModelsCommand::class);
15
+
16
+ $ tester = $ this ->runCommand ($ command , [
17
+ '--write ' => true ,
18
+ ]);
19
+
20
+ $ this ->assertSame (0 , $ tester ->getStatusCode ());
21
+ $ this ->assertStringContainsString ('Written new phpDocBlock to ' , $ tester ->getDisplay ());
22
+ $ this ->assertMatchesMockedSnapshot ();
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Barryvdh \LaravelIdeHelper \Tests \Console \ModelsCommand \Variadic \Models ;
6
+
7
+ use DateTime ;
8
+ use Illuminate \Database \Eloquent \Builder ;
9
+ use Illuminate \Database \Eloquent \Model ;
10
+
11
+ /**
12
+ * Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand\Variadic\Models\Simple
13
+ *
14
+ * @property integer $id
15
+ * @method static Builder|Simple newModelQuery()
16
+ * @method static Builder|Simple newQuery()
17
+ * @method static Builder|Simple query()
18
+ * @method static Builder|Simple whereId($value)
19
+ * @method static Builder|Simple whereTypedVariadic(int ...$values)
20
+ * @method static Builder|Simple whereVariadic(...$values)
21
+ * @mixin \Eloquent
22
+ */
23
+ class Simple extends Model
24
+ {
25
+ public function scopeWhereVariadic (Builder $ query , ...$ values ): void
26
+ {
27
+ }
28
+
29
+ public function scopeWhereTypedVariadic (Builder $ query , int ...$ values ): void
30
+ {
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments