Skip to content

Commit 70b5a65

Browse files
Use DecimalIntString over NumericString
1 parent 2f2bd5c commit 70b5a65

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/Type/Constant/ConstantStringType.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use PHPStan\Reflection\TrivialParametersAcceptor;
2020
use PHPStan\ShouldNotHappenException;
2121
use PHPStan\TrinaryLogic;
22+
use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType;
2223
use PHPStan\Type\Accessory\AccessoryLiteralStringType;
2324
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
2425
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
@@ -459,7 +460,9 @@ public function generalize(GeneralizePrecision $precision): Type
459460
new AccessoryLiteralStringType(),
460461
];
461462

462-
if (is_numeric($this->getValue())) {
463+
if ((string) (int) $this->getValue() === $this->getValue()) {
464+
$accessories[] = new AccessoryDecimalIntegerStringType();
465+
} elseif (is_numeric($this->getValue())) {
463466
$accessories[] = new AccessoryNumericStringType();
464467
}
465468

src/Type/IntegerRangeType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
1111
use PHPStan\Reflection\InitializerExprTypeResolver;
1212
use PHPStan\TrinaryLogic;
13+
use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType;
1314
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
1415
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
15-
use PHPStan\Type\Accessory\AccessoryNumericStringType;
1616
use PHPStan\Type\Accessory\AccessoryUppercaseStringType;
1717
use PHPStan\Type\Constant\ConstantBooleanType;
1818
use PHPStan\Type\Constant\ConstantIntegerType;
@@ -509,7 +509,7 @@ public function toString(): Type
509509
new StringType(),
510510
new AccessoryLowercaseStringType(),
511511
new AccessoryUppercaseStringType(),
512-
new AccessoryNumericStringType(),
512+
new AccessoryDecimalIntegerStringType(),
513513
new AccessoryNonFalsyStringType(),
514514
]);
515515
}
@@ -518,7 +518,7 @@ public function toString(): Type
518518
new StringType(),
519519
new AccessoryLowercaseStringType(),
520520
new AccessoryUppercaseStringType(),
521-
new AccessoryNumericStringType(),
521+
new AccessoryDecimalIntegerStringType(),
522522
]);
523523
}
524524

src/Type/IntegerType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
77
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
88
use PHPStan\TrinaryLogic;
9+
use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType;
910
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
10-
use PHPStan\Type\Accessory\AccessoryNumericStringType;
1111
use PHPStan\Type\Accessory\AccessoryUppercaseStringType;
1212
use PHPStan\Type\Constant\ConstantArrayType;
1313
use PHPStan\Type\Constant\ConstantBooleanType;
@@ -78,7 +78,7 @@ public function toString(): Type
7878
new StringType(),
7979
new AccessoryLowercaseStringType(),
8080
new AccessoryUppercaseStringType(),
81-
new AccessoryNumericStringType(),
81+
new AccessoryDecimalIntegerStringType(),
8282
]);
8383
}
8484

0 commit comments

Comments
 (0)