-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[8.x] Allow adding catch callbacks for chains #33364
Conversation
*/ | ||
public function invokeChainCatchCallbacks($e) | ||
{ | ||
collect($this->chainCatchCallbacks)->each->__invoke($e); |
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.
I don't think userland code should ever call dynamic methods like that? Can we not just literally invoke it?
(collect($this->chainCatchCallbacks)->each)($e);
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.
@GrahamCampbell hmmm what's the reason?
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.
Magic methods are not meant to be called directly. It's hacky to do that. Just like it's hacky to use reflection to make a private method callable and then call it. Those methods are there to be used by PHP native syntax. __invoke
is meant to be called only be actually calling the class and __get
is meant to be called only by doing a property access, etc. Obviously, there are exceptions, but I don't think this is one of those cases.
This PR add a new
Bus::chain()
method similar toBus::batch()
and also allows attaching catch callbacks to chain:The callbacks will be invoked if any of the jobs fail.