non-decimal-int-stringdecimal-int-string, and wider than the name suggests: it
is every string that stays a string when used as an array key, so '+1',
'00', '18E+3', '1.2' and plain 'foo' all qualify. Only canonical
decimal notation is excluded. Analyzers that model it reject such a literal;
others fall back to plain string and accept it.
References:
- PHPStan TypeNodeResolver non-decimal-int-string resolves to string&AccessoryDecimalIntegerStringType(inverse: true)
- PHPStan AccessoryDecimalIntegerStringType: covers "+1", "00", "18E+3", "1.2", "1,3", "foo"| Analyzer | Version | Result | Diagnostics |
|---|---|---|---|
| phan | 6.0.7Phan 6.0.7 php-ast version 1.1.3 PHP version used to run Phan: 8.5.9 | Unrecognized | phpdoc_advanced_fallback_non_decimal_int_string.php:22: Saw a token Phan may have failed to parse after '* @return non-decimal-int-string': after non, saw '-' [PhanUnextractableAnnotationSuffix] phpdoc_advanced_fallback_non_decimal_int_string.php:24: Return type of returnsNonDecimalIntString() is undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non [PhanUndeclaredTypeReturnType] phpdoc_advanced_fallback_non_decimal_int_string.php:26: Returning '00' of type string but returnsNonDecimalIntString() is declared to return \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non (no real type) (the inferred real return type has nothing in common with the declared phpdoc return type) [PhanTypeMismatchReturnProbablyReal] phpdoc_advanced_fallback_non_decimal_int_string.php:34: Saw possibly unextractable annotation for a fragment of comment '* @param non-decimal-int-string $value': after non, did not see an element name (will guess based on comment order) [PhanUnextractableAnnotationElementName] phpdoc_advanced_fallback_non_decimal_int_string.php:34: Saw a token Phan may have failed to parse after '* @param non-decimal-int-string $value': after non, saw '-' [PhanUnextractableAnnotationSuffix] phpdoc_advanced_fallback_non_decimal_int_string.php:36: Parameter $value has undeclared type \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non [PhanUndeclaredTypeParameter] phpdoc_advanced_fallback_non_decimal_int_string.php:41: Argument 1 ($value) is returnsNonDecimalIntString() of type \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non but \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsString() takes string defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:29 [PhanTypeMismatchArgument] phpdoc_advanced_fallback_non_decimal_int_string.php:45: Argument 1 ($value) is '00' of type string but \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString() takes \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_non_decimal_int_string.php:46: Argument 1 ($value) is '1.2' of type string but \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString() takes \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_non_decimal_int_string.php:47: Argument 1 ($value) is 'foo' of type string but \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString() takes \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_non_decimal_int_string.php:51: Argument 1 ($value) is '123' of type string but \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString() takes \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal] phpdoc_advanced_fallback_non_decimal_int_string.php:52: Argument 1 ($value) is '-1' of type string but \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString() takes \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]
Expectation diffLine 26: Expected valid value to be accepted, got ["Returning '00' of type string but returnsNonDecimalIntString() is declared to return \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\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 returnsNonDecimalIntString() of type \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsString() takes string defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:29 [PhanTypeMismatchArgument]"] Line 45: Expected valid value to be accepted, got ["Argument 1 ($value) is '00' of type string but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsNonDecimalIntString() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.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.2' of type string but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsNonDecimalIntString() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"] Line 47: Expected valid value to be accepted, got ["Argument 1 ($value) is 'foo' of type string but \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsNonDecimalIntString() takes \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non (no real type) defined at /Users/megurine/repo/php/php-typing-conformance/conformance/tests/phpdoc_advanced_fallback_non_decimal_int_string.php:36 (the inferred real argument type has nothing in common with the parameter's phpdoc type) [PhanTypeMismatchArgumentProbablyReal]"] |
| phpstan | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced reported Lv.5+ | phpdoc_advanced_fallback_non_decimal_int_string.php:51: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString expects non-decimal-int-string, '123' given. [identifier=argument.type] [reported-from-level=5] phpdoc_advanced_fallback_non_decimal_int_string.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString expects non-decimal-int-string, '-1' given. [identifier=argument.type] [reported-from-level=5] With strict-rulesphpdoc_advanced_fallback_non_decimal_int_string.php:51: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString expects non-decimal-int-string, '123' given. [identifier=argument.type] phpdoc_advanced_fallback_non_decimal_int_string.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString expects non-decimal-int-string, '-1' given. [identifier=argument.type]
|
| psalm | 6.16.1Psalm 6.16.1@f1f5de594dc76faf8784e02d3dc4716c91c6f6ac next: 7.0.0-beta19 |
Unrecognized (pzoom≠) | phpdoc_advanced_fallback_non_decimal_int_string.php:24: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\returnsNonDecimalIntString [InvalidDocblock] phpdoc_advanced_fallback_non_decimal_int_string.php:24: Method Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\returnsNonDecimalIntString does not have a return type, expecting '00' [MissingReturnType] phpdoc_advanced_fallback_non_decimal_int_string.php:34: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString [InvalidDocblock] phpdoc_advanced_fallback_non_decimal_int_string.php:36: Parameter $value has no provided type [MissingParamType] phpdoc_advanced_fallback_non_decimal_int_string.php:41: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsString cannot be mixed, expecting string [MixedArgument] pzoom (Psalm port)phpdoc_advanced_fallback_non_decimal_int_string.php:24: Invalid return docblock type [InvalidDocblock] phpdoc_advanced_fallback_non_decimal_int_string.php:24: Function Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\returnsNonDecimalIntString does not have a return type [MissingReturnType] phpdoc_advanced_fallback_non_decimal_int_string.php:36: Invalid docblock type [InvalidDocblock] phpdoc_advanced_fallback_non_decimal_int_string.php:36: Argument $value of Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString does not have a type [MissingParamType] phpdoc_advanced_fallback_non_decimal_int_string.php:41: Argument 1 of acceptsString cannot be mixed, expecting string [MixedArgument]
Expectation diffLine 41: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsString cannot be mixed, expecting string [MixedArgument]"] |
| mago | 1.46.0mago 1.46.0 | Unrecognized | phpdoc_advanced_fallback_non_decimal_int_string.php:22: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string`. [non-existent-class-like]
phpdoc_advanced_fallback_non_decimal_int_string.php:26: Invalid return type for function `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\returnsNonDecimalIntString`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string)`, but found `string('00')`. [invalid-return-statement]
phpdoc_advanced_fallback_non_decimal_int_string.php:34: Cannot find class, interface, enum, or type alias `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string`. [non-existent-class-like]
phpdoc_advanced_fallback_non_decimal_int_string.php:41: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsString`: expected `string`, but found `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string)`. [invalid-argument]
phpdoc_advanced_fallback_non_decimal_int_string.php:45: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string)`, but found `string('00')`. [invalid-argument]
phpdoc_advanced_fallback_non_decimal_int_string.php:46: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string)`, but found `string('1.2')`. [invalid-argument]
phpdoc_advanced_fallback_non_decimal_int_string.php:47: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string)`, but found `string('foo')`. [invalid-argument]
phpdoc_advanced_fallback_non_decimal_int_string.php:51: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string)`, but found `string('123')`. [invalid-argument]
phpdoc_advanced_fallback_non_decimal_int_string.php:52: Invalid argument type for argument #1 of `Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string)`, but found `string('-1')`. [invalid-argument]
Expectation diffLine 26: Expected valid value to be accepted, got ["Invalid return type for function `Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\returnsNonDecimalIntString`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string)`, but found `string('00')`. [invalid-return-statement]"]
Line 41: Expected valid value to be accepted, got ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsString`: expected `string`, but found `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string)`. [invalid-argument]"]
Line 45: Expected valid value to be accepted, got ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string)`, but found `string('00')`. [invalid-argument]"]
Line 46: Expected valid value to be accepted, got ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string)`, but found `string('1.2')`. [invalid-argument]"]
Line 47: Expected valid value to be accepted, got ["Invalid argument type for argument #1 of `Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsNonDecimalIntString`: expected `unknown-ref(Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string)`, but found `string('foo')`. [invalid-argument]"] |
| mir | 0.70.1mir 0.70.1 | Incidental (2/2) | phpdoc_advanced_fallback_non_decimal_int_string.php:41: InvalidArgument: Argument $value of acceptsString() expects 'string', got 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string' [MIR0201] phpdoc_advanced_fallback_non_decimal_int_string.php:45: InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string', got '"00"' [MIR0201] phpdoc_advanced_fallback_non_decimal_int_string.php:46: InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string', got '"1.2"' [MIR0201] phpdoc_advanced_fallback_non_decimal_int_string.php:47: InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string', got '"foo"' [MIR0201] phpdoc_advanced_fallback_non_decimal_int_string.php:51: InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string', got '"123"' [MIR0201] phpdoc_advanced_fallback_non_decimal_int_string.php:52: InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string', got '"-1"' [MIR0201]
Expectation diffLine 41: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsString() expects 'string', got 'Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string' [MIR0201]"] Line 45: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string', got '\"00\"' [MIR0201]"] Line 46: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string', got '\"1.2\"' [MIR0201]"] Line 47: Expected valid value to be accepted, got ["InvalidArgument: Argument $value of acceptsNonDecimalIntString() expects 'Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string', got '\"foo\"' [MIR0201]"] |
| phpantom | 0.9.0phpantom_lsp 0.9.0 | Unrecognized | phpdoc_advanced_fallback_non_decimal_int_string.php:22: Class 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string' not found [unknown_class] phpdoc_advanced_fallback_non_decimal_int_string.php:34: Class 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string' not found [unknown_class]
|
| intelephense | 1.18.5intelephense 1.18.5 | Incidental (0/2) | phpdoc_advanced_fallback_non_decimal_int_string.php:41: Expected type 'string'. Found 'Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string'. [P1006]
Expectation diffLine 41: Expected valid value to be accepted, got ["Expected type 'string'. Found 'Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string'. [P1006]"] |
| phpy | 0.2.0phpy 0.2.0 | Not enforced | No diagnostics reported.
|
| qodana | 262.8665.325Qodana 262.8665.325 | Unrecognized | phpdoc_advanced_fallback_non_decimal_int_string.php:22: Return type in PHPDoc does not match the actual return type [PhpReturnDocTypeMismatchInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:22: Undefined class 'non-decimal-int-string' [PhpUndefinedClassInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:26: Return value type is not compatible with declared [PhpIncompatibleReturnTypeInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:34: Undefined class 'non-decimal-int-string' [PhpUndefinedClassInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:45: Parameter ''00'' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:46: Parameter ''1.2'' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:47: Parameter ''foo'' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:51: Parameter ''123'' type is not compatible with declaration [PhpParamsInspection] phpdoc_advanced_fallback_non_decimal_int_string.php:52: Parameter ''-1'' type is not compatible with declaration [PhpParamsInspection]
Expectation diffLine 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 ''00'' type is not compatible with declaration [PhpParamsInspection]"] Line 46: Expected valid value to be accepted, got ["Parameter ''1.2'' type is not compatible with declaration [PhpParamsInspection]"] Line 47: Expected valid value to be accepted, got ["Parameter ''foo'' 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_decimal_int_string.php:12: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string does not exist [undefinedClass] phpdoc_advanced_fallback_non_decimal_int_string.php:34: Class or interface named \Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string does not exist [undefinedClass]
Expectation diffLine 12: Unexpected errors ["Class or interface named \\Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\non-decimal-int-string does not exist [undefinedClass]"] |
| steins | 0.1.5steins 0.1.5 (2026-08-12 revision 39b4cc1) | Enforced | phpdoc_advanced_fallback_non_decimal_int_string.php:51: argument "123" to acceptsNonDecimalIntString() violates declared @param non-decimal-int-string $value — declared contract violation [phpdoc.param-mismatch] phpdoc_advanced_fallback_non_decimal_int_string.php:52: argument "-1" to acceptsNonDecimalIntString() violates declared @param non-decimal-int-string $value — declared contract violation [phpdoc.param-mismatch]
|
| phpstan-strict | 2.2.8PHPStan - PHP Static Analysis Tool 2.2.8 | Enforced | phpdoc_advanced_fallback_non_decimal_int_string.php:51: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString expects non-decimal-int-string, '123' given. [identifier=argument.type] phpdoc_advanced_fallback_non_decimal_int_string.php:52: Parameter #1 $value of function Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString expects non-decimal-int-string, '-1' given. [identifier=argument.type]
|
| psalm-next | 7.0.0-beta19Psalm 7.0.0-beta19@7e751c06a756fa64dc4c759c09fe4a173afcb433 | Unrecognized | phpdoc_advanced_fallback_non_decimal_int_string.php:24: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\returnsNonDecimalIntString [InvalidDocblock] phpdoc_advanced_fallback_non_decimal_int_string.php:24: Method Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\returnsNonDecimalIntString does not have a return type, expecting '00' [MissingReturnType] phpdoc_advanced_fallback_non_decimal_int_string.php:34: Unrecognized type Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\non-decimal-int-string in docblock for Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsNonDecimalIntString [InvalidDocblock] phpdoc_advanced_fallback_non_decimal_int_string.php:36: Parameter $value has no provided type [MissingParamType] phpdoc_advanced_fallback_non_decimal_int_string.php:41: Argument 1 of Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString\acceptsString cannot be mixed, expecting string [MixedArgument]
Expectation diffLine 41: Expected valid value to be accepted, got ["Argument 1 of Conformance\\Tests\\PhpdocAdvancedFallbackNonDecimalIntString\\acceptsString cannot be mixed, expecting string [MixedArgument]"] |
<?php
declare(strict_types=1);
namespace Conformance\Tests\PhpdocAdvancedFallbackNonDecimalIntString;
/**
* `non-decimal-int-string`
*
* The complement of `decimal-int-string`, and wider than the name suggests: it
* is every string that stays a string when used as an array key, so `'+1'`,
* `'00'`, `'18E+3'`, `'1.2'` and plain `'foo'` all qualify. Only canonical
* decimal notation is excluded. Analyzers that model it reject such a literal;
* others fall back to plain `string` and accept it.
*
* References:
* - PHPStan TypeNodeResolver `non-decimal-int-string` resolves to string&AccessoryDecimalIntegerStringType(inverse: true)
* - PHPStan AccessoryDecimalIntegerStringType: covers "+1", "00", "18E+3", "1.2", "1,3", "foo"
*/
/**
* @return non-decimal-int-string
*/
function returnsNonDecimalIntString() // T: non-decimal-int-string
{
return '00'; // V
}
function acceptsString(string $value): void
{
}
/**
* @param non-decimal-int-string $value
*/
function acceptsNonDecimalIntString($value): void // T: non-decimal-int-string
{
}
// A `non-decimal-int-string` value always satisfies a native `string` parameter.
acceptsString(returnsNonDecimalIntString()); // V
// Strings that keep their identity as an array key satisfy the parameter,
// whether or not they look numeric.
acceptsNonDecimalIntString('00'); // V
acceptsNonDecimalIntString('1.2'); // V
acceptsNonDecimalIntString('foo'); // V
// Canonical decimal notation is the one thing excluded: enforcing analyzers
// reject it, others fall back to `string` and accept it.
acceptsNonDecimalIntString('123'); // E?: '123' is cast to int as an array key, so it is a decimal-int-string
acceptsNonDecimalIntString('-1'); // E?: '-1' is cast to int as an array key, so it is a decimal-int-string