@@ -209,19 +209,22 @@ static function (Type $type, callable $traverse) use ($objectManager): Type {
209
209
210
210
private function getScalarHydratedReturnType (Type $ queryResultType ): Type
211
211
{
212
- if (!$ queryResultType instanceof ArrayType ) {
212
+ if (!$ queryResultType-> isArray ()-> yes () ) {
213
213
return new ArrayType (new MixedType (), new MixedType ());
214
214
}
215
215
216
- $ itemType = $ queryResultType ->getItemType ();
217
- $ hasNoObject = (new ObjectWithoutClassType ())->isSuperTypeOf ($ itemType )->no ();
218
- $ hasNoArray = $ itemType ->isArray ()->no ();
216
+ foreach ($ queryResultType ->getArrays () as $ arrayType ) {
217
+ $ itemType = $ arrayType ->getItemType ();
219
218
220
- if ($ hasNoArray && $ hasNoObject ) {
221
- return $ queryResultType ;
219
+ if (
220
+ !(new ObjectWithoutClassType ())->isSuperTypeOf ($ itemType )->no ()
221
+ || !$ itemType ->isArray ()->no ()
222
+ ) {
223
+ new ArrayType (new MixedType (), new MixedType ());
224
+ }
222
225
}
223
226
224
- return new ArrayType ( new MixedType (), new MixedType ()) ;
227
+ return $ queryResultType ;
225
228
}
226
229
227
230
private function getSimpleObjectHydratedReturnType (Type $ queryResultType ): Type
@@ -236,31 +239,41 @@ private function getSimpleObjectHydratedReturnType(Type $queryResultType): Type
236
239
private function getSingleScalarHydratedReturnType (Type $ queryResultType ): Type
237
240
{
238
241
$ queryResultType = $ this ->getScalarHydratedReturnType ($ queryResultType );
239
- if (!$ queryResultType instanceof ConstantArrayType ) {
242
+ if (!$ queryResultType-> isConstantArray ()-> yes () ) {
240
243
return new MixedType ();
241
244
}
242
245
243
- $ values = $ queryResultType ->getValueTypes ();
244
- if (count ($ values ) !== 1 ) {
245
- return new MixedType ();
246
+ $ types = [];
247
+ foreach ($ queryResultType ->getConstantArrays () as $ constantArrayType ) {
248
+ $ values = $ constantArrayType ->getValueTypes ();
249
+ if (count ($ values ) !== 1 ) {
250
+ return new MixedType ();
251
+ }
252
+
253
+ $ types [] = $ constantArrayType ->getFirstIterableValueType ();
246
254
}
247
255
248
- return $ queryResultType -> getFirstIterableValueType ( );
256
+ return TypeCombinator:: union (... $ types );
249
257
}
250
258
251
259
private function getScalarColumnHydratedReturnType (Type $ queryResultType ): Type
252
260
{
253
261
$ queryResultType = $ this ->getScalarHydratedReturnType ($ queryResultType );
254
- if (!$ queryResultType instanceof ConstantArrayType ) {
262
+ if (!$ queryResultType-> isConstantArray ()-> yes () ) {
255
263
return new MixedType ();
256
264
}
257
265
258
- $ values = $ queryResultType ->getValueTypes ();
259
- if (count ($ values ) !== 1 ) {
260
- return new MixedType ();
266
+ $ types = [];
267
+ foreach ($ queryResultType ->getConstantArrays () as $ constantArrayType ) {
268
+ $ values = $ constantArrayType ->getValueTypes ();
269
+ if (count ($ values ) !== 1 ) {
270
+ return new MixedType ();
271
+ }
272
+
273
+ $ types [] = $ constantArrayType ->getFirstIterableValueType ();
261
274
}
262
275
263
- return $ queryResultType -> getFirstIterableValueType ( );
276
+ return TypeCombinator:: union (... $ types );
264
277
}
265
278
266
279
private function originalReturnType (MethodReflection $ methodReflection ): Type
0 commit comments