You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/src/writing-php-code/phpdocs-basics.md
+18Lines changed: 18 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -191,6 +191,24 @@ public function returnStatic(): self
191
191
}
192
192
```
193
193
194
+
Variadic functions
195
+
-------------------------
196
+
197
+
This allows specifying functions or methods which have a variable amount of parameters (available since [PHP 5.6](https://www.php.net/manual/en/migration56.new-features.php)).
198
+
199
+
Your code can look like this:
200
+
201
+
```php
202
+
/**
203
+
* @param string $arg
204
+
* @param string ...$additional
205
+
*/
206
+
function foo($arg, ...$additional)
207
+
{
208
+
209
+
}
210
+
```
211
+
194
212
A narrower `@return $this` instead of `@return static` can also be used, and PHPStan will check if you're really returning the same object instance and not just the child class.
0 commit comments