← All results

non-negative-float

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

Floats from zero up, float<0, max>. It differs from positive-float by exactly one value, so zero is what the two spellings are for; -0.1 is the boundary on the other side. Analyzers that model the range reject a negative literal; others fall back to plain float and accept it. 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 Unrecognized
phpdoc_advanced_fallback_non_negative_float.php:21: Saw a token Phan may have failed to parse after '* @return non-negative-float': after non, saw '-' [PhanUnextractableAnnotationSuffix]
phpdoc_advanced_fallback_non_negative_float.php:23: Return type of returnsNonNegativeFloat() is undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non [PhanUndeclaredTypeReturnType]
phpdoc_advanced_fallback_non_negative_float.php:25: Returning 1.5 of type float (value: 1.5) but returnsNonNegativeFloat() is declared to return \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal]
phpdoc_advanced_fallback_non_negative_float.php:33: Saw possibly unextractable annotation for a fragment of comment '* @param non-negative-float $value': after non, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName]
phpdoc_advanced_fallback_non_negative_float.php:33: Saw a token Phan may have failed to parse after '* @param non-negative-float $value': after non, saw '-' [PhanUnextractableAnnotationSuffix]
phpdoc_advanced_fallback_non_negative_float.php:35: Parameter $value has undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non [PhanUndeclaredTypeParameter]
phpdoc_advanced_fallback_non_negative_float.php:40: Argument 1 ($value) is returnsNonNegativeFloat() of type \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non but \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsFloat() takes float defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_negative_float.php:28 [PhanTypeMismatchArgument]
phpdoc_advanced_fallback_non_negative_float.php:44: Argument 1 ($value) is 0.0 of type float (value: 0.0) but \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
phpdoc_advanced_fallback_non_negative_float.php:45: Argument 1 ($value) is 1.5 of type float (value: 1.5) but \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
phpdoc_advanced_fallback_non_negative_float.php:48: Argument 1 ($value) is -0.1 of type float (value: -0.1) but \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
  • Recognition: spelling not resolved — reported on declaration line(s) 21, 23, 33, 35
  • Enforcement: 1/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 25: Expected valid value to be accepted, got ["Returning 1.5 of type float (value: 1.5) but returnsNonNegativeFloat() is declared to return \\Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal]"]
Line 40: Expected valid value to be accepted, got ["Argument 1 ($value) is returnsNonNegativeFloat() of type \\Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsFloat() takes float defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_negative_float.php:28 [PhanTypeMismatchArgument]"]
Line 44: Expected valid value to be accepted, got ["Argument 1 ($value) is 0.0 of type float (value: 0.0) but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsNonNegativeFloat() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"]
Line 45: Expected valid value to be accepted, got ["Argument 1 ($value) is 1.5 of type float (value: 1.5) but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsNonNegativeFloat() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"]
phpstan 2.3.7PHPStan - PHP Static Analysis Tool 2.3.7 Enforced reported Lv.5+
phpdoc_advanced_fallback_non_negative_float.php:48: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat expects float<0.0, max>, -0.1 given. [reported-from-level=5]
With strict-rules
phpdoc_advanced_fallback_non_negative_float.php:48: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat expects float<0.0, max>, -0.1 given.
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
phpstan-strict 2.3.7PHPStan - PHP Static Analysis Tool 2.3.7 Enforced
phpdoc_advanced_fallback_non_negative_float.php:48: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat expects float<0.0, max>, -0.1 given.
  • Recognition: spelling resolved
  • Enforcement: 1/1 of the expected violations reported
