Skip to content

[12.x] Align casts property type with casts method return type#59154

Open
nhedger wants to merge 1 commit intolaravel:12.xfrom
nhedger:feat/align-model-casts-type
Open

[12.x] Align casts property type with casts method return type#59154
nhedger wants to merge 1 commit intolaravel:12.xfrom
nhedger:feat/align-model-casts-type

Conversation

@nhedger
Copy link
Contributor

@nhedger nhedger commented Mar 11, 2026

Summary

This PR updates the PHPDoc type for the casts property in the HasAttributes trait so it matches the type used by the trait’s casts method.

/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts()
{
return [];
}

* The attributes that should be cast.
*
* @var array
* @var array<string, string>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this ideally be something like this?

Suggested change
* @var array<string, string>
* @var array<string, string|class-string<\UnitEnum|\Illuminate\Contracts\Database\Eloquent\CastsAttributes|\Illuminate\Contracts\Database\Eloquent\Castable>>

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