@@ -64,18 +64,18 @@ class SchemaValidator
64
64
* It maps built-in Doctrine types to PHP types
65
65
*/
66
66
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 ' ] ,
79
79
];
80
80
81
81
public function __construct (EntityManagerInterface $ em , bool $ validatePropertyTypes = true )
@@ -390,21 +390,21 @@ function (array $fieldMapping) use ($class): ?string {
390
390
$ propertyType = $ propertyType ->getName ();
391
391
392
392
// 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 ) ) {
394
394
return null ;
395
395
}
396
396
397
397
if (is_a ($ propertyType , BackedEnum::class, true )) {
398
398
$ backingType = (string ) (new ReflectionEnum ($ propertyType ))->getBackingType ();
399
399
400
- if ($ metadataFieldType !== $ backingType ) {
400
+ if (! in_array ( $ backingType, $ metadataFieldType , true ) ) {
401
401
return sprintf (
402
402
"The field '%s#%s' has the property type '%s' with a backing type of '%s' that differs from the metadata field type '%s'. " ,
403
403
$ class ->name ,
404
404
$ fieldName ,
405
405
$ propertyType ,
406
406
$ backingType ,
407
- $ metadataFieldType
407
+ implode ( ' | ' , $ metadataFieldType)
408
408
);
409
409
}
410
410
@@ -429,7 +429,7 @@ function (array $fieldMapping) use ($class): ?string {
429
429
) {
430
430
$ backingType = (string ) (new ReflectionEnum ($ fieldMapping ['enumType ' ]))->getBackingType ();
431
431
432
- if ($ metadataFieldType === $ backingType ) {
432
+ if (in_array ( $ backingType , $ metadataFieldType , true ) ) {
433
433
return null ;
434
434
}
435
435
@@ -439,7 +439,7 @@ function (array $fieldMapping) use ($class): ?string {
439
439
$ fieldName ,
440
440
$ fieldMapping ['enumType ' ],
441
441
$ backingType ,
442
- $ metadataFieldType
442
+ implode ( ' | ' , $ metadataFieldType)
443
443
);
444
444
}
445
445
@@ -455,7 +455,7 @@ function (array $fieldMapping) use ($class): ?string {
455
455
$ class ->name ,
456
456
$ fieldName ,
457
457
$ propertyType ,
458
- $ metadataFieldType ,
458
+ implode ( ' | ' , $ metadataFieldType) ,
459
459
$ fieldMapping ['type ' ]
460
460
);
461
461
},
@@ -468,8 +468,10 @@ function (array $fieldMapping) use ($class): ?string {
468
468
/**
469
469
* The exact DBAL type must be used (no subclasses), since consumers of doctrine/orm may have their own
470
470
* customization around field types.
471
+ *
472
+ * @return list<string>|null
471
473
*/
472
- private function findBuiltInType (Type $ type ): ?string
474
+ private function findBuiltInType (Type $ type ): ?array
473
475
{
474
476
$ typeName = get_class ($ type );
475
477
0 commit comments