psalm 6.21.4Psalm 6.21.4@72023213487628df0bc5b2e02d68cbac614b7ef5 Unrecognized (pzoom≠)
phpdoc_advanced_fallback_non_negative_float.php:23: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_negative_float.php:23: Method Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat does not have a return type, expecting float(1.5) [MissingReturnType]
phpdoc_advanced_fallback_non_negative_float.php:33: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_negative_float.php:35: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_non_negative_float.php:40: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsFloat cannot be mixed, expecting float [MixedArgument]
pzoom (Psalm port)
phpdoc_advanced_fallback_non_negative_float.php:23: Invalid return docblock type [InvalidDocblock]
phpdoc_advanced_fallback_non_negative_float.php:23: Function Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat does not have a return type [MissingReturnType]
phpdoc_advanced_fallback_non_negative_float.php:35: Invalid docblock type [InvalidDocblock]
phpdoc_advanced_fallback_non_negative_float.php:35: Argument $value of Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat does not have a type [MissingParamType]
phpdoc_advanced_fallback_non_negative_float.php:40: Argument 1 of acceptsFloat cannot be mixed, expecting float [MixedArgument]
  • Recognition: spelling not resolved — reported on declaration line(s) 23, 33, 35
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 40: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
psalm 7 7.21.0Psalm 7.21.0@1a665f0114bd40cf12ad57a1a82066549d92f1b6 Unrecognized
phpdoc_advanced_fallback_non_negative_float.php:23: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_negative_float.php:23: Method Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat does not have a return type, expecting float(1.5) [MissingReturnType]
phpdoc_advanced_fallback_non_negative_float.php:33: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_negative_float.php:35: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_non_negative_float.php:40: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsFloat cannot be mixed, expecting float [MixedArgument]
  • Recognition: spelling not resolved — reported on declaration line(s) 23, 33, 35
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 40: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
mago 1.61.0mago 1.61.0 Unrecognized ⚠ 4 false positives
phpdoc_advanced_fallback_non_negative_float.php:22: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float`. [non-existent-class-like]
phpdoc_advanced_fallback_non_negative_float.php:26: Invalid return type for function `Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float)`, but found `float(1.5)`. [invalid-return-statement]
phpdoc_advanced_fallback_non_negative_float.php:34: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float`. [non-existent-class-like]
phpdoc_advanced_fallback_non_negative_float.php:41: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsFloat`: expected `float`, but found `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float)`. [invalid-argument]
phpdoc_advanced_fallback_non_negative_float.php:45: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float)`, but found `float(0.0)`. [invalid-argument]
phpdoc_advanced_fallback_non_negative_float.php:46: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float)`, but found `float(1.5)`. [invalid-argument]
phpdoc_advanced_fallback_non_negative_float.php:49: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float)`, but found `float(-0.1)`. [invalid-argument]
  • Recognition: spelling not resolved — reported on declaration line(s) 22, 34
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
  • False positives: line(s) 26, 41, 46, 49
Expectation diff
Line 45: Expected valid value to be accepted, got ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsNonNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float)`, but found `float(0.0)`. [invalid-argument]"]
Line 26: Unexpected errors ["Invalid return type for function `Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\returnsNonNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float)`, but found `float(1.5)`. [invalid-return-statement]"]
Line 41: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsFloat`: expected `float`, but found `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float)`. [invalid-argument]"]
Line 46: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsNonNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float)`, but found `float(1.5)`. [invalid-argument]"]
Line 49: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsNonNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float)`, but found `float(-0.1)`. [invalid-argument]"]
mir 0.101.0mir 0.101.0 Unrecognized
phpdoc_advanced_fallback_non_negative_float.php:23: UndefinedDocblockClass: Docblock type 'Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float' does not exist [MIR1505]
phpdoc_advanced_fallback_non_negative_float.php:44: InvalidArgument: Argument $value of acceptsNonNegativeFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float', got '0' [MIR0201]
phpdoc_advanced_fallback_non_negative_float.php:45: InvalidArgument: Argument $value of acceptsNonNegativeFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float', got '1.5' [MIR0201]
phpdoc_advanced_fallback_non_negative_float.php:48: InvalidArgument: Argument $value of acceptsNonNegativeFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float', got 'float' [MIR0201]
  • Recognition: spelling not resolved — reported on declaration line(s) 23
  • Enforcement: 1/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 44: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonNegativeFloat() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float', got '0' [MIR0201]"]
Line 45: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonNegativeFloat() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float', got '1.5' [MIR0201]"]
phpantom 1.1.0phpantom_lsp 1.1.0 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
pun 0.4.3pun 0.4.3 Unrecognized
phpdoc_advanced_fallback_non_negative_float.php:23: Function Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat() has no return type specified. [missingType.return]
phpdoc_advanced_fallback_non_negative_float.php:23: PHPDoc tag @return contains unresolvable type. [return.unresolvableType]
phpdoc_advanced_fallback_non_negative_float.php:35: Function Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat() has parameter $value with no type specified. [missingType.parameter]
phpdoc_advanced_fallback_non_negative_float.php:35: PHPDoc tag @param for parameter $value contains unresolvable type. [parameter.unresolvableType]
phpdoc_advanced_fallback_non_negative_float.php:40: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsFloat expects float, Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float given. [argument.type]
  • Recognition: spelling not resolved — reported on declaration line(s) 23, 35
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 40: Expected valid value to be accepted, got ["Parameter #1 $value of function Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsFloat expects float, Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float given. [argument.type]"]
intelephense 1.18.5intelephense 1.18.5 Incidental (0/1)
phpdoc_advanced_fallback_non_negative_float.php:40: Expected type 'float'. Found 'Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float'. [P1006]
  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported — incidental, since values the type admits were also rejected on line(s) 40
