← All results

negative-float

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

Floats strictly less than zero. Zero is the interesting probe: it is neither positive nor negative. -INF is less than zero, so it satisfies this spelling. Analyzers that model the range reject 0.0; 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_negative_float.php:21: Saw a token Phan may have failed to parse after '* @return negative-float': after negative, saw '-' [PhanUnextractableAnnotationSuffix]
phpdoc_advanced_fallback_negative_float.php:23: Return type of returnsNegativeFloat() is undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative [PhanUndeclaredTypeReturnType]
phpdoc_advanced_fallback_negative_float.php:25: Returning -1.5 of type float (value: -1.5) but returnsNegativeFloat() is declared to return \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal]
phpdoc_advanced_fallback_negative_float.php:33: Saw possibly unextractable annotation for a fragment of comment '* @param negative-float $value': after negative, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName]
phpdoc_advanced_fallback_negative_float.php:33: Saw a token Phan may have failed to parse after '* @param negative-float $value': after negative, saw '-' [PhanUnextractableAnnotationSuffix]
phpdoc_advanced_fallback_negative_float.php:35: Parameter $value has undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative [PhanUndeclaredTypeParameter]
phpdoc_advanced_fallback_negative_float.php:40: Argument 1 ($value) is returnsNegativeFloat() of type \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative but \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsFloat() takes float defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_float.php:28 [PhanTypeMismatchArgument]
phpdoc_advanced_fallback_negative_float.php:43: Argument 1 ($value) is -1.5 of type float (value: -1.5) but \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
phpdoc_advanced_fallback_negative_float.php:46: Argument 1 ($value) is -INF of type float but \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
phpdoc_advanced_fallback_negative_float.php:49: Argument 1 ($value) is 0.0 of type float (value: 0.0) but \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
phpdoc_advanced_fallback_negative_float.php:52: Argument 1 ($value) is 1.5 of type float (value: 1.5) but \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_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: 2/2 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 returnsNegativeFloat() is declared to return \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative (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 returnsNegativeFloat() of type \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative but \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsFloat() takes float defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_float.php:28 [PhanTypeMismatchArgument]"]
Line 43: Expected valid value to be accepted, got ["Argument 1 ($value) is -1.5 of type float (value: -1.5) but \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsNegativeFloat() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_negative_float.php:35 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"]
Line 46: Expected valid value to be accepted, got ["Argument 1 ($value) is -INF of type float but \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsNegativeFloat() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_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_negative_float.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat expects float<min, -5.0E-324>, 0.0 given. [reported-from-level=5]
phpdoc_advanced_fallback_negative_float.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat expects float<min, -5.0E-324>, 1.5 given. [reported-from-level=5]
With strict-rules
phpdoc_advanced_fallback_negative_float.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat expects float<min, -5.0E-324>, 0.0 given.
phpdoc_advanced_fallback_negative_float.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat expects float<min, -5.0E-324>, 1.5 given.
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
phpstan-strict 2.3.7PHPStan - PHP Static Analysis Tool 2.3.7 Enforced
phpdoc_advanced_fallback_negative_float.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat expects float<min, -5.0E-324>, 0.0 given.
phpdoc_advanced_fallback_negative_float.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat expects float<min, -5.0E-324>, 1.5 given.
  • Recognition: spelling resolved
  • Enforcement: 2/2 of the expected violations reported
psalm 6.21.4Psalm 6.21.4@72023213487628df0bc5b2e02d68cbac614b7ef5 Unrecognized (pzoom≠)
phpdoc_advanced_fallback_negative_float.php:23: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\returnsNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_negative_float.php:23: Method Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\returnsNegativeFloat does not have a return type, expecting float(-1.5) [MissingReturnType]
phpdoc_advanced_fallback_negative_float.php:33: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_negative_float.php:35: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_negative_float.php:40: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsFloat cannot be mixed, expecting float [MixedArgument]
pzoom (Psalm port)
phpdoc_advanced_fallback_negative_float.php:23: Invalid return docblock type [InvalidDocblock]
phpdoc_advanced_fallback_negative_float.php:23: Function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\returnsNegativeFloat does not have a return type [MissingReturnType]
phpdoc_advanced_fallback_negative_float.php:35: Invalid docblock type [InvalidDocblock]
phpdoc_advanced_fallback_negative_float.php:35: Argument $value of Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat does not have a type [MissingParamType]
phpdoc_advanced_fallback_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/2 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\\PhpdocAdvancedFallbackNegativeFloat\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
psalm 7 7.21.0Psalm 7.21.0@1a665f0114bd40cf12ad57a1a82066549d92f1b6 Unrecognized
phpdoc_advanced_fallback_negative_float.php:23: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\returnsNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_negative_float.php:23: Method Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\returnsNegativeFloat does not have a return type, expecting float(-1.5) [MissingReturnType]
phpdoc_advanced_fallback_negative_float.php:33: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat [InvalidDocblock]
phpdoc_advanced_fallback_negative_float.php:35: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_negative_float.php:40: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsFloat cannot be mixed, expecting float [MixedArgument]
  • Recognition: spelling not resolved — reported on declaration line(s) 23, 33, 35
  • Enforcement: 0/2 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\\PhpdocAdvancedFallbackNegativeFloat\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
mago 1.61.0mago 1.61.0 Unrecognized ⚠ 6 false positives
phpdoc_advanced_fallback_negative_float.php:22: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float`. [non-existent-class-like]
phpdoc_advanced_fallback_negative_float.php:26: Invalid return type for function `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\returnsNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float)`, but found `float(-1.5)`. [invalid-return-statement]
phpdoc_advanced_fallback_negative_float.php:34: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float`. [non-existent-class-like]
phpdoc_advanced_fallback_negative_float.php:41: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsFloat`: expected `float`, but found `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float)`. [invalid-argument]
phpdoc_advanced_fallback_negative_float.php:44: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float)`, but found `float(-1.5)`. [invalid-argument]
phpdoc_advanced_fallback_negative_float.php:47: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float)`, but found `float`. [invalid-argument]
phpdoc_advanced_fallback_negative_float.php:50: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float)`, but found `float(0.0)`. [invalid-argument]
phpdoc_advanced_fallback_negative_float.php:53: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float)`, but found `float(1.5)`. [invalid-argument]
  • Recognition: spelling not resolved — reported on declaration line(s) 22, 34
  • Enforcement: 0/2 of the expected violations reported — incidental, since the spelling was not resolved
  • False positives: line(s) 26, 41, 44, 47, 50, 53
Expectation diff
Line 26: Unexpected errors ["Invalid return type for function `Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\returnsNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float)`, but found `float(-1.5)`. [invalid-return-statement]"]
Line 41: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsFloat`: expected `float`, but found `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float)`. [invalid-argument]"]
Line 44: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float)`, but found `float(-1.5)`. [invalid-argument]"]
Line 47: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float)`, but found `float`. [invalid-argument]"]
Line 50: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float)`, but found `float(0.0)`. [invalid-argument]"]
Line 53: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\acceptsNegativeFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float)`, but found `float(1.5)`. [invalid-argument]"]
mir 0.101.0mir 0.101.0 Unrecognized
phpdoc_advanced_fallback_negative_float.php:23: UndefinedDocblockClass: Docblock type 'Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float' does not exist [MIR1505]
phpdoc_advanced_fallback_negative_float.php:43: InvalidArgument: Argument $value of acceptsNegativeFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float', got 'float' [MIR0201]
phpdoc_advanced_fallback_negative_float.php:46: MixedArgument: Argument $value of acceptsNegativeFloat() is mixed [MIR1200]
phpdoc_advanced_fallback_negative_float.php:49: InvalidArgument: Argument $value of acceptsNegativeFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float', got '0' [MIR0201]
phpdoc_advanced_fallback_negative_float.php:52: InvalidArgument: Argument $value of acceptsNegativeFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float', got '1.5' [MIR0201]
  • Recognition: spelling not resolved — reported on declaration line(s) 23
  • Enforcement: 2/2 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 43: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNegativeFloat() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float', got 'float' [MIR0201]"]
