diff --git a/Database/Eloquent/CastsAttributes.php b/Database/Eloquent/CastsAttributes.php index 89cec66..21776bc 100644 --- a/Database/Eloquent/CastsAttributes.php +++ b/Database/Eloquent/CastsAttributes.php @@ -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 */ @@ -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 $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);