Repository navigation
[12.x] Fix callable type for freezeTime, freezeSecond, and travelTo - #59466
Merged
taylorotwell merged 3 commits intoMar 31, 2026
Merged
taylorotwell merged 3 commits into
taylorotwell merged 3 commits into
Conversation
calebdw
reviewed
Mar 31, 2026
Contributor
|
Looks good! |
jonagoldman
pushed a commit
to deplox/laravel-framework
that referenced
this pull request
Apr 30, 2026
…aravel#59466) * Fix callable type for freezeTime, freezeSecond, and travelTo callbacks * Remove travelTo type test with narrowed Carbon callback * Use template for travelTo callback date type
binaryfire
added a commit
to hypervel/components-backup
that referenced
this pull request
Oct 1, 2026
Port callback return templates across Wormhole and InteractsWithTime, including the later correction that describes the date passed to freeze and travel callbacks. Use CarbonInterface for configurable Date factory output and infer the exact supplied travelTo date type. Add native types for the documented inputs and explicit null returns for paths without callbacks. Retain Hypervel’s immutable date defaults, coroutine-local clock, and finally-based cleanup when callbacks throw. Port both complete upstream type fixtures and cover concrete date and string inference without adding redundant runtime tests. Upstream: laravel/framework#58951 laravel/framework#59466 Source: laravel/framework 13.x at 01d008c9b5f32cb7c5e50a9a22273113d810b2a2. Validation: each type fixture after porting, existing time-travel tests through ParaTest, full source and type analysis, formatting, and post-format type 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.
This fixes the callable parameter type in the docblocks of
freezeTime(),freezeSecond(), andtravelTo()in theInteractsWithTimetrait.Since #58951, the callback parameter is typed as
(callable(): TReturn)|null, a callable accepting zero parameters. However,travelTo()actually invokes the callback with$date:This causes PHPStan/Larastan to report a false positive when passing a closure that accepts a
Carbonparameter:The fix updates the callable types to reflect the actual runtime behavior:
freezeTime/freezeSecond:(callable(\Illuminate\Support\Carbon): TReturn)|nulltravelTo: uses aTDatetemplate inferred from the$dateparameter, so the callback type matches dynamically