Skip to content

Commit

Permalink
Merge pull request #9252 from bitwise-operators/documentation/value-o…
Browse files Browse the repository at this point in the history
…f-backedenum
  • Loading branch information
weirdan committed Feb 9, 2023
2 parents 7ae8f9f + 9f07f5f commit 9c6dfb8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/annotating_code/type_syntax/utility_types.md
Expand Up @@ -51,6 +51,13 @@ Some examples:
- `value-of<string[]>` evaluates to `string`
- `value-of<T>` evaluates to the template param's value-type (ensure `@template T of array`)

### Use with enumerations

In addition to array-types, `value-of` can also be used to specify an `int` or `string` that contains one of the possible values of a `BackedEnum`:

- `value-of<Suit>` evaluates to `'H'|'D'|'C'|'S'` (see [Backed enumerations](https://www.php.net/manual/en/language.enumerations.backed.php))
- `value-of<BinaryDigits>` evaluates to `0|1`

### Notes on template usage

If you use `value-of` with a template param, you can fulfill the type check only with these allowed methods:
Expand Down

0 comments on commit 9c6dfb8

Please sign in to comment.