@@ -50,6 +50,9 @@ public function __invoke()
5050
5151 assertType (TaggedResult::class, $ this ->handle (new TaggedQuery ()));
5252
53+ $ randomQuery = rand (0 , 1 ) ? new RegularQuery () : new TaggedQuery ();
54+ assertType (RegularQueryResult::class . '| ' . TaggedResult::class, $ this ->handle ($ randomQuery ));
55+
5356 // HandleTrait will throw exception in fact due to multiple handle methods/handlers per single query
5457 assertType ('mixed ' , $ this ->handle (new MultiHandlersForTheSameMessageQuery ()));
5558 }
@@ -94,6 +97,9 @@ public function action()
9497 assertType ('float ' , $ queryBus ->dispatch (new FloatQuery ()));
9598 assertType ('string ' , $ queryBus ->dispatch (new StringQuery ()));
9699
100+ $ randomQuery = rand (0 , 1 ) ? new IntQuery () : new StringQuery ();
101+ assertType ('int|string ' , $ queryBus ->dispatch ($ randomQuery ));
102+
97103 assertType (TaggedResult::class, $ queryBus ->dispatch (new TaggedQuery ()));
98104
99105 assertType (RegularQueryResult::class, $ queryBus ->dispatch2 (new RegularQuery ()));
@@ -102,6 +108,9 @@ public function action()
102108
103109 assertType (RegularQueryResult::class, $ queryBusWithInterface ->dispatch (new RegularQuery ()));
104110
111+ $ randomQueryBus = rand (0 , 1 ) ? $ queryBus : $ queryBusWithInterface ;
112+ assertType (RegularQueryResult::class, $ randomQueryBus ->dispatch (new RegularQuery ()));
113+
105114 // HandleTrait will throw exception in fact due to multiple handle methods/handlers per single query
106115 assertType ('mixed ' , $ queryBus ->dispatch (new MultiHandlesForInTheSameHandlerQuery ()));
107116 assertType ('mixed ' , $ queryBus ->dispatch (new MultiHandlersForTheSameMessageQuery ()));
0 commit comments