diff --git a/build/psalm/ITypedQueryBuilderTest.php b/build/psalm/ITypedQueryBuilderTest.php index 7bd2a7a3f80c6..e9d6ddc3fe5cd 100644 --- a/build/psalm/ITypedQueryBuilderTest.php +++ b/build/psalm/ITypedQueryBuilderTest.php @@ -21,6 +21,38 @@ $qb->selectAlias('g', 'h'); $qb->selectAlias($qb->func()->lower('i'), 'j'); +$qb + ->setParameter('k', 'l') + ->setParameters([]) + ->setFirstResult(0) + ->setMaxResults(0) + ->delete() + ->update() + ->insert() + ->from('m') + ->join('n', 'o', 'p') + ->innerJoin('q', 'r', 's') + ->leftJoin('t', 'u', 'v') + ->rightJoin('w', 'x', 'y') + ->set('z', '1') + ->where() + ->andWhere() + ->orWhere() + ->groupBy() + ->addGroupBy() + ->setValue('2', '3') + ->values([]) + ->having() + ->andHaving() + ->orHaving() + ->orderBy('4') + ->addOrderBy('5') + ->resetQueryParts() + ->resetQueryPart('6') + ->hintShardKey('7', '8') + ->runAcrossAllShards() + ->forUpdate(); + /** @psalm-check-type-exact $result = \OCP\DB\IResult<'a'|'b'|'c'|'d'|'e'|'f'|'h'|'j'> */ $result = $qb->executeQuery(); diff --git a/lib/public/DB/QueryBuilder/ITypedQueryBuilder.php b/lib/public/DB/QueryBuilder/ITypedQueryBuilder.php index ea5daa2a71c26..1901a22e74940 100644 --- a/lib/public/DB/QueryBuilder/ITypedQueryBuilder.php +++ b/lib/public/DB/QueryBuilder/ITypedQueryBuilder.php @@ -37,7 +37,9 @@ public function select(...$selects); * @template NewS of string * @param NewS ...$columns The columns to select. They are not allowed to contain table names or aliases, or asterisks. Use {@see self::selectAlias()} for that. * @psalm-this-out self + * @return $this * @since 34.0.0 + * @note Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439 */ public function selectColumns(string ...$columns): self; @@ -52,7 +54,9 @@ public function selectDistinct($select); * @template NewS of string * @param NewS ...$columns The columns to select distinct. They are not allowed to contain table names or aliases, or asterisks. Use {@see self::selectAlias()} for that. * @psalm-this-out self + * @return $this * @since 34.0.0 + * @note Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439 */ public function selectColumnsDistinct(string ...$columns): self; @@ -69,8 +73,244 @@ public function addSelect(...$select); * @template NewS of string * @param NewS $alias * @psalm-this-out self - * @psalm-suppress LessSpecificImplementedReturnType + * @return $this + * @note Psalm has a bug that prevents inferring the correct type in chained calls: https://github.com/vimeo/psalm/issues/8803. Convert the chained calls to standalone calls or switch to PHPStan, which suffered the same bug in the past, but fixed it in 2.1.5: https://github.com/phpstan/phpstan/issues/8439 */ #[Override] public function selectAlias($select, $alias): self; + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function setParameter($key, $value, $type = null); + + /** + * @inheritDoc + * @return $this + */ + #[Override] + public function setParameters(array $params, array $types = []); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function setFirstResult($firstResult); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function setMaxResults($maxResults); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function delete($delete = null, $alias = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function update($update = null, $alias = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function insert($insert = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function from($from, $alias = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function join($fromAlias, $join, $alias, $condition = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function innerJoin($fromAlias, $join, $alias, $condition = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function leftJoin($fromAlias, $join, $alias, $condition = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function rightJoin($fromAlias, $join, $alias, $condition = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function set($key, $value); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function where(...$predicates); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function andWhere(...$where); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function orWhere(...$where); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function groupBy(...$groupBys); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function addGroupBy(...$groupBy); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function setValue($column, $value); + + /** + * @inheritDoc + * @return $this + */ + #[Override] + public function values(array $values); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function having(...$having); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function andHaving(...$having); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function orHaving(...$having); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function orderBy($sort, $order = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function addOrderBy($sort, $order = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function resetQueryParts($queryPartNames = null); + + /** + * @inheritDoc + * @return $this + * @psalm-suppress MissingParamType + */ + #[Override] + public function resetQueryPart($queryPartName); + + /** + * @inheritDoc + * @return $this + */ + #[Override] + public function hintShardKey(string $column, mixed $value, bool $overwrite = false): self; + + /** + * @inheritDoc + * @return $this + */ + #[Override] + public function runAcrossAllShards(): self; + + /** + * @inheritDoc + * @return $this + */ + #[Override] + public function forUpdate(ConflictResolutionMode $conflictResolutionMode = ConflictResolutionMode::Ordinary): self; }