Skip to content

Commit 0ff50fc

Browse files
Bartłomiej Nowakbnowak
authored andcommitted
updated README.md
1 parent 86e4507 commit 0ff50fc

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,20 +232,20 @@ class QueryBus
232232
233233
public function dispatch(object $query): mixed
234234
{
235-
return $this->handle($query); // Return type will be inferred
235+
return $this->handle($query); // Return type will be inferred in calling code as query result
236236
}
237237
238238
// Multiple methods per class example
239239
public function execute(object $message): mixed
240240
{
241-
return $this->handle($message);
241+
return $this->handle($message); // Return type will be inferred in calling code as query result
242242
}
243243
}
244244
245245
// Interface-based configuration example
246246
interface QueryBusInterface
247247
{
248-
public function dispatch(object $query): mixed;
248+
public function dispatch(object $query): mixed; // Return type will be inferred in calling code as query result
249249
}
250250
251251
class QueryBusWithInterface implements QueryBusInterface
@@ -263,12 +263,13 @@ class QueryBusWithInterface implements QueryBusInterface
263263
}
264264
}
265265
266-
// Usage examples with proper type inference
266+
// Examples of use with proper type inference
267267
$query = new GetProductQuery($productId);
268268
$queryBus = new QueryBus($messageBus);
269269
$queryBusWithInterface = new QueryBusWithInterface($messageBus);
270270
271271
$product = $queryBus->dispatch($query); // Returns: Product
272272
$product2 = $queryBus->execute($query); // Returns: Product
273273
$product3 = $queryBusWithInterface->dispatch($query); // Returns: Product
274+
// Without the feature all above query bus results would be default 'mixed'.
274275
```

0 commit comments

Comments
 (0)