int-mask-of<Class::*>int-mask-of<Permissions::*> describes every bitwise-or combination of the
matching class constants, a refinement of int, so a @return int-mask-of
value always satisfies a native int parameter. Analyzers that model the
mask reject a value that is not a valid combination; others fall back to
int.
References:
- PHPStan TypeNodeResolver int-mask-of expands the constants to a flag mask| Analyzer | Version | Result | Diagnostics |
|---|---|---|---|
| phan | 6.0.7Phan 6.0.7 php-ast version 1.1.3 PHP version used to run Phan: 8.5.9 | Unrecognized | phpdoc_advanced_fallback_int_mask_of.php:28: Saw a token Phan may have failed to parse after '* @return int-mask-of<Permissions::*>': after int, saw '-' [PhanUnextractableAnnotationSuffix] phpdoc_advanced_fallback_int_mask_of.php:40: Saw possibly unextractable annotation for a fragment of comment '* @param int-mask-of<Permissions::*> $flags': after int, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName] phpdoc_advanced_fallback_int_mask_of.php:40: Saw a token Phan may have failed to parse after '* @param int-mask-of<Permissions::*> $flags': after int, saw '-' [PhanUnextractableAnnotationSuffix]
Notes: Phan cannot parse the `int-mask-of` pseudo-type (the hyphen breaks its annotation tokenizer), so it does not check the mask. |
| phpstan | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced reported Lv.5+ | phpdoc_advanced_fallback_int_mask_of.php:54: Parameter #1 $flags of function Conformance\Tests\PhpdocAdvancedFallbackIntMaskOf\acceptsPermissionMask expects int<0, 7>, 8 given. [identifier=argument.type] [reported-from-level=5] With strict-rulesphpdoc_advanced_fallback_int_mask_of.php:54: Parameter #1 $flags of function Conformance\Tests\PhpdocAdvancedFallbackIntMaskOf\acceptsPermissionMask expects int<0, 7>, 8 given. [identifier=argument.type]
|
| psalm | 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac next: 7.0.0-beta19 |
Enforced (pzoom≠) | phpdoc_advanced_fallback_int_mask_of.php:54: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackIntMaskOf\acceptsPermissionMask expects 0|1|2|3|4|5|6|7, but 8 provided [InvalidArgument] pzoom (Psalm port)No diagnostics from pzoom.
|
| mago | 1.46.0mago 1.46.0 | Enforced | phpdoc_advanced_fallback_int_mask_of.php:54: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackIntMaskOf\acceptsPermissionMask`: expected `int(0)|int(1)|int(2)|int(3)|int(4)|int(5)|int(6)|int(7)`, but found `int(8)`. [invalid-argument]
|
| mir | 0.70.1mir 0.70.1 | Widened to int | No diagnostics reported.
Notes: Does not model `int-mask-of` and falls back to `int`, so it accepts the out-of-range value. |
| phpantom | 0.9.0phpantom_lsp 0.9.0 | Not enforced | No diagnostics reported.
|
| intelephense | 1.18.5intelephense 1.18.5 | Widened to int | No diagnostics reported.
|
| phpy | 0.2.0phpy 0.2.0 | Not enforced | No diagnostics reported.
|
| qodana | 262.8665.325Qodana 262.8665.325 | Not enforced | No diagnostics reported.
|
| noverify | 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 | Widened to int | No diagnostics reported.
Notes: Does not model `int-mask-of` and falls back to `int`, so it accepts the out-of-range value. |
| steins | 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) | Widened to a nonexistent-class reference | No diagnostics reported.
Notes: `int-mask-of<...>` has no entry in `lower_generic`, so it lowers through the catch-all to `ContractTy::Class("int-mask-of")`, and the class-constant mask membership check is never performed. |
| phpstan-strict | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced | phpdoc_advanced_fallback_int_mask_of.php:54: Parameter #1 $flags of function Conformance\Tests\PhpdocAdvancedFallbackIntMaskOf\acceptsPermissionMask expects int<0, 7>, 8 given. [identifier=argument.type]
|
| psalm-next | 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 | Enforced | phpdoc_advanced_fallback_int_mask_of.php:54: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackIntMaskOf\acceptsPermissionMask expects 0|1|2|3|4|5|6|7, but 8 provided [InvalidArgument]
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedFallbackIntMaskOf;
/**
* `int-mask-of<Class::*>`
*
* `int-mask-of<Permissions::*>` describes every bitwise-or combination of the
* matching class constants, a refinement of `int`, so a `@return int-mask-of`
* value always satisfies a native `int` parameter. Analyzers that model the
* mask reject a value that is not a valid combination; others fall back to
* `int`.
*
* References:
* - PHPStan TypeNodeResolver `int-mask-of` expands the constants to a flag mask
*/
final class Permissions
{
public const READ = 1;
public const WRITE = 2;
public const EXECUTE = 4;
}
/**
* @return int-mask-of<Permissions::*>
*/
function returnsPermissionMask() // T: int-mask-of<Permissions::*>
{
return Permissions::READ | Permissions::EXECUTE; // V
}
function acceptsInt(int $value): void
{
}
/**
* @param int-mask-of<Permissions::*> $flags
*/
function acceptsPermissionMask($flags): void // T: int-mask-of<Permissions::*>
{
}
// An `int-mask-of` value always satisfies a native `int` parameter.
acceptsInt(returnsPermissionMask()); // V
// A valid combination of constants satisfies the refined parameter.
acceptsPermissionMask(Permissions::READ | Permissions::WRITE); // V
// A value outside the constant mask: mask-aware analyzers reject it, others
// fall back to `int` and accept it.
acceptsPermissionMask(8); // E?: 8 is not a mask of the Permissions constants