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 ;
@@ -376,7 +377,7 @@ public function getTestData(): iterable
376
377
]),
377
378
$ this ->constantArray ([
378
379
[new ConstantIntegerType (0 ), new ObjectType (One::class)],
379
- [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString ()],
380
+ [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString (true )],
380
381
[new ConstantStringType ('intColumn ' ), new IntegerType ()],
381
382
])
382
383
),
@@ -398,7 +399,7 @@ public function getTestData(): iterable
398
399
]),
399
400
$ this ->constantArray ([
400
401
[new ConstantIntegerType (0 ), new ObjectType (Many::class)],
401
- [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString ()],
402
+ [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString (true )],
402
403
[new ConstantStringType ('intColumn ' ), new IntegerType ()],
403
404
])
404
405
),
@@ -419,7 +420,7 @@ public function getTestData(): iterable
419
420
]),
420
421
$ this ->constantArray ([
421
422
[new ConstantStringType ('one ' ), new ObjectType (One::class)],
422
- [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString ()],
423
+ [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString (true )],
423
424
[new ConstantStringType ('intColumn ' ), new IntegerType ()],
424
425
])
425
426
),
@@ -529,7 +530,7 @@ public function getTestData(): iterable
529
530
yield 'just root entity and scalars ' => [
530
531
$ this ->constantArray ([
531
532
[new ConstantIntegerType (0 ), new ObjectType (One::class)],
532
- [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString ()],
533
+ [new ConstantStringType ('id ' ), $ hasDbal4 ? new IntegerType () : $ this ->numericString (true )],
533
534
]),
534
535
'
535
536
SELECT o, o.id
@@ -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,
@@ -1523,7 +1524,7 @@ private function yieldConditionalDataset(): iterable
1523
1524
],
1524
1525
[
1525
1526
new ConstantIntegerType (3 ),
1526
- $ this ->numericString (),
1527
+ $ this ->numericString (true ),
1527
1528
],
1528
1529
]),
1529
1530
'
@@ -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