|
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;
|
@@ -1469,7 +1470,7 @@ public function getTestData(): iterable
|
1469 | 1470 | $this->constantArray([
|
1470 | 1471 | [new ConstantStringType('minusInt'), $this->stringifies() ? new ConstantStringType('-1') : new ConstantIntegerType(-1)],
|
1471 | 1472 | [new ConstantStringType('minusFloat'), $this->stringifies() ? $this->numericString() : new ConstantFloatType(-0.1)],
|
1472 |
| - [new ConstantStringType('minusIntRange'), $this->stringifies() ? $this->numericString() : IntegerRangeType::fromInterval(null, 0)], |
| 1473 | + [new ConstantStringType('minusIntRange'), $this->stringifies() ? $this->numericString(true) : IntegerRangeType::fromInterval(null, 0)], |
1473 | 1474 | ]),
|
1474 | 1475 | '
|
1475 | 1476 | SELECT -1 as minusInt,
|
@@ -1587,12 +1588,17 @@ private function constantArray(array $elements): Type
|
1587 | 1588 | return $builder->getArray();
|
1588 | 1589 | }
|
1589 | 1590 |
|
1590 |
| - private function numericString(): Type |
| 1591 | + private function numericString(bool $lowercase = false): Type |
1591 | 1592 | {
|
1592 |
| - return new IntersectionType([ |
| 1593 | + $types = [ |
1593 | 1594 | new StringType(),
|
1594 | 1595 | new AccessoryNumericStringType(),
|
1595 |
| - ]); |
| 1596 | + ]; |
| 1597 | + if ($lowercase) { |
| 1598 | + $types[] = new AccessoryLowercaseStringType(); |
| 1599 | + } |
| 1600 | + |
| 1601 | + return new IntersectionType($types); |
1596 | 1602 | }
|
1597 | 1603 |
|
1598 | 1604 | private function uint(): Type
|
@@ -1638,14 +1644,14 @@ private function stringifies(): bool
|
1638 | 1644 | private function intOrStringified(): Type
|
1639 | 1645 | {
|
1640 | 1646 | return $this->stringifies()
|
1641 |
| - ? $this->numericString() |
| 1647 | + ? $this->numericString(true) |
1642 | 1648 | : new IntegerType();
|
1643 | 1649 | }
|
1644 | 1650 |
|
1645 | 1651 | private function uintOrStringified(): Type
|
1646 | 1652 | {
|
1647 | 1653 | return $this->stringifies()
|
1648 |
| - ? $this->numericString() |
| 1654 | + ? $this->numericString(true) |
1649 | 1655 | : $this->uint();
|
1650 | 1656 | }
|
1651 | 1657 |
|
|
0 commit comments