Skip to content

Commit 2d645ef

Browse files
bug symfony#58371 [PropertyInfo] Fix bigint extraction with type info (mtarld)
This PR was merged into the 7.1 branch. Discussion ---------- [PropertyInfo] Fix bigint extraction with type info | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT During an upmerge, an issue has been made, indeed: ```php return [ new Type(Type::BUILTIN_TYPE_INT, $nullable), new Type(Type::BUILTIN_TYPE_STRING, $nullable), ]; ``` must be considered as an union and not a collection (ie: `Type::union` instead of `Type::collection`) Commits ------- 4ce5d8e [PropertyInfo] Fix bigint extraction with type info
2 parents f42d8b4 + 4ce5d8e commit 2d645ef

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function getType(string $class, string $property, array $context = []): ?
133133

134134
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
135135
if (Types::BIGINT === $typeOfField && !method_exists(BigIntType::class, 'getName')) {
136-
return Type::collection(Type::int(), Type::string());
136+
return $nullable ? Type::nullable(Type::union(Type::int(), Type::string())) : Type::union(Type::int(), Type::string());
137137
}
138138

139139
$enumType = null;

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public static function typeProvider(): iterable
286286
{
287287
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
288288
if (!method_exists(BigIntType::class, 'getName')) {
289-
$expectedBigIntType = Type::collection(Type::int(), Type::string());
289+
$expectedBigIntType = Type::union(Type::int(), Type::string());
290290
} else {
291291
$expectedBigIntType = Type::string();
292292
}

0 commit comments

Comments
 (0)