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

Add documentation for int masks #6983

Merged
merged 2 commits into from Apr 26, 2022
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 website/src/writing-php-code/phpdoc-types.md
Expand Up @@ -298,3 +298,14 @@ All of these names are equivalent:
* `no-return`

Marking a function or a method as `@return never` tells PHPStan the function always throws an exception, or contains a way to end the script execution, like `die()` or `exit()`. This is useful when [solving undefined variables](/writing-php-code/solving-undefined-variables).

Integer masks
-------------------------

<div class="text-xs inline-block border border-green-600 text-green-600 bg-green-100 rounded px-1 mb-4">Available in PHPStan 1.6.0</div>

Some functions accept a bitmask composed by `|`-ing different integer values. `0` is always part of the possible values. Some examples:

* `int-mask<1, 2, 4>` (accepts values that can be composed using `|` from the given integers, and 0)
* `int-mask-of<1|2|4>` (the same as above, but writting as a union)
* `int-mask-of<Foo::INT_*>` (accepts values from all constants on `Foo` that start with `INT_`)