You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+93Lines changed: 93 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,8 @@ This extension provides following features:
21
21
* Provides correct return type for `InputBag::get()` method based on the `$default` parameter.
22
22
* Provides correct return type for `InputBag::all()` method based on the `$key` parameter.
23
23
* Provides correct return types for `TreeBuilder` and `NodeDefinition` objects.
24
+
* Provides correct return type for Messenger `HandleTrait::handle()` method based on the message type.
25
+
* Provides configurable return type resolution for methods that internally use Messenger `HandleTrait`.
24
26
* Notifies you when you try to get an unregistered service from the container.
25
27
* Notifies you when you try to get a private service from the container.
26
28
* Optionally correct return types for `InputInterface::getArgument()`, `::getOption`, `::hasArgument`, and `::hasOption`.
@@ -168,3 +170,94 @@ Call the new env in your `console-application.php`:
168
170
```php
169
171
$kernel = new \App\Kernel('phpstan_env', (bool) $_SERVER['APP_DEBUG']);
170
172
```
173
+
174
+
## Messenger HandleTrait Wrappers
175
+
176
+
The extension provides advanced type inference for methods that internally use Symfony Messenger's `HandleTrait`. This feature is particularly useful for query bus implementations (in CQRS pattern) that use/wrap the `HandleTrait::handle()` method.
177
+
178
+
### Configuration
179
+
180
+
```neon
181
+
parameters:
182
+
symfony:
183
+
messenger:
184
+
handleTraitWrappers:
185
+
- App\Bus\QueryBus::dispatch
186
+
- App\Bus\QueryBus::execute
187
+
- App\Bus\QueryBusInterface::dispatch
188
+
```
189
+
190
+
### Message Handlers
191
+
192
+
```php
193
+
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
194
+
195
+
// Product handler that returns Product
196
+
#[AsMessageHandler]
197
+
class GetProductQueryHandler
198
+
{
199
+
public function __invoke(GetProductQuery $query): Product
0 commit comments