int<0, 255>int<min, max> is a bounded refinement of int, so a @return int<0, 255>
value always satisfies a native int parameter — analyzers that do not model
the range still fall back to int. Range-aware analyzers additionally reject
a literal outside the bounds.
References:
- PHPStan TypeNodeResolver int<min, max> resolves to IntegerRangeType| 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 | Widened to int | No diagnostics reported.
Notes: Does not model the integer range and falls back to `int`, so it accepts the out-of-range value. The range-aware analyzers reject it. |
| phpstan | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced reported Lv.5+ | phpdoc_advanced_fallback_int_range.php:46: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackIntRange\acceptsByte expects int<0, 255>, 256 given. [identifier=argument.type] [reported-from-level=5] With strict-rulesphpdoc_advanced_fallback_int_range.php:46: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackIntRange\acceptsByte expects int<0, 255>, 256 given. [identifier=argument.type]
|
| psalm | 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac next: 7.0.0-beta19 |
Enforced | phpdoc_advanced_fallback_int_range.php:46: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackIntRange\acceptsByte expects int<0, 255>, but 256 provided [InvalidArgument]
|
| mago | 1.46.0mago 1.46.0 | Enforced | phpdoc_advanced_fallback_int_range.php:46: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackIntRange\acceptsByte`: expected `int<0, 255>`, but found `int(256)`. [invalid-argument]
|
| mir | 0.70.1mir 0.70.1 | Enforced | phpdoc_advanced_fallback_int_range.php:46: InvalidArgument: Argument $value of acceptsByte() expects 'int<0, 255>', got '256' [MIR0201]
|
| phpantom | 0.9.0phpantom_lsp 0.9.0 | Enforced | phpdoc_advanced_fallback_int_range.php:46: Argument 1 ($value) expects int<0..255>, got 256 [type_mismatch_argument]
|
| 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 | Enforced | phpdoc_advanced_fallback_int_range.php:46: Value ranges mismatch. Expected: <0, 255>, Actual: <256, 256> [PhpParamsInspection]
|
| 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 the integer range and falls back to `int`, so it accepts the out-of-range value. The range-aware analyzers reject it. |
| steins | 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) | Enforced | phpdoc_advanced_fallback_int_range.php:46: argument 256 to acceptsByte() violates declared @param int<0, 255> $value — declared contract violation [phpdoc.param-mismatch]
|
| phpstan-strict | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced | phpdoc_advanced_fallback_int_range.php:46: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackIntRange\acceptsByte expects int<0, 255>, 256 given. [identifier=argument.type]
|
| psalm-next | 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 | Enforced | phpdoc_advanced_fallback_int_range.php:46: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackIntRange\acceptsByte expects int<0, 255>, but 256 provided [InvalidArgument]
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedFallbackIntRange;
/**
* `int<0, 255>`
*
* `int<min, max>` is a bounded refinement of `int`, so a `@return int<0, 255>`
* value always satisfies a native `int` parameter — analyzers that do not model
* the range still fall back to `int`. Range-aware analyzers additionally reject
* a literal outside the bounds.
*
* References:
* - PHPStan TypeNodeResolver `int<min, max>` resolves to IntegerRangeType
*/
/**
* @return int<0, 255>
*/
function returnsByte() // T: int<0, 255>
{
return 200; // V
}
function acceptsInt(int $value): void
{
}
/**
* @param int<0, 255> $value
*/
function acceptsByte($value): void // T: int<0, 255>
{
}
// An `int<0, 255>` value always satisfies a native `int` parameter.
acceptsInt(returnsByte()); // V
// An in-range literal satisfies the refined parameter.
acceptsByte(200); // V
// An out-of-range literal: range-aware analyzers reject it, others fall back to
// `int` and accept it.
acceptsByte(256); // E?: 256 is above the int<0, 255> range