← All results

float<0, 1.5>

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

Bounded refinement of float. Bounds are inclusive, and may be integer or float literals (float<min, 100.0>, float<0.5, max>). A @return float<0, 1.5> value always satisfies a native float parameter — analyzers that do not model the range still fall back to float. Range-aware analyzers reject a literal outside the bounds, and treat $n > 1.5 on a value already in the range as always false. References: - https://phpstan.org/writing-php-code/phpdoc-types#float-ranges - PHPStan 2.3.6 (phpstan/phpstan-src#6937)

Analyzer results

AnalyzerVersionResultDiagnostics
phan 6.0.11Phan 6.0.11 php-ast version 1.1.3 PHP version used to run Phan: 8.5.12 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 1/4 of the expected violations reported
phpstan 2.3.7PHPStan - PHP Static Analysis Tool 2.3.7 Enforced reported Lv.4+
phpdoc_advanced_fallback_float_range.php:50: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval expects float<0.0, 1.5>, -0.1 given. [reported-from-level=5]
phpdoc_advanced_fallback_float_range.php:51: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval expects float<0.0, 1.5>, 1.6 given. [reported-from-level=5]
phpdoc_advanced_fallback_float_range.php:58: Comparison operation ">" between float<0.0, 1.5> and 1.5 is always false. [reported-from-level=4]
With strict-rules
phpdoc_advanced_fallback_float_range.php:50: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval expects float<0.0, 1.5>, -0.1 given.
phpdoc_advanced_fallback_float_range.php:51: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval expects float<0.0, 1.5>, 1.6 given.
phpdoc_advanced_fallback_float_range.php:58: Comparison operation ">" between float<0.0, 1.5> and 1.5 is always false.
  • Recognition: spelling resolved
  • Enforcement: 4/4 of the expected violations reported
phpstan-strict 2.3.7PHPStan - PHP Static Analysis Tool 2.3.7 Enforced
phpdoc_advanced_fallback_float_range.php:50: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval expects float<0.0, 1.5>, -0.1 given.
phpdoc_advanced_fallback_float_range.php:51: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval expects float<0.0, 1.5>, 1.6 given.
phpdoc_advanced_fallback_float_range.php:58: Comparison operation ">" between float<0.0, 1.5> and 1.5 is always false.
  • Recognition: spelling resolved
  • Enforcement: 4/4 of the expected violations reported
psalm 6.21.4Psalm 6.21.4@72023213487628df0bc5b2e02d68cbac614b7ef5 Unrecognized (pzoom≠)
phpdoc_advanced_fallback_float_range.php:25: Cannot create generic object with reserved word in docblock for Conformance\Tests\PhpdocAdvancedFallbackFloatRange\returnsUnitInterval [InvalidDocblock]
phpdoc_advanced_fallback_float_range.php:25: Method Conformance\Tests\PhpdocAdvancedFallbackFloatRange\returnsUnitInterval does not have a return type, expecting float(0.75) [MissingReturnType]
phpdoc_advanced_fallback_float_range.php:35: Cannot create generic object with reserved word in docblock for Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval [InvalidDocblock]
phpdoc_advanced_fallback_float_range.php:37: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_float_range.php:42: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsFloat cannot be mixed, expecting float [MixedArgument]
phpdoc_advanced_fallback_float_range.php:54: Cannot create generic object with reserved word in docblock for Conformance\Tests\PhpdocAdvancedFallbackFloatRange\alreadyBounded [InvalidDocblock]
pzoom (Psalm port)

No diagnostics from pzoom.

  • Recognition: spelling not resolved — reported on declaration line(s) 25, 35, 37, 54
  • Enforcement: 1/4 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 42: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackFloatRange\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
psalm 7 7.21.0Psalm 7.21.0@1a665f0114bd40cf12ad57a1a82066549d92f1b6 Unrecognized
phpdoc_advanced_fallback_float_range.php:25: Cannot create generic object with reserved word in docblock for Conformance\Tests\PhpdocAdvancedFallbackFloatRange\returnsUnitInterval [InvalidDocblock]
phpdoc_advanced_fallback_float_range.php:25: Method Conformance\Tests\PhpdocAdvancedFallbackFloatRange\returnsUnitInterval does not have a return type, expecting float(0.75) [MissingReturnType]
phpdoc_advanced_fallback_float_range.php:35: Cannot create generic object with reserved word in docblock for Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval [InvalidDocblock]
phpdoc_advanced_fallback_float_range.php:37: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_float_range.php:42: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsFloat cannot be mixed, expecting float [MixedArgument]
phpdoc_advanced_fallback_float_range.php:54: Cannot create generic object with reserved word in docblock for Conformance\Tests\PhpdocAdvancedFallbackFloatRange\alreadyBounded [InvalidDocblock]
  • Recognition: spelling not resolved — reported on declaration line(s) 25, 35, 37, 54
  • Enforcement: 1/4 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 42: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackFloatRange\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
mago 1.61.0mago 1.61.0 Widened to float

No diagnostics reported.

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

Notes: Mago enforces `int<min, max>` (phpdoc_advanced_fallback_int_range) but is silent on `float<0, 1.5>`: out-of-range literals and the already-bounded `> 1.5` comparison stay quiet.

