diff --git a/src/Analyser/MutatingScope.php b/src/Analyser/MutatingScope.php index c3a289ec9b..bbefa0933c 100644 --- a/src/Analyser/MutatingScope.php +++ b/src/Analyser/MutatingScope.php @@ -62,7 +62,6 @@ use PHPStan\TrinaryLogic; use PHPStan\Type\Accessory\AccessoryLiteralStringType; use PHPStan\Type\Accessory\AccessoryNonEmptyStringType; -use PHPStan\Type\Accessory\AccessoryNumericStringType; use PHPStan\Type\Accessory\NonEmptyArrayType; use PHPStan\Type\ArrayType; use PHPStan\Type\BenevolentUnionType; @@ -695,6 +694,8 @@ private function resolveType(Expr $node): Type if ($type->isNonEmptyString()->yes()) { $accessories[] = new AccessoryNonEmptyStringType(); } + // it is not useful to apply numeric and literal strings here. + // numeric string isn't certainly kept numeric: 3v4l.org/JERDB return TypeCombinator::intersect(...$accessories); } diff --git a/tests/PHPStan/Analyser/data/bitwise-not.php b/tests/PHPStan/Analyser/data/bitwise-not.php index a9e406d489..d3ec67530c 100644 --- a/tests/PHPStan/Analyser/data/bitwise-not.php +++ b/tests/PHPStan/Analyser/data/bitwise-not.php @@ -8,7 +8,7 @@ * @param string|int $stringOrInt * @param non-empty-string $nonEmptyString */ -function foo(int $int, string $string, float $float, $stringOrInt, $numericString, $literalString, string $nonEmptyString) : void{ +function foo(int $int, string $string, float $float, $stringOrInt, string $nonEmptyString) : void{ assertType('int', ~$int); assertType('string', ~$string); assertType('non-empty-string', ~$nonEmptyString);