diff --git a/website/src/writing-php-code/phpdoc-types.md b/website/src/writing-php-code/phpdoc-types.md index b631566eaa..1f1d6bef78 100644 --- a/website/src/writing-php-code/phpdoc-types.md +++ b/website/src/writing-php-code/phpdoc-types.md @@ -86,6 +86,24 @@ This is useful if we want to tell that a method from a parent class will return 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 an object of the child class. +Variadic functions +------------------------- + +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)). + +Your code can look like this: + +```php +/** + * @param string $arg + * @param string ...$additional + */ +function foo($arg, ...$additional) +{ + +} +``` + Generics ------------------------- @@ -183,21 +201,3 @@ The `callable` typehint has been in PHP for a long time. But it doesn't allow en * `callable(float ...$floats): (int|null)` (accepts multiple variadic float arguments, returns integer or null) Parameter types and return type are required. Use `mixed` if you don't want to use a more specific type. - -Variadic functions (variable amount of arguments) -------------------------- - -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)). - -Your code can look like this: - -```php -/** - * @param string $arg - * @param string ...$additional - */ -function foo($arg, ...$additional) -{ - -} -```