diff --git a/src/Concerns/AddsFieldsToQuery.php b/src/Concerns/AddsFieldsToQuery.php index 63f39279..63cd8ad4 100644 --- a/src/Concerns/AddsFieldsToQuery.php +++ b/src/Concerns/AddsFieldsToQuery.php @@ -12,7 +12,7 @@ trait AddsFieldsToQuery { protected ?Collection $allowedFields = null; - public function allowedFields($fields): self + public function allowedFields($fields): static { if ($this->allowedIncludes instanceof Collection) { throw new AllowedFieldsMustBeCalledBeforeAllowedIncludes(); diff --git a/src/Concerns/AddsIncludesToQuery.php b/src/Concerns/AddsIncludesToQuery.php index edfd7d57..3e45fe9b 100644 --- a/src/Concerns/AddsIncludesToQuery.php +++ b/src/Concerns/AddsIncludesToQuery.php @@ -12,7 +12,7 @@ trait AddsIncludesToQuery { protected ?Collection $allowedIncludes = null; - public function allowedIncludes($includes): self + public function allowedIncludes($includes): static { $includes = is_array($includes) ? $includes : func_get_args(); diff --git a/src/Concerns/FiltersQuery.php b/src/Concerns/FiltersQuery.php index c376fbac..8361df06 100644 --- a/src/Concerns/FiltersQuery.php +++ b/src/Concerns/FiltersQuery.php @@ -10,7 +10,7 @@ trait FiltersQuery /** @var \Illuminate\Support\Collection */ protected $allowedFilters; - public function allowedFilters($filters): self + public function allowedFilters($filters): static { $filters = is_array($filters) ? $filters : func_get_args(); diff --git a/src/Concerns/SortsQuery.php b/src/Concerns/SortsQuery.php index 5d6f3e07..f8adf89d 100644 --- a/src/Concerns/SortsQuery.php +++ b/src/Concerns/SortsQuery.php @@ -10,7 +10,7 @@ trait SortsQuery /** @var \Illuminate\Support\Collection */ protected $allowedSorts; - public function allowedSorts($sorts): self + public function allowedSorts($sorts): static { if ($this->request->sorts()->isEmpty()) { // We haven't got any requested sorts. No need to parse allowed sorts. @@ -40,7 +40,7 @@ public function allowedSorts($sorts): self * * @return \Spatie\QueryBuilder\QueryBuilder */ - public function defaultSort($sorts): self + public function defaultSort($sorts): static { return $this->defaultSorts(func_get_args()); } @@ -50,7 +50,7 @@ public function defaultSort($sorts): self * * @return \Spatie\QueryBuilder\QueryBuilder */ - public function defaultSorts($sorts): self + public function defaultSorts($sorts): static { if ($this->request->sorts()->isNotEmpty()) { // We've got requested sorts. No need to parse defaults. diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 7c2ada40..93e9a702 100755 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -46,7 +46,7 @@ public function __construct($subject, ?Request $request = null) * * @return $this */ - protected function initializeSubject($subject): self + protected function initializeSubject($subject): static { throw_unless( $subject instanceof EloquentBuilder || $subject instanceof Relation, @@ -58,7 +58,7 @@ protected function initializeSubject($subject): self return $this; } - protected function initializeRequest(?Request $request = null): self + protected function initializeRequest(?Request $request = null): static { $this->request = $request ? QueryBuilderRequest::fromRequest($request) @@ -91,7 +91,7 @@ public function getSubject() * * @return static */ - public static function for($subject, ?Request $request = null): self + public static function for($subject, ?Request $request = null): static { if (is_subclass_of($subject, Model::class)) { $subject = $subject::query();