| 1 | <?php |
||
| 2 | namespace Kir\MySQL\Builder\Traits; |
||
| 3 | |||
| 4 | use Closure; |
||
| 5 | use Kir\MySQL\Builder\Helpers\ConditionAddHelper; |
||
| 6 | use Kir\MySQL\Builder\Internal\ConditionBuilder; |
||
| 7 | use Kir\MySQL\Builder\Internal\Types; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @phpstan-import-type DBParameterValueType from Types |
||
| 11 | * @phpstan-import-type DBWhereExpressionType from Types |
||
| 12 | */ |
||
| 13 | trait WhereBuilder { |
||
| 14 | use AbstractDB; |
||
| 15 | |||
| 16 | /** @var array<int, array{DBWhereExpressionType, list<DBParameterValueType>}> */ |
||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||
| 17 | private array $where = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @param DBWhereExpressionType $expression |
||
|
0 ignored issues
–
show
The type
Kir\MySQL\Builder\Traits\DBWhereExpressionType was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 21 | * @param DBParameterValueType ...$args |
||
|
0 ignored issues
–
show
The type
Kir\MySQL\Builder\Traits\DBParameterValueType was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 22 | * @return $this |
||
| 23 | */ |
||
| 24 | public function where($expression, ...$args) { |
||
| 25 | /** @var Closure(DBWhereExpressionType, list<DBParameterValueType>):void $fn */ |
||
| 26 | $fn = fn($expression, $args) => $this->where[] = [$expression, $args]; |
||
| 27 | ConditionAddHelper::addCondition($fn, $expression, $args); |
||
| 28 | return $this; |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param string $query |
||
| 33 | * @return string |
||
| 34 | */ |
||
| 35 | protected function buildWhereConditions(string $query): string { |
||
| 36 | return ConditionBuilder::build($this->db(), $query, $this->where, 'WHERE'); |
||
| 37 | } |
||
| 38 | } |
||
| 39 |