|
15 | 15 | use PHPStan\Php\PhpVersion; |
16 | 16 | use PHPStan\Testing\PHPStanTestCase; |
17 | 17 | use PHPStan\Type\Accessory\AccessoryArrayListType; |
| 18 | +use PHPStan\Type\Accessory\AccessoryLowercaseStringType; |
18 | 19 | use PHPStan\Type\Accessory\AccessoryNumericStringType; |
19 | 20 | use PHPStan\Type\ArrayType; |
20 | 21 | use PHPStan\Type\Constant\ConstantArrayTypeBuilder; |
@@ -1474,7 +1475,7 @@ public function getTestData(): iterable |
1474 | 1475 | $this->constantArray([ |
1475 | 1476 | [new ConstantStringType('minusInt'), $this->stringifies() ? new ConstantStringType('-1') : new ConstantIntegerType(-1)], |
1476 | 1477 | [new ConstantStringType('minusFloat'), $this->stringifies() ? $this->numericString() : new ConstantFloatType(-0.1)], |
1477 | | - [new ConstantStringType('minusIntRange'), $this->stringifies() ? $this->numericString() : IntegerRangeType::fromInterval(null, 0)], |
| 1478 | + [new ConstantStringType('minusIntRange'), $this->stringifies() ? $this->numericString(true) : IntegerRangeType::fromInterval(null, 0)], |
1478 | 1479 | ]), |
1479 | 1480 | ' |
1480 | 1481 | SELECT -1 as minusInt, |
@@ -1622,12 +1623,17 @@ private function constantArray(array $elements): Type |
1622 | 1623 | return $builder->getArray(); |
1623 | 1624 | } |
1624 | 1625 |
|
1625 | | - private function numericString(): Type |
| 1626 | + private function numericString(bool $lowercase = false): Type |
1626 | 1627 | { |
1627 | | - return new IntersectionType([ |
| 1628 | + $types = [ |
1628 | 1629 | new StringType(), |
1629 | 1630 | new AccessoryNumericStringType(), |
1630 | | - ]); |
| 1631 | + ]; |
| 1632 | + if ($lowercase) { |
| 1633 | + $types[] = new AccessoryLowercaseStringType(); |
| 1634 | + } |
| 1635 | + |
| 1636 | + return new IntersectionType($types); |
1631 | 1637 | } |
1632 | 1638 |
|
1633 | 1639 | private function uint(): Type |
@@ -1673,14 +1679,14 @@ private function stringifies(): bool |
1673 | 1679 | private function intOrStringified(): Type |
1674 | 1680 | { |
1675 | 1681 | return $this->stringifies() |
1676 | | - ? $this->numericString() |
| 1682 | + ? $this->numericString(true) |
1677 | 1683 | : new IntegerType(); |
1678 | 1684 | } |
1679 | 1685 |
|
1680 | 1686 | private function uintOrStringified(): Type |
1681 | 1687 | { |
1682 | 1688 | return $this->stringifies() |
1683 | | - ? $this->numericString() |
| 1689 | + ? $this->numericString(true) |
1684 | 1690 | : $this->uint(); |
1685 | 1691 | } |
1686 | 1692 |
|
|
0 commit comments