← All results

non-positive-float

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

Floats up to and including zero, float<min, 0>. It differs from negative-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 positive 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_positive_float.php:22: Saw a token Phan may have failed to parse after '* @return non-positive-float': after non, saw '-' [PhanUnextractableAnnotationSuffix]
phpdoc_advanced_fallback_non_positive_float.php:24: Return type of returnsNonPositiveFloat() is undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non [PhanUndeclaredTypeReturnType]
phpdoc_advanced_fallback_non_positive_float.php:26: Returning -1.5 of type float (value: -1.5) but returnsNonPositiveFloat() is declared to return \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal]
phpdoc_advanced_fallback_non_positive_float.php:34: Saw possibly unextractable annotation for a fragment of comment '* @param non-positive-float $value': after non, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName]
phpdoc_advanced_fallback_non_positive_float.php:34: Saw a token Phan may have failed to parse after '* @param non-positive-float $value': after non, saw '-' [PhanUnextractableAnnotationSuffix]
phpdoc_advanced_fallback_non_positive_float.php:36: Parameter $value has undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non [PhanUndeclaredTypeParameter]
phpdoc_advanced_fallback_non_positive_float.php:41: Argument 1 ($value) is returnsNonPositiveFloat() of type \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non but \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsFloat() takes float defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_positive_float.php:29 [PhanTypeMismatchArgument]
phpdoc_advanced_fallback_non_positive_float.php:45: Argument 1 ($value) is 0.0 of type float (value: 0.0) but \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_positive_float.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
phpdoc_advanced_fallback_non_positive_float.php:46: Argument 1 ($value) is -1.5 of type float (value: -1.5) but \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_positive_float.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
phpdoc_advanced_fallback_non_positive_float.php:49: Argument 1 ($value) is 0.1 of type float (value: 0.1) but \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat() takes \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_positive_float.php:36 (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) 22, 24, 34, 36
  • Enforcement: 1/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 26: Expected valid value to be accepted, got ["Returning -1.5 of type float (value: -1.5) but returnsNonPositiveFloat() is declared to return \\Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal]"]
Line 41: Expected valid value to be accepted, got ["Argument 1 ($value) is returnsNonPositiveFloat() of type \\Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsFloat() takes float defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_positive_float.php:29 [PhanTypeMismatchArgument]"]
Line 45: Expected valid value to be accepted, got ["Argument 1 ($value) is 0.0 of type float (value: 0.0) but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsNonPositiveFloat() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_positive_float.php:36 (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 -1.5 of type float (value: -1.5) but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsNonPositiveFloat() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_positive_float.php:36 (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_positive_float.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat expects float<min, 0.0>, 0.1 given. [reported-from-level=5]
With strict-rules
phpdoc_advanced_fallback_non_positive_float.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat expects float<min, 0.0>, 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_positive_float.php:49: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat expects float<min, 0.0>, 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_positive_float.php:24: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_positive_float.php:24: Method Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat does not have a return type, expecting float(-1.5) [MissingReturnType]
phpdoc_advanced_fallback_non_positive_float.php:34: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_positive_float.php:36: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_non_positive_float.php:41: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsFloat cannot be mixed, expecting float [MixedArgument]
pzoom (Psalm port)
phpdoc_advanced_fallback_non_positive_float.php:24: Invalid return docblock type [InvalidDocblock]
phpdoc_advanced_fallback_non_positive_float.php:24: Function Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat does not have a return type [MissingReturnType]
phpdoc_advanced_fallback_non_positive_float.php:36: Invalid docblock type [InvalidDocblock]
phpdoc_advanced_fallback_non_positive_float.php:36: Argument $value of Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat does not have a type [MissingParamType]
phpdoc_advanced_fallback_non_positive_float.php:41: Argument 1 of acceptsFloat cannot be mixed, expecting float [MixedArgument]
  • Recognition: spelling not resolved — reported on declaration line(s) 24, 34, 36
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 41: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
psalm 7 7.21.0Psalm 7.21.0@1a665f0114bd40cf12ad57a1a82066549d92f1b6 Unrecognized
phpdoc_advanced_fallback_non_positive_float.php:24: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_positive_float.php:24: Method Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat does not have a return type, expecting float(-1.5) [MissingReturnType]
phpdoc_advanced_fallback_non_positive_float.php:34: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat [InvalidDocblock]
phpdoc_advanced_fallback_non_positive_float.php:36: Parameter $value has no provided type [MissingParamType]
phpdoc_advanced_fallback_non_positive_float.php:41: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsFloat cannot be mixed, expecting float [MixedArgument]
  • Recognition: spelling not resolved — reported on declaration line(s) 24, 34, 36
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 41: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsFloat cannot be mixed, expecting float [MixedArgument]"]
mago 1.61.0mago 1.61.0 Unrecognized ⚠ 4 false positives
phpdoc_advanced_fallback_non_positive_float.php:23: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float`. [non-existent-class-like]
phpdoc_advanced_fallback_non_positive_float.php:27: Invalid return type for function `Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float)`, but found `float(-1.5)`. [invalid-return-statement]
phpdoc_advanced_fallback_non_positive_float.php:35: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float`. [non-existent-class-like]
phpdoc_advanced_fallback_non_positive_float.php:42: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsFloat`: expected `float`, but found `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float)`. [invalid-argument]
phpdoc_advanced_fallback_non_positive_float.php:46: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float)`, but found `float(0.0)`. [invalid-argument]
phpdoc_advanced_fallback_non_positive_float.php:47: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float)`, but found `float(-1.5)`. [invalid-argument]
phpdoc_advanced_fallback_non_positive_float.php:50: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float)`, but found `float(0.1)`. [invalid-argument]
  • 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
  • False positives: line(s) 27, 42, 47, 50
