Skip to content

[Docblock] Add return type to defer() helper #56534

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

Merged
merged 2 commits into from
Aug 4, 2025

Conversation

tushar-nain
Copy link
Contributor

Summary

This pull request adds a missing @return docblock to the defer() global helper defined in Illuminate\Support\functions.php.

The helper returns either a DeferredCallback or a DeferredCallbackCollection, depending on whether a callable is passed. Currently, the docblock does not specify the return type when $callback is null, which can negatively impact IDE autocompletion and static analysis.

Benefits

  • Improves IDE support (e.g., PhpStorm, VS Code)
  • Enhances compatibility with static analysis tools (e.g., PHPStan, Psalm)
  • Clarifies the actual behavior of the helper for future maintainers and contributors
  • Does not introduce any functional changes or side effects

Why This Is Safe

  • This is a docblock-only change; it does not alter runtime behavior.
  • No existing code depends on the absence of the return type in the docblock.

Related

This helper is part of the newer Illuminate\Support\defer() system introduced for deferring callbacks, and this docblock ensures full developer insight into the return behavior of the helper.

Co-authored-by: Sebastian Hädrich <11225821+shaedrich@users.noreply.github.com>
@taylorotwell taylorotwell merged commit 8e2d286 into laravel:12.x Aug 4, 2025
58 of 60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants