Skip to content

Commit

Permalink
Document advanced array shape unsealing syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
robchett committed May 14, 2023
1 parent 2039667 commit f491a53
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/annotating_code/type_syntax/array_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ $options['verbose'] = isset($options['verbose']);
handleOptions($options);
```

`...` is a shorthand for `...<array-key, mixed>` you can use other array generic types to provide more information about the open shape.

```php
// This is an open array
/** @param array{someKey: string, ...} */
// Which is the same as
/** @param array{someKey: string, ...<array-key, mixed>} */
// But it can be further locked down with a shape ...<TKey, TValue>
/** @return array{someKey: string, ...<int, bool>} */
```

## Callable arrays

An array holding a callable, like PHP's native `call_user_func()` and friends supports it:
Expand Down

0 comments on commit f491a53

Please sign in to comment.