Skip to content

Commit

Permalink
[11.x] Make methods of HasRelationships generic (#54174)
Browse files Browse the repository at this point in the history
* Make relationResolver, newRelatedInstance and newRelatedThroughInstance generic

* CS
  • Loading branch information
SanderMuller authored Jan 13, 2025
1 parent 09ac6ca commit 7864240
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<TRelatedModel> $class
* @param string $key
* @return mixed
* @return Closure|null
*/
public function relationResolver($class, $key)
{
Expand Down Expand Up @@ -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<TRelatedModel> $class
* @return TRelatedModel
*/
protected function newRelatedInstance($class)
{
Expand All @@ -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<TRelatedModel> $class
* @return TRelatedModel
*/
protected function newRelatedThroughInstance($class)
{
Expand Down

0 comments on commit 7864240

Please sign in to comment.