Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Improved PHPDoc Return Types for Eloquent's Original Attribute Methods #55779

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

Conversation

clementbirkle
Copy link
Contributor

This PR enhances the type information in PHPDoc blocks for three methods that retrieve original attributes:

  • getOriginal()
  • getOriginalWithoutRewindingModel()
  • getRawOriginal()

Changes

Replaced the generic @return mixed|array with a more precise conditional return type: @return ($key is null ? array<string, mixed> : mixed)

This better communicates that:

  • When no key is provided, these methods return an array of all original attributes
  • When a key is provided, they return a mixed value for that specific attribute

Benefits

  • Improved static analysis capabilities
  • Better IDE type hinting and autocompletion
  • More accurate documentation for developers

No functional changes were made to the implementation.

@taylorotwell taylorotwell merged commit 5a915b3 into laravel:12.x May 19, 2025
61 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.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.