Skip to content

Commit

Permalink
Document array shape unsealing syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
robchett committed May 13, 2023
1 parent 2039667 commit f8ebb07
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/annotating_code/type_syntax/array_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ Optional keys can be denoted by a trailing `?`, e.g.:
/** @return array{optional?: string, bar: int} */
```

Defining an array shape seals it, triggering a warning if additional keys are used. To allow additional, generic, keys you can unseal it:

```php
/** @return array{optional?: string, bar: int, ...<string, string>} */
```

Tip: if you find yourself copying the same complex array shape over and over again to avoid `InvalidArgument` issues, try using [type aliases](utility_types.md#type-aliases), instead.

### Validating array shapes
Expand Down

0 comments on commit f8ebb07

Please sign in to comment.