← All results

int-mask<1, 2, 4>

Group: Advanced PHPDoc types · Category: ecosystem · File: phpdoc_advanced_fallback_int_mask.php

int-mask<1, 2, 4> describes every bitwise-or combination of the flags (0..7), a refinement of int, so a @return int-mask<...> 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 expands to the union of flag combinations

Analyzer results

AnalyzerVersionResultDiagnostics
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.php:20: Saw a token Phan may have failed to parse after '* @return int-mask<1, 2, 4>': after int, saw '-' [PhanUnextractableAnnotationSuffix]
phpdoc_advanced_fallback_int_mask.php:32: Saw possibly unextractable annotation for a fragment of comment '* @param int-mask<1, 2, 4> $flags': after int, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName]
phpdoc_advanced_fallback_int_mask.php:32: Saw a token Phan may have failed to parse after '* @param int-mask<1, 2, 4> $flags': after int, saw '-' [PhanUnextractableAnnotationSuffix]
  • Recognition: spelling not resolved — reported on declaration line(s) 20, 32
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved

Notes: Phan cannot parse the `int-mask` 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.php:46: Parameter #1 $flags of function Conformance\Tests\PhpdocAdvancedFallbackIntMask\acceptsFlags expects int<0, 7>, 8 given. [identifier=argument.type] [reported-from-level=5]
With strict-rules
phpdoc_advanced_fallback_int_mask.php:46: Parameter #1 $flags of function Conformance\Tests\PhpdocAdvancedFallbackIntMask\acceptsFlags expects int<0, 7>, 8 given. [identifier=argument.type]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
psalm 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac
next: 7.0.0-beta19
Enforced
phpdoc_advanced_fallback_int_mask.php:46: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackIntMask\acceptsFlags expects 0|1|2|3|4|5|6|7, but 8 provided [InvalidArgument]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
mago 1.46.0mago 1.46.0 Enforced
phpdoc_advanced_fallback_int_mask.php:46: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackIntMask\acceptsFlags`: expected `int(0)|int(1)|int(2)|int(3)|int(4)|int(5)|int(6)|int(7)`, but found `int(8)`. [invalid-argument]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
mir 0.70.1mir 0.70.1 Enforced
phpdoc_advanced_fallback_int_mask.php:46: InvalidArgument: Argument $flags of acceptsFlags() expects '0|1|2|3|4|5|6|7', got '8' [MIR0201]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
phpantom 0.9.0phpantom_lsp 0.9.0 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
intelephense 1.18.5intelephense 1.18.5 Widened to int

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
phpy 0.2.0phpy 0.2.0 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
qodana 262.8665.325Qodana 262.8665.325 Not enforced

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
noverify 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 Unrecognized ⚠ 1 false positive
phpdoc_advanced_fallback_int_mask.php:12: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackIntMask\int-mask does not exist [undefinedClass]
phpdoc_advanced_fallback_int_mask.php:32: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackIntMask\int-mask does not exist [undefinedClass]
  • Recognition: spelling not resolved — reported on declaration line(s) 32
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
  • False positives: line(s) 12
Expectation diff
Line 12: Unexpected errors ["Class or interface named \\Conformance\\Tests\\PhpdocAdvancedFallbackIntMask\\int-mask does not exist [undefinedClass]"]

Notes: NoVerify treats `int-mask` as an undefined class rather than a flag-mask type.

steins 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) Widened to a nonexistent-class reference

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported

Notes: `int-mask<...>` has no entry in `lower_generic`'s vocabulary table (steins-contract/src/lib.rs), so it lowers through the catch-all to `ContractTy::Class("int-mask")` rather than any int refinement, and the bit-set membership is never checked.

phpstan-strict 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 Enforced
phpdoc_advanced_fallback_int_mask.php:46: Parameter #1 $flags of function Conformance\Tests\PhpdocAdvancedFallbackIntMask\acceptsFlags expects int<0, 7>, 8 given. [identifier=argument.type]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
psalm-next 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 Enforced
phpdoc_advanced_fallback_int_mask.php:46: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackIntMask\acceptsFlags expects 0|1|2|3|4|5|6|7, but 8 provided [InvalidArgument]
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedFallbackIntMask;

/**
 * `int-mask<1, 2, 4>`
 *
 * `int-mask<1, 2, 4>` describes every bitwise-or combination of the flags
 * (0..7), a refinement of `int`, so a `@return int-mask<...>` 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` expands to the union of flag combinations
 */

/**
 * @return int-mask<1, 2, 4>
 */
function returnsFlags() // T: int-mask<1, 2, 4>
{
    return 1 | 4; // V
}

function acceptsInt(int $value): void
{
}

/**
 * @param int-mask<1, 2, 4> $flags
 */
function acceptsFlags($flags): void // T: int-mask<1, 2, 4>
{
}

// An `int-mask` value always satisfies a native `int` parameter.
acceptsInt(returnsFlags()); // V

// A valid combination (1 | 4 = 5) satisfies the refined parameter.
acceptsFlags(1 | 4); // V

// A value outside the mask combinations: mask-aware analyzers reject it, others
// fall back to `int` and accept it.
acceptsFlags(8); // E?: 8 is not a combination of the int-mask<1, 2, 4> flags