From ca91db819b9615230676a6ea0e19558cfaa33093 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Fri, 9 Dec 2022 13:16:43 +0100 Subject: [PATCH] Reduce big int type from string to numeric-string --- src/Type/Doctrine/Descriptors/BigIntType.php | 3 ++- tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Type/Doctrine/Descriptors/BigIntType.php b/src/Type/Doctrine/Descriptors/BigIntType.php index 71a3a811..213bf17b 100644 --- a/src/Type/Doctrine/Descriptors/BigIntType.php +++ b/src/Type/Doctrine/Descriptors/BigIntType.php @@ -2,6 +2,7 @@ namespace PHPStan\Type\Doctrine\Descriptors; +use PHPStan\Type\Accessory\AccessoryNumericStringType; use PHPStan\Type\IntegerType; use PHPStan\Type\StringType; use PHPStan\Type\Type; @@ -17,7 +18,7 @@ public function getType(): string public function getWritableToPropertyType(): Type { - return new StringType(); + return TypeCombinator::intersect(new StringType(), new AccessoryNumericStringType()); } public function getWritableToDatabaseType(): Type diff --git a/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php b/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php index a6b59762..499a0732 100644 --- a/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php +++ b/tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php @@ -349,7 +349,7 @@ public function getTestData(): iterable ]), $this->constantArray([ [new ConstantIntegerType(0), new ObjectType(One::class)], - [new ConstantStringType('id'), new StringType()], + [new ConstantStringType('id'), $this->numericString()], [new ConstantStringType('intColumn'), new IntegerType()], ]) ), @@ -371,7 +371,7 @@ public function getTestData(): iterable ]), $this->constantArray([ [new ConstantIntegerType(0), new ObjectType(Many::class)], - [new ConstantStringType('id'), new StringType()], + [new ConstantStringType('id'), $this->numericString()], [new ConstantStringType('intColumn'), new IntegerType()], ]) ), @@ -392,7 +392,7 @@ public function getTestData(): iterable ]), $this->constantArray([ [new ConstantStringType('one'), new ObjectType(One::class)], - [new ConstantStringType('id'), new StringType()], + [new ConstantStringType('id'), $this->numericString()], [new ConstantStringType('intColumn'), new IntegerType()], ]) ), @@ -502,7 +502,7 @@ public function getTestData(): iterable yield 'just root entity and scalars' => [ $this->constantArray([ [new ConstantIntegerType(0), new ObjectType(One::class)], - [new ConstantStringType('id'), new StringType()], + [new ConstantStringType('id'), $this->numericString()], ]), ' SELECT o, o.id