Skip to content

Commit

Permalink
static return type when returning $this
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzolosa committed Jun 3, 2022
1 parent 8dcf144 commit 51005e1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
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

0 comments on commit 51005e1

Please sign in to comment.