Skip to content

Commit c551adc

Browse files
committed
Merge remote-tracking branch 'origin/1.5.x' into 2.0.x
2 parents bcb88b6 + de811c7 commit c551adc

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

tests/Type/Doctrine/Query/QueryResultTypeWalkerHydrationModeTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PHPStan\Php\PhpVersion;
1212
use PHPStan\Testing\PHPStanTestCase;
1313
use PHPStan\Type\Accessory\AccessoryArrayListType;
14+
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
1415
use PHPStan\Type\Accessory\AccessoryNumericStringType;
1516
use PHPStan\Type\ArrayType;
1617
use PHPStan\Type\Constant\ConstantArrayTypeBuilder;
@@ -306,12 +307,17 @@ private static function list(Type $values): Type
306307
return TypeCombinator::intersect(new ArrayType(new IntegerType(), $values), new AccessoryArrayListType());
307308
}
308309

309-
private static function numericString(): Type
310+
private static function numericString(bool $lowercase = false): Type
310311
{
311-
return new IntersectionType([
312+
$types = [
312313
new StringType(),
313314
new AccessoryNumericStringType(),
314-
]);
315+
];
316+
if ($lowercase) {
317+
$types[] = new AccessoryLowercaseStringType();
318+
}
319+
320+
return new IntersectionType($types);
315321
}
316322

317323
/**

tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PHPStan\Php\PhpVersion;
1616
use PHPStan\Testing\PHPStanTestCase;
1717
use PHPStan\Type\Accessory\AccessoryArrayListType;
18+
use PHPStan\Type\Accessory\AccessoryLowercaseStringType;
1819
use PHPStan\Type\Accessory\AccessoryNumericStringType;
1920
use PHPStan\Type\ArrayType;
2021
use PHPStan\Type\Constant\ConstantArrayTypeBuilder;
@@ -1469,7 +1470,7 @@ public function getTestData(): iterable
14691470
$this->constantArray([
14701471
[new ConstantStringType('minusInt'), $this->stringifies() ? new ConstantStringType('-1') : new ConstantIntegerType(-1)],
14711472
[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)],
14731474
]),
14741475
'
14751476
SELECT -1 as minusInt,
@@ -1587,12 +1588,17 @@ private function constantArray(array $elements): Type
15871588
return $builder->getArray();
15881589
}
15891590

1590-
private function numericString(): Type
1591+
private function numericString(bool $lowercase = false): Type
15911592
{
1592-
return new IntersectionType([
1593+
$types = [
15931594
new StringType(),
15941595
new AccessoryNumericStringType(),
1595-
]);
1596+
];
1597+
if ($lowercase) {
1598+
$types[] = new AccessoryLowercaseStringType();
1599+
}
1600+
1601+
return new IntersectionType($types);
15961602
}
15971603

15981604
private function uint(): Type
@@ -1638,14 +1644,14 @@ private function stringifies(): bool
16381644
private function intOrStringified(): Type
16391645
{
16401646
return $this->stringifies()
1641-
? $this->numericString()
1647+
? $this->numericString(true)
16421648
: new IntegerType();
16431649
}
16441650

16451651
private function uintOrStringified(): Type
16461652
{
16471653
return $this->stringifies()
1648-
? $this->numericString()
1654+
? $this->numericString(true)
16491655
: $this->uint();
16501656
}
16511657

0 commit comments

Comments
 (0)