Skip to content

Commit

Permalink
Reduce big int type from string to numeric-string
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Dec 9, 2022
1 parent 964caf8 commit ca91db8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Type/Doctrine/Descriptors/BigIntType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/Type/Doctrine/Query/QueryResultTypeWalkerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
])
),
Expand All @@ -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()],
])
),
Expand All @@ -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()],
])
),
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ca91db8

Please sign in to comment.