1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 13:51:54 +01:00

Merge pull request #9252 from bitwise-operators/documentation/value-of-backedenum

This commit is contained in:
Bruce Weirdan 2023-02-09 04:11:45 -04:00 committed by GitHub
commit 9c6dfb8e56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,13 @@ Some examples:
- `value-of<string[]>` evaluates to `string` - `value-of<string[]>` evaluates to `string`
- `value-of<T>` evaluates to the template param's value-type (ensure `@template T of array`) - `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 ### Notes on template usage
If you use `value-of` with a template param, you can fulfill the type check only with these allowed methods: If you use `value-of` with a template param, you can fulfill the type check only with these allowed methods: