Skip to content

Commit

Permalink
Update phpdoc-types.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 10, 2020
1 parent 1c78fb1 commit 75f18eb
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions website/src/writing-php-code/phpdoc-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------

Expand Down Expand Up @@ -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)
{

}
```

0 comments on commit 75f18eb

Please sign in to comment.