-
Notifications
You must be signed in to change notification settings - Fork 93
using messenger HandleTrait as QueryBus with appropriate result typing #423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.4.x
Are you sure you want to change the base?
using messenger HandleTrait as QueryBus with appropriate result typing #423
Conversation
use HandleTrait; | ||
|
||
public function dispatch(object $query): mixed | ||
{ | ||
return $this->handle($query); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also add this test case with changed function name.
use HandleTrait; | |
public function dispatch(object $query): mixed | |
{ | |
return $this->handle($query); | |
} | |
use HandleTrait { | |
handle as private handleQuery; | |
} | |
public function handle(object $query): mixed | |
{ | |
return $this->handleQuery($query); | |
} |
@ondrejmirtes Sorry to disturb you, but I think this is one of the pieces that is missing in this whole puzzle to support. Can we move forward ? |
Hi @michaljusiega, thanks for your reply. I think we can add it - no problem. However, from my perspective it's more important to address the root issue (missing feature) of the topic (described here). My reasoning is without having this result interpreted on bus class level - this is much less useful in general. |
So this QueryBus class is something in your codebase and you want the same type inference that classes using HandleTrait and calling the You can simply write a dynamic return type extension for |
This PR goal is to determine correct result typing for QueryBus kind of classes which uses SF messenger HandleTrait internally and simply return its results.