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/phpdoc-types.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,24 @@ This is useful if we want to tell that a method from a parent class will return
86
86
87
87
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.
88
88
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
+
89
107
Generics
90
108
-------------------------
91
109
@@ -183,21 +201,3 @@ The `callable` typehint has been in PHP for a long time. But it doesn't allow en
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)).
0 commit comments