Repository navigation
[13.x] Add generic return type to InvokableComponentVariable - #62018
Merged
taylorotwell merged 1 commit intoOct 14, 2026
Merged
taylorotwell merged 1 commit into
taylorotwell merged 1 commit into
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
alies-dev
marked this pull request as ready for review
October 14, 2026 14:43
InvokableComponentVariable
Merged
1 task done
alies-dev
added a commit
to psalm/psalm-plugin-laravel
that referenced
this pull request
Oct 14, 2026
Declares `@mixin TValue` on the stub, so `__call` forwarding to the resolved value is typed, matching the mixin added upstream in laravel/framework#62018. Property reads stay sealed: Psalm does not resolve templated mixins for property fetches.
binaryfire
added a commit
to hypervel/components-backup
that referenced
this pull request
Oct 26, 2026
Apply laravel/framework#62018 (5cc36e3233), including its complete type fixture. Component variables preserve the resolver result type through invocation and method forwarding. The deferred display contract incorrectly restricted raw resolver results to strings and Htmlable objects, rejecting numeric and nullable component values before escaping could handle them. Return the original unconstrained resolver value. Normalize numeric values to strings only in the default HTML encoder, preserving values passed to custom encoders. Remove redundant test cleanup already owned by the framework subscriber. Regression tests reproduce both TypeErrors before correction. Formatting, full source and type analysis, the View suite and HTML encoder tests 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.
Blade components pass their zero-argument public methods to views wrapped in
\Illuminate\View\InvokableComponentVariableinstances, and so far static analysis tools couldn't infer return types of suchInvokableComponentVariable, so I'm proposing to use@templatesyntax for InvokableComponentVariable.PR adds a single covariant template for the resolved value and declares it as a mixin, so a view can state what a component method returns and both calling it and proxied access are typed:
The change is PHPDoc only. The template defaults to
mixed, so existing unparameterizedInvokableComponentVariableannotations keep working.tools
Additionally bladestan may implement custom handlers to specify more narrow return types instead of mixed; psalm/plugin-laravel already does.