@@ -70,29 +70,20 @@ public function getWritableToDatabaseType(): Type
70
70
71
71
public function getDatabaseInternalType (): Type
72
72
{
73
- if (!$ this ->reflectionProvider ->hasClass ($ this ->type )) {
74
- return new MixedType ();
75
- }
76
-
77
- $ registry = $ this ->container ->getByType (DefaultDescriptorRegistry::class);
78
- $ parents = $ this ->reflectionProvider ->getClass ($ this ->type )->getParentClassesNames ();
79
-
80
- foreach ($ parents as $ dbalTypeParentClass ) {
81
- try {
82
- // this assumes that if somebody inherits from DecimalType,
83
- // the real database type remains decimal and we can reuse its descriptor
84
- return $ registry ->getByClassName ($ dbalTypeParentClass )->getDatabaseInternalType ();
85
-
86
- } catch (DescriptorNotRegisteredException $ e ) {
87
- continue ;
88
- }
89
- }
90
-
91
- return new MixedType ();
73
+ return $ this ->doGetDatabaseInternalType (null );
92
74
}
93
75
94
76
public function getDatabaseInternalTypeForDriver (Connection $ connection ): Type
95
77
{
78
+ return $ this ->doGetDatabaseInternalType ($ connection );
79
+ }
80
+
81
+ private function doGetDatabaseInternalType (?Connection $ connection ): Type
82
+ {
83
+ if (!$ this ->reflectionProvider ->hasClass ($ this ->type )) {
84
+ return new MixedType ();
85
+ }
86
+
96
87
$ registry = $ this ->container ->getByType (DefaultDescriptorRegistry::class);
97
88
$ parents = $ this ->reflectionProvider ->getClass ($ this ->type )->getParentClassesNames ();
98
89
@@ -102,7 +93,7 @@ public function getDatabaseInternalTypeForDriver(Connection $connection): Type
102
93
// the real database type remains decimal and we can reuse its descriptor
103
94
$ descriptor = $ registry ->getByClassName ($ dbalTypeParentClass );
104
95
105
- return $ descriptor instanceof DoctrineTypeDriverAwareDescriptor
96
+ return $ descriptor instanceof DoctrineTypeDriverAwareDescriptor && $ connection !== null
106
97
? $ descriptor ->getDatabaseInternalTypeForDriver ($ connection )
107
98
: $ descriptor ->getDatabaseInternalType ();
108
99
0 commit comments