Skip to content

Commit a9f07aa

Browse files
author
Bartłomiej Nowak
committed
updated README.md
1 parent 4481284 commit a9f07aa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,20 +221,20 @@ class QueryBus
221221
222222
public function dispatch(object $query): mixed
223223
{
224-
return $this->handle($query); // Return type will be inferred
224+
return $this->handle($query); // Return type will be inferred in calling code as query result
225225
}
226226
227227
// Multiple methods per class example
228228
public function execute(object $message): mixed
229229
{
230-
return $this->handle($message);
230+
return $this->handle($message); // Return type will be inferred in calling code as query result
231231
}
232232
}
233233
234234
// Interface-based configuration example
235235
interface QueryBusInterface
236236
{
237-
public function dispatch(object $query): mixed;
237+
public function dispatch(object $query): mixed; // Return type will be inferred in calling code as query result
238238
}
239239
240240
class QueryBusWithInterface implements QueryBusInterface
@@ -252,12 +252,13 @@ class QueryBusWithInterface implements QueryBusInterface
252252
}
253253
}
254254
255-
// Usage examples with proper type inference
255+
// Examples of use with proper type inference
256256
$query = new GetProductQuery($productId);
257257
$queryBus = new QueryBus($messageBus);
258258
$queryBusWithInterface = new QueryBusWithInterface($messageBus);
259259
260260
$product = $queryBus->dispatch($query); // Returns: Product
261261
$product2 = $queryBus->execute($query); // Returns: Product
262262
$product3 = $queryBusWithInterface->dispatch($query); // Returns: Product
263+
// Without the feature all above query bus results would be default 'mixed'.
263264
```

0 commit comments

Comments
 (0)