Skip to content

Commit

Permalink
Relax Eloquent collection types
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Jan 8, 2025
1 parent cb5b81a commit bddcda9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Execution/ModelsLoader/ModelsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface ModelsLoader
*
* @template TModel of \Illuminate\Database\Eloquent\Model
*
* @param \Illuminate\Database\Eloquent\Collection<int, TModel> $parents
* @param \Illuminate\Database\Eloquent\Collection<array-key, TModel> $parents
*/
public function load(EloquentCollection $parents): void;

Expand Down
18 changes: 9 additions & 9 deletions src/Execution/ModelsLoader/PaginatedModelsLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public function extract(Model $model): mixed
}

/**
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $parents
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $parents
*
* @return \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model>
* @return \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model>
*/
protected function loadRelatedModels(EloquentCollection $parents): EloquentCollection
{
Expand Down Expand Up @@ -94,7 +94,7 @@ protected function loadRelatedModels(EloquentCollection $parents): EloquentColle
/**
* Use the underlying model to instantiate a relation by name.
*
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $parents
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $parents
*
* @return \Illuminate\Database\Eloquent\Relations\Relation<\Illuminate\Database\Eloquent\Model>
*/
Expand All @@ -108,7 +108,7 @@ protected function relationInstance(EloquentCollection $parents): Relation
/**
* Return a fresh instance of a query builder for the underlying model.
*
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $parents
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $parents
*
* @return \Illuminate\Database\Eloquent\Builder<\Illuminate\Database\Eloquent\Model>
*/
Expand All @@ -125,7 +125,7 @@ protected function newModelQuery(EloquentCollection $parents): EloquentBuilder
* Ensure the pivot relation is hydrated too, if it exists.
*
* @param \Illuminate\Database\Eloquent\Relations\Relation<\Illuminate\Database\Eloquent\Model> $relation
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $relatedModels
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $relatedModels
*/
protected function hydratePivotRelation(Relation $relation, EloquentCollection $relatedModels): void
{
Expand All @@ -142,7 +142,7 @@ protected function hydratePivotRelation(Relation $relation, EloquentCollection $
*
* This is necessary because we load models in a non-standard way in @see loadRelatedModels()
*
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $models
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $models
*/
protected function loadDefaultWith(EloquentCollection $models): void
{
Expand All @@ -164,8 +164,8 @@ protected function loadDefaultWith(EloquentCollection $models): void
/**
* Associate the collection of all fetched relationModels back with their parents.
*
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $parents
* @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $relatedModels
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $parents
* @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $relatedModels
*/
protected function associateRelationModels(EloquentCollection $parents, EloquentCollection $relatedModels): void
{
Expand All @@ -178,7 +178,7 @@ protected function associateRelationModels(EloquentCollection $parents, Eloquent
);
}

/** @param \Illuminate\Database\Eloquent\Collection<int, \Illuminate\Database\Eloquent\Model> $parents */
/** @param \Illuminate\Database\Eloquent\Collection<array-key, \Illuminate\Database\Eloquent\Model> $parents */
protected function convertRelationToPaginator(EloquentCollection $parents): void
{
$first = $this->paginationArgs->first;
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Defer/DeferDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function testDeferNestedRelationshipFields(): void

public function testDeferNestedListFields(): void
{
/** @var \Illuminate\Database\Eloquent\Collection<int, \Tests\Utils\Models\Company> $companies */
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \Tests\Utils\Models\Company> $companies */
$companies = factory(Company::class, 2)
->create()
->each(static function (Company $company): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function testResolveMorphToManyUsingInterfaces(): void
$post->user()->associate($user);
$post->save();

/** @var \Illuminate\Database\Eloquent\Collection<int, \Tests\Utils\Models\Tag> $postTags */
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \Tests\Utils\Models\Tag> $postTags */
$postTags = factory(Tag::class, 3)
->create()
->map(static function (Tag $tag) use ($post): Tag {
Expand All @@ -217,7 +217,7 @@ public function testResolveMorphToManyUsingInterfaces(): void
$task->user()->associate($user);
$task->save();

/** @var \Illuminate\Database\Eloquent\Collection<int, \Tests\Utils\Models\Tag> $taskTags */
/** @var \Illuminate\Database\Eloquent\Collection<array-key, \Tests\Utils\Models\Tag> $taskTags */
$taskTags = factory(Tag::class, 3)
->create()
->map(static function (Tag $tag) use ($task): Tag {
Expand Down

0 comments on commit bddcda9

Please sign in to comment.