Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document array shape unsealing syntax #9784

Merged
merged 1 commit into from
May 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/annotating_code/type_syntax/array_types.md
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