Skip to content

Commit

Permalink
Fix issue psalm yiisoft/active-record. (#457)
Browse files Browse the repository at this point in the history
Fix issue psalm yiisoft/active-record. (#457)
  • Loading branch information
terabytesoftw committed Jan 5, 2023
1 parent 92a4032 commit 9325f29
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 52 deletions.
80 changes: 40 additions & 40 deletions src/Query/Query.php
Expand Up @@ -98,7 +98,7 @@ public function __toString(): string
return serialize($this);
}

public function addGroupBy(array|string|ExpressionInterface $columns): self
public function addGroupBy(array|string|ExpressionInterface $columns): static
{
if ($columns instanceof ExpressionInterface) {
$columns = [$columns];
Expand All @@ -115,7 +115,7 @@ public function addGroupBy(array|string|ExpressionInterface $columns): self
return $this;
}

public function addOrderBy(array|string|ExpressionInterface $columns): self
public function addOrderBy(array|string|ExpressionInterface $columns): static
{
$columns = $this->createQueryHelper()->normalizeOrderBy($columns);

Expand All @@ -128,7 +128,7 @@ public function addOrderBy(array|string|ExpressionInterface $columns): self
return $this;
}

public function addParams(array $params): self
public function addParams(array $params): static
{
if (!empty($params)) {
if (empty($this->params)) {
Expand All @@ -151,7 +151,7 @@ public function addParams(array $params): self
return $this;
}

public function andFilterHaving(array $condition): self
public function andFilterHaving(array $condition): static
{
$condition = $this->filterCondition($condition);

Expand All @@ -162,7 +162,7 @@ public function andFilterHaving(array $condition): self
return $this;
}

public function andFilterWhere(array $condition): self
public function andFilterWhere(array $condition): static
{
$condition = $this->filterCondition($condition);

Expand All @@ -173,7 +173,7 @@ public function andFilterWhere(array $condition): self
return $this;
}

public function andHaving(array|string|ExpressionInterface $condition, array $params = []): self
public function andHaving(array|string|ExpressionInterface $condition, array $params = []): static
{
if ($this->having === null) {
$this->having = $condition;
Expand All @@ -186,7 +186,7 @@ public function andHaving(array|string|ExpressionInterface $condition, array $pa
return $this;
}

public function addSelect(array|string|ExpressionInterface $columns): self
public function addSelect(array|string|ExpressionInterface $columns): static
{
if ($this->select === []) {
return $this->select($columns);
Expand All @@ -197,7 +197,7 @@ public function addSelect(array|string|ExpressionInterface $columns): self
return $this;
}

public function andFilterCompare(string $name, string|null $value, string $defaultOperator = '='): self
public function andFilterCompare(string $name, string|null $value, string $defaultOperator = '='): static
{
$operator = $defaultOperator;

Expand All @@ -209,7 +209,7 @@ public function andFilterCompare(string $name, string|null $value, string $defau
return $this->andFilterWhere([$operator, $name, $value]);
}

public function andWhere($condition, array $params = []): self
public function andWhere($condition, array $params = []): static
{
if ($this->where === null) {
$this->where = $condition;
Expand Down Expand Up @@ -245,7 +245,7 @@ public function batch(int $batchSize = 100): BatchQueryResultInterface
return $this->db->createBatchQueryResult($this)->batchSize($batchSize);
}

public function cache(int|null $duration = 3600, Dependency $dependency = null): self
public function cache(int|null $duration = 3600, Dependency $dependency = null): static
{
$this->queryCacheDuration = $duration;
$this->queryCacheDependency = $dependency;
Expand Down Expand Up @@ -321,7 +321,7 @@ public function createCommand(): CommandInterface
return $command;
}

public function distinct(bool|null $value = true): self
public function distinct(bool|null $value = true): static
{
$this->distinct = $value;

Expand Down Expand Up @@ -350,14 +350,14 @@ public function exists(): bool
return (bool) $command->queryScalar();
}

public function emulateExecution(bool $value = true): self
public function emulateExecution(bool $value = true): static
{
$this->emulateExecution = $value;

return $this;
}

public function filterHaving(array $condition): self
public function filterHaving(array $condition): static
{
$condition = $this->filterCondition($condition);

Expand All @@ -368,7 +368,7 @@ public function filterHaving(array $condition): self
return $this;
}

public function filterWhere(array $condition): self
public function filterWhere(array $condition): static
{
$condition = $this->filterCondition($condition);

Expand All @@ -379,7 +379,7 @@ public function filterWhere(array $condition): self
return $this;
}

public function from(array|ExpressionInterface|string $tables): self
public function from(array|ExpressionInterface|string $tables): static
{
if ($tables instanceof ExpressionInterface) {
$tables = [$tables];
Expand Down Expand Up @@ -474,7 +474,7 @@ public function getWithQueries(): array
return $this->withQueries;
}

public function groupBy(array|string|ExpressionInterface $columns): self
public function groupBy(array|string|ExpressionInterface $columns): static
{
if ($columns instanceof ExpressionInterface) {
$columns = [$columns];
Expand All @@ -486,43 +486,43 @@ public function groupBy(array|string|ExpressionInterface $columns): self
return $this;
}

public function having(array|ExpressionInterface|string|null $condition, array $params = []): self
public function having(array|ExpressionInterface|string|null $condition, array $params = []): static
{
$this->having = $condition;
$this->addParams($params);

return $this;
}

public function indexBy(Closure|string|null $column): self
public function indexBy(Closure|string|null $column): static
{
$this->indexBy = $column;

return $this;
}

public function innerJoin(array|string $table, array|string $on = '', array $params = []): self
public function innerJoin(array|string $table, array|string $on = '', array $params = []): static
{
$this->join[] = ['INNER JOIN', $table, $on];

return $this->addParams($params);
}

public function join(string $type, array|string $table, array|string $on = '', array $params = []): self
public function join(string $type, array|string $table, array|string $on = '', array $params = []): static
{
$this->join[] = [$type, $table, $on];

return $this->addParams($params);
}

public function leftJoin(array|string $table, array|string $on = '', array $params = []): self
public function leftJoin(array|string $table, array|string $on = '', array $params = []): static
{
$this->join[] = ['LEFT JOIN', $table, $on];

return $this->addParams($params);
}

public function limit(Expression|int|null $limit): self
public function limit(Expression|int|null $limit): static
{
$this->limit = $limit;

Expand All @@ -543,14 +543,14 @@ public function min(string $q): int|float|null|string
return is_numeric($min) ? $min : null;
}

public function noCache(): self
public function noCache(): static
{
$this->queryCacheDuration = -1;

return $this;
}

public function offset(Expression|int|null $offset): self
public function offset(Expression|int|null $offset): static
{
$this->offset = $offset;

Expand All @@ -565,14 +565,14 @@ public function one(): array|object|null
};
}

public function orderBy(array|string|ExpressionInterface $columns): self
public function orderBy(array|string|ExpressionInterface $columns): static
{
$this->orderBy = $this->createQueryHelper()->normalizeOrderBy($columns);

return $this;
}

public function orFilterHaving(array $condition): self
public function orFilterHaving(array $condition): static
{
$condition = $this->filterCondition($condition);

Expand All @@ -583,7 +583,7 @@ public function orFilterHaving(array $condition): self
return $this;
}

public function orFilterWhere(array $condition): self
public function orFilterWhere(array $condition): static
{
$condition = $this->filterCondition($condition);

Expand All @@ -594,7 +594,7 @@ public function orFilterWhere(array $condition): self
return $this;
}

public function orHaving(array|string|ExpressionInterface $condition, array $params = []): self
public function orHaving(array|string|ExpressionInterface $condition, array $params = []): static
{
if ($this->having === null) {
$this->having = $condition;
Expand All @@ -607,7 +607,7 @@ public function orHaving(array|string|ExpressionInterface $condition, array $par
return $this;
}

public function orWhere(array|string|ExpressionInterface $condition, array $params = []): self
public function orWhere(array|string|ExpressionInterface $condition, array $params = []): static
{
if ($this->where === null) {
$this->where = $condition;
Expand All @@ -620,7 +620,7 @@ public function orWhere(array|string|ExpressionInterface $condition, array $para
return $this;
}

public function params(array $params): self
public function params(array $params): static
{
$this->params = $params;

Expand All @@ -646,12 +646,12 @@ public function populate(array $rows): array
return $result;
}

public function prepare(QueryBuilderInterface $builder): QueryInterface
public function prepare(QueryBuilderInterface $builder): static
{
return $this;
}

public function rightJoin(array|string $table, array|string $on = '', array $params = []): self
public function rightJoin(array|string $table, array|string $on = '', array $params = []): static
{
$this->join[] = ['RIGHT JOIN', $table, $on];

Expand All @@ -666,29 +666,29 @@ public function scalar(): bool|int|null|string|float
};
}

public function select(array|string|ExpressionInterface $columns, string $option = null): self
public function select(array|string|ExpressionInterface $columns, string $option = null): static
{
$this->select = $this->createQueryHelper()->normalizeSelect($columns);
$this->selectOption = $option;

return $this;
}

public function selectOption(string|null $value): self
public function selectOption(string|null $value): static
{
$this->selectOption = $value;

return $this;
}

public function setJoin(array $value): self
public function setJoin(array $value): static
{
$this->join = $value;

return $this;
}

public function setUnion(array $value): self
public function setUnion(array $value): static
{
$this->union = $value;

Expand All @@ -708,29 +708,29 @@ public function sum(string $q): int|float|null|string
};
}

public function union(QueryInterface|string $sql, bool $all = false): self
public function union(QueryInterface|string $sql, bool $all = false): static
{
$this->union[] = ['query' => $sql, 'all' => $all];

return $this;
}

public function where(array|string|ExpressionInterface|null $condition, array $params = []): self
public function where(array|string|ExpressionInterface|null $condition, array $params = []): static
{
$this->where = $condition;
$this->addParams($params);

return $this;
}

public function withQuery(QueryInterface|string $query, string $alias, bool $recursive = false): self
public function withQuery(QueryInterface|string $query, string $alias, bool $recursive = false): static
{
$this->withQueries[] = ['query' => $query, 'alias' => $alias, 'recursive' => $recursive];

return $this;
}

public function withQueries(array $withQueries): self
public function withQueries(array $withQueries): static
{
$this->withQueries = $withQueries;

Expand Down

0 comments on commit 9325f29

Please sign in to comment.