Skip to content

Commit

Permalink
add compatibility with larastan
Browse files Browse the repository at this point in the history
  • Loading branch information
asanovr committed Jun 3, 2024
1 parent 98f3503 commit d29f0f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
19 changes: 10 additions & 9 deletions src/Illuminate/Database/Eloquent/Relations/BelongsTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
use Illuminate\Database\Eloquent\Relations\Concerns\SupportsDefaultModels;

/**
* @template T of \Illuminate\Database\Eloquent\Model
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TChildModel of \Illuminate\Database\Eloquent\Model
*
* @extends Relation<T>
* @extends Relation<TRelatedModel>
*/
class BelongsTo extends Relation
{
Expand All @@ -24,7 +25,7 @@ class BelongsTo extends Relation
/**
* The child model instance of the relation.
*
* @var T
* @var TChildModel
*/
protected $child;

Expand Down Expand Up @@ -200,8 +201,8 @@ public function match(array $models, Collection $results, $relation)
/**
* Associate the model instance to the given parent.
*
* @param T|int|string|null $model
* @return T
* @param TRelatedModel|int|string|null $model
* @return TChildModel
*/
public function associate($model)
{
Expand All @@ -221,7 +222,7 @@ public function associate($model)
/**
* Dissociate previously associated model from the given parent.
*
* @return T
* @return TChildModel
*/
public function dissociate()
{
Expand All @@ -233,7 +234,7 @@ public function dissociate()
/**
* Alias of "dissociate" method.
*
* @return T
* @return TChildModel
*/
public function disassociate()
{
Expand Down Expand Up @@ -295,7 +296,7 @@ protected function relationHasIncrementingId()
* Make a new related instance for the given model.
*
* @param \Illuminate\Database\Eloquent\Model $parent
* @return T
* @return TRelatedModel
*/
protected function newRelatedInstanceFor(Model $parent)
{
Expand All @@ -305,7 +306,7 @@ protected function newRelatedInstanceFor(Model $parent)
/**
* Get the child of the relationship.
*
* @return T
* @return TChildModel
*/
public function getChild()
{
Expand Down
21 changes: 11 additions & 10 deletions src/Illuminate/Database/Eloquent/Relations/MorphTo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
use Illuminate\Database\Eloquent\Relations\Concerns\InteractsWithDictionary;

/**
* @template T of \Illuminate\Database\Eloquent\Model
* @template TRelatedModel of \Illuminate\Database\Eloquent\Model
* @template TChildModel of \Illuminate\Database\Eloquent\Model
*
* @extends BelongsTo<T>
* @extends BelongsTo<TRelatedModel, TChildModel>
*/
class MorphTo extends BelongsTo
{
Expand Down Expand Up @@ -133,7 +134,7 @@ public function getEager()
* Get all of the relation results for a type.
*
* @param string $type
* @return \Illuminate\Database\Eloquent\Collection<mixed, T>
* @return \Illuminate\Database\Eloquent\Collection<mixed, TRelatedModel>
*/
protected function getResultsByType($type)
{
Expand Down Expand Up @@ -182,7 +183,7 @@ protected function gatherKeysByType($type, $keyType)
* Create a new model instance by type.
*
* @param string $type
* @return T
* @return TRelatedModel
*/
public function createModelByType($type)
{
Expand Down Expand Up @@ -232,7 +233,7 @@ protected function matchToMorphParents($type, Collection $results)
* Associate the model instance to the given parent.
*
* @param \Illuminate\Database\Eloquent\Model|null $model
* @return T
* @return TRelatedModel
*/
public function associate($model)
{
Expand All @@ -256,7 +257,7 @@ public function associate($model)
/**
* Dissociate previously associated model from the given parent.
*
* @return T
* @return TRelatedModel
*/
public function dissociate()
{
Expand All @@ -283,7 +284,7 @@ public function touch()
* Make a new related instance for the given model.
*
* @param \Illuminate\Database\Eloquent\Model $parent
* @return T
* @return TRelatedModel
*/
protected function newRelatedInstanceFor(Model $parent)
{
Expand Down Expand Up @@ -314,7 +315,7 @@ public function getDictionary()
* Specify which relations to load for a given morph type.
*
* @param array $with
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<T>
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel>
*/
public function morphWith(array $with)
{
Expand All @@ -329,7 +330,7 @@ public function morphWith(array $with)
* Specify which relationship counts to load for a given morph type.
*
* @param array $withCount
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<T>
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel>
*/
public function morphWithCount(array $withCount)
{
Expand All @@ -344,7 +345,7 @@ public function morphWithCount(array $withCount)
* Specify constraints on the query for a given morph type.
*
* @param array $callbacks
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<T>
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<TRelatedModel>
*/
public function constrain(array $callbacks)
{
Expand Down

0 comments on commit d29f0f9

Please sign in to comment.