Skip to content

Eloquent generics #54573

Closed
Closed
@rcerljenko

Description

@rcerljenko

Laravel Version

11.42.0

PHP Version

8.4.3

Database Driver & Version

No response

Description

Hi,

With the latest update we started to receive these errors.

This scope is a part of the trait that any model can use.

public function scopeSearch(Builder $query, ?string $search = null): Builder
{
	return $query->whereHas('user', static function (Builder $query) use ($search): void {
		/**
		 * @var Builder<static> $query
		 */
		$query->search($search);
	});
}
PHPDoc tag @var with type Illuminate\Database\Eloquent\Builder<static(App\Models\Admin)> is not subtype of native type Illuminate\Database\Eloquent\Builder<Illuminate\Database\Eloquent\Model>.
- varTag.nativeType

Steps To Reproduce

Copy this code in a trait and use it on some model.

public function scopeSearch(Builder $query, ?string $search = null): Builder
{
	return $query->whereHas('user', static function (Builder $query) use ($search): void {
		/**
		 * @var Builder<static> $query
		 */
		$query->search($search);
	});
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions