Conversation

bnowak

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.

Comment on lines +116 to +121
use HandleTrait;

public function dis(object $query): mixed
{
return $this->handle($query);
}

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.

Suggested change
use HandleTrait;
public function dis(object $query): mixed
{
return $this->handle($query);
}
use HandleTrait {
handle as private handleQuery;
}
public function handle(object $query): mixed
{
return $this->handleQuery($query);
}

@michaljusiega

@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 ?

@bnowak

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.

@ondrejmirtes

So this QueryBus class is something in your codebase and you want the same type inference that classes using HandleTrait and calling the handle method have?

You can simply write a dynamic return type extension for QueryBus::dis() that delegates the type resolution to new MethodCall($methodCall->var, 'handle', $methodCall->getArgs()).

Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.