Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static return type when returning $this #775

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Concerns/AddsFieldsToQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/AddsIncludesToQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion src/Concerns/FiltersQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions src/Concerns/SortsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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());
}
Expand All @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand Down