Skip to content

Commit 1c78fb1

Browse files
Mistralysondrejmirtes
authored andcommitted
Added syntax for variadic functions.
1 parent 13f753e commit 1c78fb1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

website/src/writing-php-code/phpdoc-types.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,3 +183,21 @@ The `callable` typehint has been in PHP for a long time. But it doesn't allow en
183183
* `callable(float ...$floats): (int|null)` (accepts multiple variadic float arguments, returns integer or null)
184184

185185
Parameter types and return type are required. Use `mixed` if you don't want to use a more specific type.
186+
187+
Variadic functions (variable amount of arguments)
188+
-------------------------
189+
190+
This allows specifying functions or methods which have a variable amount of parameters (available in PHP [since v5.6](https://www.php.net/manual/en/migration56.new-features.php)).
191+
192+
Your code can look like this:
193+
194+
```php
195+
/**
196+
* @param string $arg
197+
* @param string ...$additional
198+
*/
199+
function foo($arg, ...$additional)
200+
{
201+
202+
}
203+
```

0 commit comments

Comments
 (0)