negative-intint<min, -1>. Zero is the interesting probe: it is
neither positive nor negative, and an analyzer that reads the name as "not
positive" lets it through. Analyzers that model the range reject it; others
fall back to plain int and accept it.
References:
- PHPStan TypeNodeResolver negative-int resolves to IntegerRangeType::fromInterval(null, -1)| Analyzer | Version | Result | Diagnostics |
|---|---|---|---|
| phan | 6.0.10Phan 6.0.10 php-ast version 1.1.3 PHP version used to run Phan: 8.5.11 | Enforced | phpdoc_advanced_fallback_negative_int.php:45: Argument 1 ($value) is 0 of type int (value: 0) but \Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt() takes negative-int defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_int.php:34 [PhanTypeMismatchArgument] phpdoc_advanced_fallback_negative_int.php:48: Argument 1 ($value) is 5 of type int (value: 5) but \Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt() takes negative-int defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_int.php:34 [PhanTypeMismatchArgument]
|
| phpstan | 2.3.1PHPStan - PHP Static Analysis Tool 2.3.1 | Enforced reported Lv.5+ | phpdoc_advanced_fallback_negative_int.php:45: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, 0 given. [reported-from-level=5] phpdoc_advanced_fallback_negative_int.php:48: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, 5 given. [reported-from-level=5] With strict-rulesphpdoc_advanced_fallback_negative_int.php:45: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, 0 given. phpdoc_advanced_fallback_negative_int.php:48: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, 5 given.
|
| psalm | 6.20.0Psalm 6.20.0@804f03c0c183d149fcd4b8c7c0c9b3fbf836d34c next: 7.0.0-rc2 |
Enforced | phpdoc_advanced_fallback_negative_int.php:45: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, but 0 provided [InvalidArgument] phpdoc_advanced_fallback_negative_int.php:48: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, but 5 provided [InvalidArgument]
|
| mago | 1.57.0mago 1.57.0 | Enforced | phpdoc_advanced_fallback_negative_int.php:45: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt`: expected `negative-int`, but found `int(0)`. [invalid-argument] phpdoc_advanced_fallback_negative_int.php:48: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt`: expected `negative-int`, but found `int(5)`. [invalid-argument]
|
| mir | 0.87.0mir 0.87.0 | Enforced | phpdoc_advanced_fallback_negative_int.php:45: InvalidArgument: Argument $value of acceptsNegativeInt() expects 'negative-int', got '0' [MIR0201] phpdoc_advanced_fallback_negative_int.php:48: InvalidArgument: Argument $value of acceptsNegativeInt() expects 'negative-int', got '5' [MIR0201]
|
| phpantom | 0.11.1phpantom_lsp 0.11.1 | Enforced | phpdoc_advanced_fallback_negative_int.php:45: Argument 1 ($value) expects negative-int, got 0 [type_mismatch_argument] phpdoc_advanced_fallback_negative_int.php:48: Argument 1 ($value) expects negative-int, got 5 [type_mismatch_argument]
|
| intelephense | 1.18.5intelephense 1.18.5 | Widened to int | No diagnostics reported.
|
| phpactor | 2026.10.07.0Phpactor 2026.10.07.0 | Not enforced | No diagnostics reported.
|
| phpy | 1.0.19409phpy 1.0.19409 | Not enforced | No diagnostics reported.
|
| qodana | 262.10968.76PhpStorm 262.10968.76 | Widened to int | No diagnostics reported.
Notes: Checked as plain `int`: a wrong type is reported as "Expected parameter of type 'int'", and `0` and `5` pass, exactly as for `@param int`. Quick Documentation still shows `negative-int`, so the spelling is recognised and only the refinement is dropped. |
| 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_negative_int.php:12: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\negative-int does not exist [undefinedClass] phpdoc_advanced_fallback_negative_int.php:32: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\negative-int does not exist [undefinedClass]
Expectation diffLine 12: Unexpected errors ["Class or interface named \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeInt\\negative-int does not exist [undefinedClass]"] |
| steins | 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) | Enforced | phpdoc_advanced_fallback_negative_int.php:45: argument 0 to acceptsNegativeInt() violates declared @param negative-int $value — declared contract violation [phpdoc.param-mismatch] phpdoc_advanced_fallback_negative_int.php:48: argument 5 to acceptsNegativeInt() violates declared @param negative-int $value — declared contract violation [phpdoc.param-mismatch]
|
| phpstan-strict | 2.3.1PHPStan - PHP Static Analysis Tool 2.3.1 | Enforced | phpdoc_advanced_fallback_negative_int.php:45: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, 0 given. phpdoc_advanced_fallback_negative_int.php:48: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, 5 given.
|
| psalm-next | 7.0.0-rc2Psalm 7.0.0-rc2@20339e3fe5b8d03bcd8061030eb2a83ad50e5783 | Enforced | phpdoc_advanced_fallback_negative_int.php:45: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, but 0 provided [InvalidArgument] phpdoc_advanced_fallback_negative_int.php:48: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNegativeInt\acceptsNegativeInt expects int<min, -1>, but 5 provided [InvalidArgument]
|
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedFallbackNegativeInt;
/**
* `negative-int`
*
* The integers below zero, `int<min, -1>`. Zero is the interesting probe: it is
* neither positive nor negative, and an analyzer that reads the name as "not
* positive" lets it through. Analyzers that model the range reject it; others
* fall back to plain `int` and accept it.
*
* References:
* - PHPStan TypeNodeResolver `negative-int` resolves to IntegerRangeType::fromInterval(null, -1)
*/
/**
* @return negative-int
*/
function returnsNegativeInt() // T: negative-int
{
return -5; // V
}
function acceptsInt(int $value): void
{
}
/**
* @param negative-int $value
*/
function acceptsNegativeInt($value): void // T: negative-int
{
}
// A `negative-int` value always satisfies a native `int` parameter.
acceptsInt(returnsNegativeInt()); // V
// The upper bound of the range satisfies the parameter.
acceptsNegativeInt(-1); // V
// Zero sits just outside it.
acceptsNegativeInt(0); // E?: 0 is not a negative-int
// And a positive literal is plainly outside it.
acceptsNegativeInt(5); // E?: 5 is not a negative-int