Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Database/Eloquent/CastsAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
use Illuminate\Database\Eloquent\Model;

/**
* Recommendation:
* Prefer symmetric casts (TGet == TSet) so "$a = $a = $b"
* remain safe and unsurprising.
*
* @template TGet
* @template TSet
*/
Expand All @@ -24,10 +28,12 @@ public function get(Model $model, string $key, mixed $value, array $attributes);
/**
* Transform the attribute to its underlying model values.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @param TSet|null $value
* @param array<string, mixed> $attributes
* Important:
* Implementations must tolerate receiving the runtime cast value (TGet) here.
* As with object caching, `set()` may receive the value returned by `get()` (TGet).
* Implementations should therefore accept both TGet and TSet.
*
* @param TGet|TSet|null $value
* @return mixed
*/
public function set(Model $model, string $key, mixed $value, array $attributes);
Expand Down
Loading