refactor(QueryBuilder): Properly type the query builder#57763
refactor(QueryBuilder): Properly type the query builder#57763CarlSchwan wants to merge 1 commit intomasterfrom
Conversation
4949aa8 to
27c24e9
Compare
75af4a1 to
ca05129
Compare
lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
Outdated
Show resolved
Hide resolved
| parent::innerJoin($fromAlias, $join, $alias, $condition); | ||
| return $this; |
There was a problem hiding this comment.
I think if you properly type the methods with @return $this in phpdoc you do not need to split all these return parent::… into 2 lines, as $this of self and parent is the same.
97b14e1 to
efaca86
Compare
And make sure the related unit tests are also typed and checked by psalm. Signed-off-by: Carl Schwan <carlschwan@kde.org>
efaca86 to
4020f91
Compare
provokateurin
left a comment
There was a problem hiding this comment.
Please add all files you touched to psalm:strict and rector:strict. That will probably result in some more issues being found, but I think it's worth fixing them in such an important part of our codebase.
| @@ -326,17 +325,17 @@ public function setFirstResult($firstResult); | |||
| * @return int The position of the first result. | |||
| * @since 8.2.0 | |||
| */ | |||
| public function getFirstResult(); | |||
| public function getFirstResult(): int; | |||
|
|
|||
| /** | |||
| * Sets the maximum number of results to retrieve (the "limit"). | |||
| * | |||
| * @param int|null $maxResults The maximum number of results to retrieve. | |||
There was a problem hiding this comment.
| * @param int|null $maxResults The maximum number of results to retrieve. | |
| * @param positive-int|null $maxResults The maximum number of results to retrieve. |
|
|
||
| /** | ||
| * Gets all defined query parameter types for the query being constructed indexed by parameter index or name. | ||
| * | ||
| * @return array The currently defined query parameter types indexed by parameter index or name. | ||
| * @return list<self::PARAM_*> The currently defined query parameter types indexed by parameter index or name. |
There was a problem hiding this comment.
| * @return list<self::PARAM_*> The currently defined query parameter types indexed by parameter index or name. | |
| * @return array<string|int, self::PARAM_*> The currently defined query parameter types indexed by parameter index or name. |
| @@ -267,47 +266,47 @@ public function setParameter($key, $value, $type = null); | |||
| * | |||
| * @param array $params The query parameters to set. | |||
| * @param array $types The query parameters types to set. | |||
There was a problem hiding this comment.
| * @param array $types The query parameters types to set. | |
| * @param array<string|int, mixed> $params The query parameters to set. | |
| * @param array<string|int, self::PARAM_*> $types The query parameters types to set. |
There was a problem hiding this comment.
| * @param non-negative-int $firstResult The first result to return. |
| @@ -345,7 +344,7 @@ public function setMaxResults($maxResults); | |||
| * @return int|null The maximum number of results. | |||
There was a problem hiding this comment.
| * @return int|null The maximum number of results. | |
| * @return positive-int|null The maximum number of results. |
| * @return $this This QueryBuilder instance. | ||
| * | ||
| * @see where() | ||
| * @since 8.2.0 | ||
| * | ||
| * @psalm-taint-sink sql $where | ||
| */ | ||
| public function orWhere(...$where); | ||
| public function orWhere(...$where): self; |
There was a problem hiding this comment.
| public function orWhere(...$where): self; | |
| public function orWhere(mixed ...$where): self; |
| * @since 8.2.0 | ||
| * | ||
| * @psalm-taint-sink sql $groupBys | ||
| */ | ||
| public function groupBy(...$groupBys); | ||
| public function groupBy(...$groupBys): self; |
There was a problem hiding this comment.
| public function groupBy(...$groupBys): self; | |
| public function groupBy(mixed ...$groupBys): self; |
| * @since 8.2.0 | ||
| * | ||
| * @psalm-taint-sink sql $groupby | ||
| */ | ||
| public function addGroupBy(...$groupBy); | ||
| public function addGroupBy(...$groupBy): self; |
There was a problem hiding this comment.
| public function addGroupBy(...$groupBy): self; | |
| public function addGroupBy(mixed ...$groupBy): self; |
| * @since 8.2.0 | ||
| * | ||
| * @psalm-taint-sink sql $having | ||
| */ | ||
| public function having(...$having); | ||
| public function having(...$having): self; |
There was a problem hiding this comment.
| public function having(...$having): self; | |
| public function having(mixed ...$having): self; |
There was a problem hiding this comment.
mixed should be replaced by string|IParameter|IQueryFunction|ILiteral in almost all places.
Also non-empty-string could be used on most methods, but it's not that important.
Summary
TODO
Checklist
3. to review, feature component)stable32)