@@ -64,18 +64,18 @@ class SchemaValidator
6464 * It maps built-in Doctrine types to PHP types
6565 */
6666 private const BUILTIN_TYPES_MAP = [
67- AsciiStringType::class => 'string ' ,
68- BigIntType::class => ' string ' ,
69- BooleanType::class => 'bool ' ,
70- DecimalType::class => 'string ' ,
71- FloatType::class => 'float ' ,
72- GuidType::class => 'string ' ,
73- IntegerType::class => 'int ' ,
74- JsonType::class => 'array ' ,
75- SimpleArrayType::class => 'array ' ,
76- SmallIntType::class => 'int ' ,
77- StringType::class => 'string ' ,
78- TextType::class => 'string ' ,
67+ AsciiStringType::class => [ 'string ' ] ,
68+ BigIntType::class => [ ' int ' , ' string '] ,
69+ BooleanType::class => [ 'bool ' ] ,
70+ DecimalType::class => [ 'string ' ] ,
71+ FloatType::class => [ 'float ' ] ,
72+ GuidType::class => [ 'string ' ] ,
73+ IntegerType::class => [ 'int ' ] ,
74+ JsonType::class => [ 'array ' ] ,
75+ SimpleArrayType::class => [ 'array ' ] ,
76+ SmallIntType::class => [ 'int ' ] ,
77+ StringType::class => [ 'string ' ] ,
78+ TextType::class => [ 'string ' ] ,
7979 ];
8080
8181 public function __construct (EntityManagerInterface $ em , bool $ validatePropertyTypes = true )
@@ -390,21 +390,21 @@ function (array $fieldMapping) use ($class): ?string {
390390 $ propertyType = $ propertyType ->getName ();
391391
392392 // If the property type is the same as the metadata field type, we are ok
393- if ($ propertyType === $ metadataFieldType ) {
393+ if (in_array ( $ propertyType, $ metadataFieldType, true ) ) {
394394 return null ;
395395 }
396396
397397 if (is_a ($ propertyType , BackedEnum::class, true )) {
398398 $ backingType = (string ) (new ReflectionEnum ($ propertyType ))->getBackingType ();
399399
400- if ($ metadataFieldType !== $ backingType ) {
400+ if (! in_array ( $ backingType, $ metadataFieldType , true ) ) {
401401 return sprintf (
402402 "The field '%s#%s' has the property type '%s' with a backing type of '%s' that differs from the metadata field type '%s'. " ,
403403 $ class ->name ,
404404 $ fieldName ,
405405 $ propertyType ,
406406 $ backingType ,
407- $ metadataFieldType
407+ implode ( ' | ' , $ metadataFieldType)
408408 );
409409 }
410410
@@ -429,7 +429,7 @@ function (array $fieldMapping) use ($class): ?string {
429429 ) {
430430 $ backingType = (string ) (new ReflectionEnum ($ fieldMapping ['enumType ' ]))->getBackingType ();
431431
432- if ($ metadataFieldType === $ backingType ) {
432+ if (in_array ( $ backingType , $ metadataFieldType , true ) ) {
433433 return null ;
434434 }
435435
@@ -439,7 +439,7 @@ function (array $fieldMapping) use ($class): ?string {
439439 $ fieldName ,
440440 $ fieldMapping ['enumType ' ],
441441 $ backingType ,
442- $ metadataFieldType
442+ implode ( ' | ' , $ metadataFieldType)
443443 );
444444 }
445445
@@ -455,7 +455,7 @@ function (array $fieldMapping) use ($class): ?string {
455455 $ class ->name ,
456456 $ fieldName ,
457457 $ propertyType ,
458- $ metadataFieldType ,
458+ implode ( ' | ' , $ metadataFieldType) ,
459459 $ fieldMapping ['type ' ]
460460 );
461461 },
@@ -468,8 +468,10 @@ function (array $fieldMapping) use ($class): ?string {
468468 /**
469469 * The exact DBAL type must be used (no subclasses), since consumers of doctrine/orm may have their own
470470 * customization around field types.
471+ *
472+ * @return list<string>|null
471473 */
472- private function findBuiltInType (Type $ type ): ?string
474+ private function findBuiltInType (Type $ type ): ?array
473475 {
474476 $ typeName = get_class ($ type );
475477
0 commit comments