Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Type/Constant/ConstantStringType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use PHPStan\Reflection\TrivialParametersAcceptor;
use PHPStan\ShouldNotHappenException;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType;
use PHPStan\Type\Accessory\AccessoryLiteralStringType;
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
use PHPStan\Type\Accessory\AccessoryNonEmptyStringType;
Expand Down Expand Up @@ -459,7 +460,9 @@ public function generalize(GeneralizePrecision $precision): Type
new AccessoryLiteralStringType(),
];

if (is_numeric($this->getValue())) {
if ((string) (int) $this->getValue() === $this->getValue()) {
$accessories[] = new AccessoryDecimalIntegerStringType();
} elseif (is_numeric($this->getValue())) {
$accessories[] = new AccessoryNumericStringType();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Type/IntegerRangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Reflection\InitializerExprTypeResolver;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType;
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
use PHPStan\Type\Accessory\AccessoryNonFalsyStringType;
use PHPStan\Type\Accessory\AccessoryNumericStringType;
use PHPStan\Type\Accessory\AccessoryUppercaseStringType;
use PHPStan\Type\Constant\ConstantBooleanType;
use PHPStan\Type\Constant\ConstantIntegerType;
Expand Down Expand Up @@ -509,7 +509,7 @@ public function toString(): Type
new StringType(),
new AccessoryLowercaseStringType(),
new AccessoryUppercaseStringType(),
new AccessoryNumericStringType(),
new AccessoryDecimalIntegerStringType(),
new AccessoryNonFalsyStringType(),
]);
}
Expand All @@ -518,7 +518,7 @@ public function toString(): Type
new StringType(),
new AccessoryLowercaseStringType(),
new AccessoryUppercaseStringType(),
new AccessoryNumericStringType(),
new AccessoryDecimalIntegerStringType(),
]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Type/IntegerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\TrinaryLogic;
use PHPStan\Type\Accessory\AccessoryDecimalIntegerStringType;
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
use PHPStan\Type\Accessory\AccessoryNumericStringType;
use PHPStan\Type\Accessory\AccessoryUppercaseStringType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Constant\ConstantBooleanType;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function toString(): Type
new StringType(),
new AccessoryLowercaseStringType(),
new AccessoryUppercaseStringType(),
new AccessoryNumericStringType(),
new AccessoryDecimalIntegerStringType(),
]);
}

Expand Down
Loading