From 78642404aa28aaf69b9170a589dd60bc3d43f86e Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Mon, 13 Jan 2025 17:44:07 +0100 Subject: [PATCH] [11.x] Make methods of `HasRelationships` generic (#54174) * Make relationResolver, newRelatedInstance and newRelatedThroughInstance generic * CS --- .../Eloquent/Concerns/HasRelationships.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php b/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php index 0664e80780bb..c62ce076b923 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php @@ -58,9 +58,11 @@ trait HasRelationships /** * Get the dynamic relation resolver if defined or inherited, or return null. * - * @param string $class + * @template TRelatedModel of \Illuminate\Database\Eloquent\Model + * + * @param class-string $class * @param string $key - * @return mixed + * @return Closure|null */ public function relationResolver($class, $key) { @@ -851,8 +853,10 @@ public function getMorphClass() /** * Create a new model instance for a related model. * - * @param string $class - * @return mixed + * @template TRelatedModel of \Illuminate\Database\Eloquent\Model + * + * @param class-string $class + * @return TRelatedModel */ protected function newRelatedInstance($class) { @@ -866,8 +870,10 @@ protected function newRelatedInstance($class) /** * Create a new model instance for a related "through" model. * - * @param string $class - * @return mixed + * @template TRelatedModel of \Illuminate\Database\Eloquent\Model + * + * @param class-string $class + * @return TRelatedModel */ protected function newRelatedThroughInstance($class) {