Skip to content

Commit 75f18eb

Browse files
authored
Update phpdoc-types.md
1 parent 1c78fb1 commit 75f18eb

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,24 @@ This is useful if we want to tell that a method from a parent class will return
8686

8787
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.
8888

89+
Variadic functions
90+
-------------------------
91+
92+
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)).
93+
94+
Your code can look like this:
95+
96+
```php
97+
/**
98+
* @param string $arg
99+
* @param string ...$additional
100+
*/
101+
function foo($arg, ...$additional)
102+
{
103+
104+
}
105+
```
106+
89107
Generics
90108
-------------------------
91109

@@ -183,21 +201,3 @@ The `callable` typehint has been in PHP for a long time. But it doesn't allow en
183201
* `callable(float ...$floats): (int|null)` (accepts multiple variadic float arguments, returns integer or null)
184202

185203
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)