diff --git a/src/Type/Php/CtypeDigitFunctionTypeSpecifyingExtension.php b/src/Type/Php/CtypeDigitFunctionTypeSpecifyingExtension.php index bc44dd244f..562dc20079 100644 --- a/src/Type/Php/CtypeDigitFunctionTypeSpecifyingExtension.php +++ b/src/Type/Php/CtypeDigitFunctionTypeSpecifyingExtension.php @@ -12,7 +12,6 @@ use PHPStan\DependencyInjection\AutowiredService; use PHPStan\Reflection\FunctionReflection; use PHPStan\ShouldNotHappenException; -use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType; use PHPStan\Type\Accessory\AccessoryNumericStringType; use PHPStan\Type\Constant\ConstantBooleanType; use PHPStan\Type\FunctionTypeSpecifyingExtension; @@ -57,7 +56,7 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n if ($context->true()) { $types[] = new IntersectionType([ new StringType(), - new AccessoryDecimalIntegerStringType(), + new AccessoryNumericStringType(), ]); } @@ -69,9 +68,6 @@ public function specifyTypes(FunctionReflection $functionReflection, FuncCall $n new StringType(), new AccessoryNumericStringType(), ]; - if ($context->true()) { - $accessories[] = new AccessoryDecimalIntegerStringType(); - } $castedType = new UnionType([ IntegerRangeType::fromInterval(0, null), new IntersectionType($accessories), diff --git a/tests/PHPStan/Analyser/nsrt/bug-14792.php b/tests/PHPStan/Analyser/nsrt/bug-14792.php new file mode 100644 index 0000000000..bdc7e6b931 --- /dev/null +++ b/tests/PHPStan/Analyser/nsrt/bug-14792.php @@ -0,0 +1,18 @@ +|decimal-int-string|true', $mixed); + assertType('int<0, max>|numeric-string|true', $mixed); } else { assertType('mixed~(int<0, max>|numeric-string|true)', $mixed); } @@ -41,7 +41,7 @@ public function sayHello($mixed, int $int, string $string, $numericString, $nonE assertType('int', $int); if (ctype_digit((string) $string)) { - assertType('decimal-int-string', $string); + assertType('numeric-string', $string); } else { assertType('string', $string); } diff --git a/tests/PHPStan/Analyser/nsrt/ctype-digit.php b/tests/PHPStan/Analyser/nsrt/ctype-digit.php index 29ae49ee95..081b189796 100644 --- a/tests/PHPStan/Analyser/nsrt/ctype-digit.php +++ b/tests/PHPStan/Analyser/nsrt/ctype-digit.php @@ -14,7 +14,7 @@ public function foo(mixed $foo): void assertType('mixed', $foo); if (is_string($foo) && ctype_digit($foo)) { - assertType('decimal-int-string', $foo); + assertType('numeric-string', $foo); } else { assertType('mixed', $foo); } @@ -26,7 +26,7 @@ public function foo(mixed $foo): void } if (ctype_digit($foo)) { - assertType('int<48, 57>|int<256, max>|decimal-int-string', $foo); + assertType('int<48, 57>|int<256, max>|numeric-string', $foo); return; } @@ -36,7 +36,7 @@ public function foo(mixed $foo): void public function doString(string $string): void { if (ctype_digit($string) === true) { - assertType('decimal-int-string', $string); + assertType('numeric-string', $string); } else { assertType('string', $string); } diff --git a/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php b/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php index a87b9eaedd..3129028a6f 100644 --- a/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php +++ b/tests/PHPStan/Rules/Arrays/NonexistentOffsetInArrayDimFetchRuleTest.php @@ -1328,12 +1328,7 @@ public function testBug9240(): void public function testBug14758(): void { - $this->analyse([__DIR__ . '/data/bug-14758.php'], [ - [ - 'Offset decimal-int-string does not exist on array.', - 11, - ], - ]); + $this->analyse([__DIR__ . '/data/bug-14758.php'], []); } #[RequiresPhp('>= 8.4.0')]