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 @@ -111,3 +111,32 @@ public function __invoke()
111
111
assertType ('mixed ' , $ this ->handle (new MultiHandlersForTheSameMessageQuery ()));
112
112
}
113
113
}
114
+
115
+ class QueryBus {
116
+ use HandleTrait;
117
+
118
+ public function dispatch (object $ query ): mixed
119
+ {
120
+ return $ this ->handle ($ query );
121
+ }
122
+ }
123
+
124
+ class Controller {
125
+ public function action ()
126
+ {
127
+ $ queryBus = new QueryBus ();
128
+
129
+ assertType (RegularQueryResult::class, $ queryBus ->dispatch (new RegularQuery ()));
130
+
131
+ assertType ('bool ' , $ queryBus ->dispatch (new BooleanQuery ()));
132
+ assertType ('int ' , $ queryBus ->dispatch (new IntQuery ()));
133
+ assertType ('float ' , $ queryBus ->dispatch (new FloatQuery ()));
134
+ assertType ('string ' , $ queryBus ->dispatch (new StringQuery ()));
135
+
136
+ assertType (TaggedResult::class, $ queryBus ->dispatch (new TaggedQuery ()));
137
+
138
+ // HandleTrait will throw exception in fact due to multiple handle methods/handlers per single query
139
+ assertType ('mixed ' , $ queryBus ->dispatch (new MultiHandlesForInTheSameHandlerQuery ()));
140
+ assertType ('mixed ' , $ queryBus ->dispatch (new MultiHandlersForTheSameMessageQuery ()));
141
+ }
142
+ }
You can’t perform that action at this time.
0 commit comments