mir 0.101.0mir 0.101.0 Unrecognized
phpdoc_advanced_fallback_float_range.php:25: UndefinedDocblockClass: Docblock type 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float' does not exist [MIR1505]
phpdoc_advanced_fallback_float_range.php:37: UndefinedDocblockClass: Docblock type 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float' does not exist [MIR1505]
phpdoc_advanced_fallback_float_range.php:45: InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float<0, 1.5>', got '0' [MIR0201]
phpdoc_advanced_fallback_float_range.php:46: InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float<0, 1.5>', got '1.5' [MIR0201]
phpdoc_advanced_fallback_float_range.php:47: InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float<0, 1.5>', got '0.75' [MIR0201]
phpdoc_advanced_fallback_float_range.php:50: InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float<0, 1.5>', got 'float' [MIR0201]
phpdoc_advanced_fallback_float_range.php:51: InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float<0, 1.5>', got '1.6' [MIR0201]
phpdoc_advanced_fallback_float_range.php:56: UndefinedDocblockClass: Docblock type 'Conformance\Tests\PhpdocAdvancedFallbackFloatRange\float' does not exist [MIR1505]
  • Recognition: spelling not resolved — reported on declaration line(s) 25, 37, 56
  • Enforcement: 3/4 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 45: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackFloatRange\\float<0, 1.5>', got '0' [MIR0201]"]
Line 46: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackFloatRange\\float<0, 1.5>', got '1.5' [MIR0201]"]
Line 47: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsUnitInterval() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackFloatRange\\float<0, 1.5>', got '0.75' [MIR0201]"]
phpantom 1.1.0phpantom_lsp 1.1.0 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 1/4 of the expected violations reported
pun 0.4.3pun 0.4.3 Unrecognized
phpdoc_advanced_fallback_float_range.php:25: Function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\returnsUnitInterval() has no return type specified. [missingType.return]
phpdoc_advanced_fallback_float_range.php:25: PHPDoc tag @return contains unresolvable type. [return.unresolvableType]
phpdoc_advanced_fallback_float_range.php:37: Function Conformance\Tests\PhpdocAdvancedFallbackFloatRange\acceptsUnitInterval() has parameter $value with no type specified. [missingType.parameter]
phpdoc_advanced_fallback_float_range.php:37: PHPDoc tag @param for parameter $value contains unresolvable type. [parameter.unresolvableType]
phpdoc_advanced_fallback_float_range.php:56: PHPDoc tag @param for parameter $n contains unresolvable type. [parameter.unresolvableType]
  • Recognition: spelling not resolved — reported on declaration line(s) 25, 37, 56
  • Enforcement: 1/4 of the expected violations reported — incidental, since the spelling was not resolved
intelephense 1.18.5intelephense 1.18.5 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 1/4 of the expected violations reported
phpactor 2026.11.22.0Phpactor 2026.11.22.0 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 1/4 of the expected violations reported
phpy 1.0.19566phpy 1.0.19566 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 1/4 of the expected violations reported
qodana 263.7307.215PhpStorm 263.7307.215 Widened to float

No diagnostics reported.

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

Notes: Qodana enforces `int<0, 255>` via PhpParamsInspection value ranges (phpdoc_advanced_fallback_int_range) but is silent on `float<0, 1.5>`: out-of-range literals and the already-bounded `> 1.5` comparison stay quiet.

noverify 0.5.5NoVerify, version 0.5.5: built on: 2025.04.22 14:36:46 OS: r-kuchinskas arm64 Commit: 4774b82f8adc53fbef38f95e97af4b953b4d1529 Unrecognized
phpdoc_advanced_fallback_float_range.php:56: param $n miss matched with phpdoc type <<float<0, 1.5>>> [funcParamTypeMissMatch]
  • Recognition: spelling not resolved — reported on declaration line(s) 56
  • Enforcement: 1/4 of the expected violations reported — incidental, since the spelling was not resolved
steins 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) Widened to float

No diagnostics reported.

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

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedFallbackFloatRange;

/**
 * `float<0, 1.5>`
 *
 * Bounded refinement of `float`. Bounds are inclusive, and may be integer or
 * float literals (`float<min, 100.0>`, `float<0.5, max>`). A
 * `@return float<0, 1.5>` value always satisfies a native `float` parameter
 * — analyzers that do not model the range still fall back to `float`.
 * Range-aware analyzers reject a literal outside the bounds, and treat
 * `$n > 1.5` on a value already in the range as always false.
 *
 * References:
 * - https://phpstan.org/writing-php-code/phpdoc-types#float-ranges
 * - PHPStan 2.3.6 (phpstan/phpstan-src#6937)
 */

/**
 * @return float<0, 1.5>
 */
function returnsUnitInterval() // T: float<0, 1.5>
{
    return 0.75; // V
}

function acceptsFloat(float $value): void
{
}

/**
 * @param float<0, 1.5> $value
 */
function acceptsUnitInterval($value): void // T: float<0, 1.5>
{
}

// A `float<0, 1.5>` value always satisfies a native `float` parameter.
acceptsFloat(returnsUnitInterval()); // V

// Both inclusive bounds, and a point between them, satisfy the parameter.
acceptsUnitInterval(0.0); // V
acceptsUnitInterval(1.5); // V
acceptsUnitInterval(0.75); // V

// Just outside either bound.
acceptsUnitInterval(-0.1); // E?: -0.1 is below float<0, 1.5>
acceptsUnitInterval(1.6); // E?: 1.6 is above float<0, 1.5>

/**
 * @param float<0, 1.5> $n
 */
function alreadyBounded(float $n): void // T: float<0, 1.5>
{
    if ($n > 1.5) { // E?: the inclusive upper bound makes > 1.5 impossible
        echo 'unreachable';
    }

    if ($n >= 1.5) { // Q: 1.5 is still in the range
        echo 'maybe the bound';
    }
}