@@ -435,29 +435,18 @@ public static function combineAcceptors(array $acceptors): ParametersAcceptorWit
435435
436436 $ parameters = [];
437437 $ isVariadic = false ;
438- $ returnType = null ;
439- $ phpDocReturnType = null ;
440- $ nativeReturnType = null ;
438+ $ returnTypes = [] ;
439+ $ phpDocReturnTypes = [] ;
440+ $ nativeReturnTypes = [] ;
441441
442442 foreach ($ acceptors as $ acceptor ) {
443- if ($ returnType === null ) {
444- $ returnType = $ acceptor ->getReturnType ();
445- } else {
446- $ returnType = TypeCombinator::union ($ returnType , $ acceptor ->getReturnType ());
447- }
443+ $ returnTypes [] = $ acceptor ->getReturnType ();
444+
448445 if ($ acceptor instanceof ParametersAcceptorWithPhpDocs) {
449- if ($ phpDocReturnType === null ) {
450- $ phpDocReturnType = $ acceptor ->getPhpDocReturnType ();
451- } else {
452- $ phpDocReturnType = TypeCombinator::union ($ phpDocReturnType , $ acceptor ->getPhpDocReturnType ());
453- }
446+ $ phpDocReturnTypes [] = $ acceptor ->getPhpDocReturnType ();
454447 }
455448 if ($ acceptor instanceof ParametersAcceptorWithPhpDocs) {
456- if ($ nativeReturnType === null ) {
457- $ nativeReturnType = $ acceptor ->getNativeReturnType ();
458- } else {
459- $ nativeReturnType = TypeCombinator::union ($ nativeReturnType , $ acceptor ->getNativeReturnType ());
460- }
449+ $ nativeReturnTypes [] = $ acceptor ->getNativeReturnType ();
461450 }
462451 $ isVariadic = $ isVariadic || $ acceptor ->isVariadic ();
463452
@@ -524,6 +513,10 @@ public static function combineAcceptors(array $acceptors): ParametersAcceptorWit
524513 }
525514 }
526515
516+ $ returnType = TypeCombinator::union (...$ returnTypes );
517+ $ phpDocReturnType = $ phpDocReturnTypes === [] ? null : TypeCombinator::union (...$ phpDocReturnTypes );
518+ $ nativeReturnType = $ nativeReturnTypes === [] ? null : TypeCombinator::union (...$ nativeReturnTypes );
519+
527520 return new FunctionVariantWithPhpDocs (
528521 TemplateTypeMap::createEmpty (),
529522 null ,
0 commit comments