Skip to content

Commit b2a32a9

Browse files
authored
Update phpdocs-basics.md
1 parent 449812c commit b2a32a9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

website/src/writing-php-code/phpdocs-basics.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,24 @@ public function returnStatic(): self
191191
}
192192
```
193193

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+
194212
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.
195213

196214
Generics

0 commit comments

Comments
 (0)