Line 46: Expected valid value to be accepted, got ["MixedArgument: Argument $value of acceptsNegativeFloat() is mixed [MIR1200]"]
phpantom 1.1.0phpantom_lsp 1.1.0 Widened to float

No diagnostics reported.

  • Recognition: spelling resolved
  • Enforcement: 0/2 of the expected violations reported
pun 0.4.3pun 0.4.3 Unrecognized
phpdoc_advanced_fallback_negative_float.php:23: Function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\returnsNegativeFloat() has no return type specified. [missingType.return]
phpdoc_advanced_fallback_negative_float.php:23: PHPDoc tag @return contains unresolvable type. [return.unresolvableType]
phpdoc_advanced_fallback_negative_float.php:35: Function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsNegativeFloat() has parameter $value with no type specified. [missingType.parameter]
phpdoc_advanced_fallback_negative_float.php:35: PHPDoc tag @param for parameter $value contains unresolvable type. [parameter.unresolvableType]
phpdoc_advanced_fallback_negative_float.php:40: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\acceptsFloat expects float, Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float given. [argument.type]
  • Recognition: spelling not resolved — reported on declaration line(s) 23, 35
  • Enforcement: 0/2 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\\PhpdocAdvancedFallbackNegativeFloat\\acceptsFloat expects float, Conformance\\Tests\\PhpdocAdvancedFallbackNegativeFloat\\negative-float given. [argument.type]"]
intelephense 1.18.5intelephense 1.18.5 Incidental (0/2)
phpdoc_advanced_fallback_negative_float.php:40: Expected type 'float'. Found 'Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat\negative-float'. [P1006]
  • Recognition: spelling resolved
  • Enforcement: 0/2 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\\PhpdocAdvancedFallbackNegativeFloat\\negative-float'. [P1006]"]
phpactor 2026.11.22.0Phpactor 2026.11.22.0 Widened to float

No diagnostics reported.

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

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedFallbackNegativeFloat;

/**
 * `negative-float`
 *
 * Floats strictly less than zero. Zero is the interesting probe: it is
 * neither positive nor negative. `-INF` is less than zero, so it satisfies
 * this spelling. Analyzers that model the range reject `0.0`; 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 negative-float
 */
function returnsNegativeFloat() // T: negative-float
{
    return -1.5; // V
}

function acceptsFloat(float $value): void
{
}

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

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

// A literal less than zero satisfies the refined parameter.
acceptsNegativeFloat(-1.5); // V

// -INF is less than zero.
acceptsNegativeFloat(-INF); // V

// Zero sits just outside it.
acceptsNegativeFloat(0.0); // E?: 0.0 is not a negative-float

// A positive literal is plainly outside it.
acceptsNegativeFloat(1.5); // E?: 1.5 is not a negative-float