Expectation diff
Line 40: Expected valid value to be accepted, got ["Expected type 'float'. Found 'Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float'. [P1006]"]
phpactor 2026.11.22.0Phpactor 2026.11.22.0 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/1 of the expected violations reported
phpy 1.0.19566phpy 1.0.19566 Unrecognized
phpdoc_advanced_fallback_non_negative_float.php:21: Use of unknown class: 'Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float'
phpdoc_advanced_fallback_non_negative_float.php:25: Return value of Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\returnsNonNegativeFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float, float returned
phpdoc_advanced_fallback_non_negative_float.php:33: Use of unknown class: 'Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float'
phpdoc_advanced_fallback_non_negative_float.php:40: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsFloat() is expected to be of type float, Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float given
phpdoc_advanced_fallback_non_negative_float.php:44: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float, float given
phpdoc_advanced_fallback_non_negative_float.php:45: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float, float given
phpdoc_advanced_fallback_non_negative_float.php:48: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\acceptsNonNegativeFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float, float given
  • Recognition: spelling not resolved — reported on declaration line(s) 21, 33
  • Enforcement: 1/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 25: Expected valid value to be accepted, got ["Return value of Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\returnsNonNegativeFloat() is expected to be of type Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float, float returned"]
Line 40: Expected valid value to be accepted, got ["Argument '1' passed to Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsFloat() is expected to be of type float, Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float given"]
Line 44: Expected valid value to be accepted, got ["Argument '1' passed to Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsNonNegativeFloat() is expected to be of type Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float, float given"]
Line 45: Expected valid value to be accepted, got ["Argument '1' passed to Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\acceptsNonNegativeFloat() is expected to be of type Conformance\\Tests\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float, float given"]
qodana 263.7307.215PhpStorm 263.7307.215 Unrecognized
phpdoc_advanced_fallback_non_negative_float.php:21: Return type in PHPDoc does not match the actual return type [PhpReturnDocTypeMismatchInspection]
phpdoc_advanced_fallback_non_negative_float.php:21: Undefined class 'non-negative-float' [PhpUndefinedClassInspection]
phpdoc_advanced_fallback_non_negative_float.php:25: Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection]
phpdoc_advanced_fallback_non_negative_float.php:33: Undefined class 'non-negative-float' [PhpUndefinedClassInspection]
phpdoc_advanced_fallback_non_negative_float.php:44: Parameter '0.0' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_negative_float.php:45: Parameter '1.5' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_negative_float.php:48: Parameter '-0.1' type is not compatible with declaration [PhpParamsInspection]
  • Recognition: spelling not resolved — reported on declaration line(s) 21, 33
  • Enforcement: 1/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 25: Expected valid value to be accepted, got ["Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection]"]
Line 44: Expected valid value to be accepted, got ["Parameter '0.0' type is not compatible with declaration [PhpParamsInspection]"]
Line 45: Expected valid value to be accepted, got ["Parameter '1.5' type is not compatible with declaration [PhpParamsInspection]"]
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_non_negative_float.php:12: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float does not exist [undefinedClass]
phpdoc_advanced_fallback_non_negative_float.php:33: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat\non-negative-float does not exist [undefinedClass]
  • Recognition: spelling not resolved — reported on declaration line(s) 33
  • 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\\PhpdocAdvancedFallbackNonNegativeFloat\\non-negative-float does not exist [undefinedClass]"]
steins 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) Unrecognized
phpdoc_advanced_fallback_non_negative_float.php:21: `non-negative-float` is not type vocabulary — a class name cannot contain `-`, so the name denotes nothing [phpdoc.unknown-vocabulary]
phpdoc_advanced_fallback_non_negative_float.php:33: `non-negative-float` is not type vocabulary — a class name cannot contain `-`, so the name denotes nothing [phpdoc.unknown-vocabulary]
  • Recognition: spelling not resolved — reported on declaration line(s) 21, 33
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedFallbackNonNegativeFloat;

/**
 * `non-negative-float`
 *
 * Floats from zero up, `float<0, max>`. It differs from `positive-float` by
 * exactly one value, so zero is what the two spellings are for; `-0.1` is the
 * boundary on the other side. Analyzers that model the range reject a
 * negative literal; others fall back to plain `float` and accept it.
 *
 * References:
 * - https://phpstan.org/writing-php-code/phpdoc-types#float-ranges
 * - PHPStan 2.3.6 (phpstan/phpstan-src#6937)
 */

/**
 * @return non-negative-float
 */
function returnsNonNegativeFloat() // T: non-negative-float
{
    return 1.5; // V
}

function acceptsFloat(float $value): void
{
}

/**
 * @param non-negative-float $value
 */
function acceptsNonNegativeFloat($value): void // T: non-negative-float
{
}

// A `non-negative-float` value always satisfies a native `float` parameter.
acceptsFloat(returnsNonNegativeFloat()); // V

// Zero is inside the range — this is what separates the spelling from
// `positive-float` — and so is anything above it.
acceptsNonNegativeFloat(0.0); // V
acceptsNonNegativeFloat(1.5); // V

// One past the boundary.
acceptsNonNegativeFloat(-0.1); // E?: -0.1 is not a non-negative-float