Repository navigation
[13.x] Resolve scheduled event callback parameter by type rather than name - #60197
Merged
taylorotwell merged 2 commits intoMay 20, 2026
Conversation
shaedrich
reviewed
May 20, 2026
Comment on lines
+794
to
+800
| foreach ($parameters as $name => $type) { | ||
| if ($type !== null && is_a($this, $type)) { | ||
| return [$name => $this]; | ||
| } | ||
| } | ||
|
|
||
| return ['event' => $this]; | ||
| return []; |
This comment was marked as low quality.
This comment was marked as low quality.
Sorry, something went wrong.
Contributor
Author
There was a problem hiding this comment.
array_any returns bool though, so $event would just be true/false — $name from the closure isn't in scope either. Did you mean array_find_key?
Either way I'd lean toward keeping the foreach — the other 3 spots using closureParameterTypes() in this file all do the same $parameters = ...; foreach thing.
binaryfire
added a commit
to hypervel/components-backup
that referenced
this pull request
Oct 1, 2026
When a group seeds pending event attributes, apply that pending copy once and return. Applying the group again duplicated lifecycle callbacks and macros. Use the current Laravel merge order, remove unreachable dependency guards, and retain Hypervel's coroutine execution and event observation boundaries. Restore the complete applicable grouping, callback, quarterly-frequency and run-command tests. Use a shared stateless event mutex fixture and join the task coroutine owned by each background-command test before asserting its outcome. Preserve mutable dates in the repeat-start test so it protects the copy guard. Correct the reversed elapsed-time comparison that kept the sub-minute maintenance test from ever entering maintenance mode. Remove the ineffective scheduled-task user API and its pending attributes, generated facade annotation and Telescope metadata/UI. Tasks share the scheduler's OS user; document running the scheduler under the required user or using an explicit system command. Keep the long-running schedule:run replacement for schedule:work and document the --once cron adaptation. Complete the linked maintenance-view deployment guidance alongside these porting-guide changes. Upstream scheduler history: laravel/framework#58926 laravel/framework#60133 laravel/framework#60144 laravel/framework#60148 laravel/framework#60190 laravel/framework#60197 laravel/framework#60255 laravel/framework#60712 laravel/framework#60311 laravel/framework#60469 laravel/framework#55624 laravel/framework#57621 laravel/framework#59331 Related complete test and documentation reconciliation: laravel/framework#60761 laravel/framework#60793 laravel/framework#61199 laravel/framework#60595 laravel/framework#61117 Porting source: 01d008c9b5f32cb7c5e50a9a22273113d810b2a2. Validation: full composer fix, both complete scheduler suites after review corrections, immediate test-file checks, facade regeneration and Telescope frontend build. The repeat-start assertion fails when copy() is removed; the maintenance-state assertion fails before correcting the elapsed-time comparison. Formatting and diff checks pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a name-based parameter resolution issue introduced in #60144.
Background
#60144 made it possible to pass the scheduled
Eventinto lifecycle callbacks, and the PR description promises that you can "typehint a callback withEvent $eventas a parameter". However, the implementation only injects the event when the closure parameter is literally named$event. Theis_a($this, $eventParameterType)check in the same method shows the intent was type-based, but the lookup is name-based — these contradict each other.All tests added by #60144 happen to use the parameter name
$event, so the working contract (typehint-based) was never exercised.Reproduction
This throws
BindingResolutionException: the parameter lookup misses on the name'event', no value is injected, and the container falls back to autowiring a newEvent— which fails becauseEventMutexisn't instantiable.Fix
Iterate the closure parameters and inject
$thisinto the first parameter whose type is a class that$thisis an instance of. This matches how Laravel container DI works elsewhere — by type, not by name.After