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
+92Lines changed: 92 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ This extension provides following features:
29
29
* Provides correct return type for `Extension::getConfiguration()` method.
30
30
* Provides correct return type for `CacheInterface::get()` method based on the callback return type.
31
31
* Provides correct return type for `BrowserKitAssertionsTrait::getClient()` method.
32
+
* Provides configurable return type resolution for methods that internally use Messenger `HandleTrait`.
32
33
* Notifies you when you try to get an unregistered service from the container.
33
34
* Notifies you when you try to get a private service from the container.
34
35
* Notifies you when you access undefined console command arguments or options.
@@ -180,3 +181,94 @@ Call the new env in your `console-application.php`:
180
181
```php
181
182
$kernel = new \App\Kernel('phpstan_env', (bool) $_SERVER['APP_DEBUG']);
182
183
```
184
+
185
+
## Messenger HandleTrait Wrappers
186
+
187
+
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.
188
+
189
+
### Configuration
190
+
191
+
```neon
192
+
parameters:
193
+
symfony:
194
+
messenger:
195
+
handleTraitWrappers:
196
+
- App\Bus\QueryBus::dispatch
197
+
- App\Bus\QueryBus::execute
198
+
- App\Bus\QueryBusInterface::dispatch
199
+
```
200
+
201
+
### Message Handlers
202
+
203
+
```php
204
+
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
205
+
206
+
// Product handler that returns Product
207
+
#[AsMessageHandler]
208
+
class GetProductQueryHandler
209
+
{
210
+
public function __invoke(GetProductQuery $query): Product
0 commit comments