Expectation diff
Line 46: Expected valid value to be accepted, got ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsNonPositiveFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float)`, but found `float(0.0)`. [invalid-argument]"]
Line 27: Unexpected errors ["Invalid return type for function `Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\returnsNonPositiveFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float)`, but found `float(-1.5)`. [invalid-return-statement]"]
Line 42: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsFloat`: expected `float`, but found `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float)`. [invalid-argument]"]
Line 47: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsNonPositiveFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float)`, but found `float(-1.5)`. [invalid-argument]"]
Line 50: Unexpected errors ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsNonPositiveFloat`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float)`, but found `float(0.1)`. [invalid-argument]"]
mir 0.101.0mir 0.101.0 Unrecognized
phpdoc_advanced_fallback_non_positive_float.php:24: UndefinedDocblockClass: Docblock type 'Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float' does not exist [MIR1505]
phpdoc_advanced_fallback_non_positive_float.php:45: InvalidArgument: Argument $value of acceptsNonPositiveFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float', got '0' [MIR0201]
phpdoc_advanced_fallback_non_positive_float.php:46: InvalidArgument: Argument $value of acceptsNonPositiveFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float', got 'float' [MIR0201]
phpdoc_advanced_fallback_non_positive_float.php:49: InvalidArgument: Argument $value of acceptsNonPositiveFloat() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float', got '0.1' [MIR0201]
  • Recognition: spelling not resolved — reported on declaration line(s) 24
  • Enforcement: 1/1 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 acceptsNonPositiveFloat() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float', got '0' [MIR0201]"]
Line 46: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonPositiveFloat() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float', got 'float' [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_positive_float.php:24: Function Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat() has no return type specified. [missingType.return]
phpdoc_advanced_fallback_non_positive_float.php:24: PHPDoc tag @return contains unresolvable type. [return.unresolvableType]
phpdoc_advanced_fallback_non_positive_float.php:36: Function Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat() has parameter $value with no type specified. [missingType.parameter]
phpdoc_advanced_fallback_non_positive_float.php:36: PHPDoc tag @param for parameter $value contains unresolvable type. [parameter.unresolvableType]
phpdoc_advanced_fallback_non_positive_float.php:41: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsFloat expects float, Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float given. [argument.type]
  • Recognition: spelling not resolved — reported on declaration line(s) 24, 36
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 41: Expected valid value to be accepted, got ["Parameter #1 $value of function Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsFloat expects float, Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float given. [argument.type]"]
intelephense 1.18.5intelephense 1.18.5 Incidental (0/1)
phpdoc_advanced_fallback_non_positive_float.php:41: Expected type 'float'. Found 'Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-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) 41
Expectation diff
Line 41: Expected valid value to be accepted, got ["Expected type 'float'. Found 'Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-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_positive_float.php:22: Use of unknown class: 'Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float'
phpdoc_advanced_fallback_non_positive_float.php:26: Return value of Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\returnsNonPositiveFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float, float returned
phpdoc_advanced_fallback_non_positive_float.php:34: Use of unknown class: 'Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float'
phpdoc_advanced_fallback_non_positive_float.php:41: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsFloat() is expected to be of type float, Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float given
phpdoc_advanced_fallback_non_positive_float.php:45: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float, float given
phpdoc_advanced_fallback_non_positive_float.php:46: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float, float given
phpdoc_advanced_fallback_non_positive_float.php:49: Argument '1' passed to Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\acceptsNonPositiveFloat() is expected to be of type Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float, float given
  • Recognition: spelling not resolved — reported on declaration line(s) 22, 34
  • Enforcement: 1/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 26: Expected valid value to be accepted, got ["Return value of Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\returnsNonPositiveFloat() is expected to be of type Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float, float returned"]
Line 41: Expected valid value to be accepted, got ["Argument '1' passed to Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsFloat() is expected to be of type float, Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float given"]
Line 45: Expected valid value to be accepted, got ["Argument '1' passed to Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsNonPositiveFloat() is expected to be of type Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float, float given"]
Line 46: Expected valid value to be accepted, got ["Argument '1' passed to Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\acceptsNonPositiveFloat() is expected to be of type Conformance\\Tests\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float, float given"]
qodana 263.7307.215PhpStorm 263.7307.215 Unrecognized
phpdoc_advanced_fallback_non_positive_float.php:22: Return type in PHPDoc does not match the actual return type [PhpReturnDocTypeMismatchInspection]
phpdoc_advanced_fallback_non_positive_float.php:22: Undefined class 'non-positive-float' [PhpUndefinedClassInspection]
phpdoc_advanced_fallback_non_positive_float.php:26: Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection]
phpdoc_advanced_fallback_non_positive_float.php:34: Undefined class 'non-positive-float' [PhpUndefinedClassInspection]
phpdoc_advanced_fallback_non_positive_float.php:45: Parameter '0.0' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_positive_float.php:46: Parameter '-1.5' type is not compatible with declaration [PhpParamsInspection]
phpdoc_advanced_fallback_non_positive_float.php:49: Parameter '0.1' type is not compatible with declaration [PhpParamsInspection]
  • Recognition: spelling not resolved — reported on declaration line(s) 22, 34
  • Enforcement: 1/1 of the expected violations reported — incidental, since the spelling was not resolved
Expectation diff
Line 26: Expected valid value to be accepted, got ["Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection]"]
Line 45: Expected valid value to be accepted, got ["Parameter '0.0' type is not compatible with declaration [PhpParamsInspection]"]
Line 46: 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_positive_float.php:12: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float does not exist [undefinedClass]
phpdoc_advanced_fallback_non_positive_float.php:34: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat\non-positive-float does not exist [undefinedClass]
  • Recognition: spelling not resolved — reported on declaration line(s) 34
  • 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\\PhpdocAdvancedFallbackNonPositiveFloat\\non-positive-float does not exist [undefinedClass]"]
steins 0.1.8steins 0.1.8 (2026-09-21 revision 76306a9) Unrecognized
phpdoc_advanced_fallback_non_positive_float.php:22: `non-positive-float` is not type vocabulary — a class name cannot contain `-`, so the name denotes nothing [phpdoc.unknown-vocabulary]
phpdoc_advanced_fallback_non_positive_float.php:34: `non-positive-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) 22, 34
  • Enforcement: 0/1 of the expected violations reported — incidental, since the spelling was not resolved

Source

<?php

declare(strict_types=1);

namespace Conformance\Tests\PhpdocAdvancedFallbackNonPositiveFloat;

/**
 * `non-positive-float`
 *
 * Floats up to and including zero, `float<min, 0>`. It differs from
 * `negative-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 positive 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-positive-float
 */
function returnsNonPositiveFloat() // T: non-positive-float
{
    return -1.5; // V
}

function acceptsFloat(float $value): void
{
}

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

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

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

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