File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -54,3 +54,32 @@ public function __invoke()
5454 assertType ('mixed ' , $ this ->handle (new MultiHandlersForTheSameMessageQuery ()));
5555 }
5656}
57+
58+ class QueryBus {
59+ use HandleTrait;
60+
61+ public function dispatch (object $ query ): mixed
62+ {
63+ return $ this ->handle ($ query );
64+ }
65+ }
66+
67+ class Controller {
68+ public function action ()
69+ {
70+ $ queryBus = new QueryBus ();
71+
72+ assertType (RegularQueryResult::class, $ queryBus ->dispatch (new RegularQuery ()));
73+
74+ assertType ('bool ' , $ queryBus ->dispatch (new BooleanQuery ()));
75+ assertType ('int ' , $ queryBus ->dispatch (new IntQuery ()));
76+ assertType ('float ' , $ queryBus ->dispatch (new FloatQuery ()));
77+ assertType ('string ' , $ queryBus ->dispatch (new StringQuery ()));
78+
79+ assertType (TaggedResult::class, $ queryBus ->dispatch (new TaggedQuery ()));
80+
81+ // HandleTrait will throw exception in fact due to multiple handle methods/handlers per single query
82+ assertType ('mixed ' , $ queryBus ->dispatch (new MultiHandlesForInTheSameHandlerQuery ()));
83+ assertType ('mixed ' , $ queryBus ->dispatch (new MultiHandlersForTheSameMessageQuery ()));
84+ }
85+ }
You can’t perform that action at this time.
0 commit comments