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

[11.x] Add multiple method signatures for where in PHPDoc block #54304

Draft
wants to merge 3 commits into
base: 11.x
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@

use function Illuminate\Support\enum_value;

/**
* @method self where(string $column, $value)
* @method self where(string $column, string $operator, $value)
* @method self where(string $column, string $operator, $value, 'and'|'or' $boolean)
* @method self where(\Closure(): mixed)
* @method self where(array<string, mixed> $column)
* @method self where((array{string, 'and'|'or', mixed}|array{string, mixed}|array{column: string, operator?: 'and'|'or', value: mixed})[] $column)
* @method self where(\Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column, mixed $operator null, mixed $value = null, string $boolean = 'and')
*/
Comment on lines +34 to +42
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last time I checked, which was around 6 months ago, a lot of tooling did not support literals / generics in @method docblocks.

Suggested change
/**
* @method self where(string $column, $value)
* @method self where(string $column, string $operator, $value)
* @method self where(string $column, string $operator, $value, 'and'|'or' $boolean)
* @method self where(\Closure(): mixed)
* @method self where(array<string, mixed> $column)
* @method self where((array{string, 'and'|'or', mixed}|array{string, mixed}|array{column: string, operator?: 'and'|'or', value: mixed})[] $column)
* @method self where(\Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column, mixed $operator null, mixed $value = null, string $boolean = 'and')
*/
/**
* @method self where(string $column, $value)
* @method self where(string $column, string $operator, $value)
* @method self where(string $column, string $operator, $value, string $boolean)
* @method self where(\Closure(): mixed)
* @method self where(array $column)
* @method self where(\Closure|string|array|\Illuminate\Contracts\Database\Query\Expression $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')
*/

class Builder implements BuilderContract
{
/** @use \Illuminate\Database\Concerns\BuildsQueries<object> */
Expand Down Expand Up @@ -1009,7 +1018,7 @@
$value, $operator, func_num_args() === 2
);

return $this->where($column, $operator, $value, 'or');

Check failure on line 1021 in src/Illuminate/Database/Query/Builder.php

View workflow job for this annotation

GitHub Actions / Source Code

Method Illuminate\Database\Query\Builder::where() invoked with 4 parameters, 1 required.
}

/**
Expand All @@ -1029,7 +1038,7 @@
}, $boolean.' not');
}

return $this->where($column, $operator, $value, $boolean.' not');

Check failure on line 1041 in src/Illuminate/Database/Query/Builder.php

View workflow job for this annotation

GitHub Actions / Source Code

Method Illuminate\Database\Query\Builder::where() invoked with 4 parameters, 1 required.
}

/**
Expand Down Expand Up @@ -2244,7 +2253,7 @@
// clause on the query. Then we'll increment the parameter index values.
$bool = strtolower($connector);

$this->where(Str::snake($segment), '=', $parameters[$index], $bool);

Check failure on line 2256 in src/Illuminate/Database/Query/Builder.php

View workflow job for this annotation

GitHub Actions / Source Code

Method Illuminate\Database\Query\Builder::where() invoked with 4 parameters, 1 required.
}

/**
Expand Down Expand Up @@ -2816,7 +2825,7 @@
$this->orders = $this->removeExistingOrdersFor($column);

if (! is_null($lastId)) {
$this->where($column, '<', $lastId);

Check failure on line 2828 in src/Illuminate/Database/Query/Builder.php

View workflow job for this annotation

GitHub Actions / Source Code

Method Illuminate\Database\Query\Builder::where() invoked with 3 parameters, 1 required.
}

return $this->orderBy($column, 'desc')
Expand All @@ -2836,7 +2845,7 @@
$this->orders = $this->removeExistingOrdersFor($column);

if (! is_null($lastId)) {
$this->where($column, '>', $lastId);

Check failure on line 2848 in src/Illuminate/Database/Query/Builder.php

View workflow job for this annotation

GitHub Actions / Source Code

Method Illuminate\Database\Query\Builder::where() invoked with 3 parameters, 1 required.
}

return $this->orderBy($column, 'asc')
Expand Down Expand Up @@ -3035,7 +3044,7 @@
*/
public function find($id, $columns = ['*'])
{
return $this->where('id', '=', $id)->first($columns);

Check failure on line 3047 in src/Illuminate/Database/Query/Builder.php

View workflow job for this annotation

GitHub Actions / Source Code

Method Illuminate\Database\Query\Builder::where() invoked with 3 parameters, 1 required.
}

/**
Expand Down Expand Up @@ -4058,7 +4067,7 @@
// ID to let developers to simply and quickly remove a single row from this
// database without manually specifying the "where" clauses on the query.
if (! is_null($id)) {
$this->where($this->from.'.id', '=', $id);

Check failure on line 4070 in src/Illuminate/Database/Query/Builder.php

View workflow job for this annotation

GitHub Actions / Source Code

Method Illuminate\Database\Query\Builder::where() invoked with 3 parameters, 1 required.
}

$this->applyBeforeQueryCallbacks();
Expand Down
Loading