Skip to content

Commit 839c5aa

Browse files
committed
Refactor setModel method to support chaining
The setModel method in the Query class has been refactored to support better chaining. Instead of creating a new Query instance with the new model, the existing Query instance is cloned, its model is updated, and then returned. This change aims to bring better consistency with other methods and improve the overall usability and predictability of the Query API. Moreover, it addresses the deprecation warning by conforming to the method signature.
1 parent 04118f7 commit 839c5aa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Query.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ public function getModel(): Model
247247
* @template TModel of Model
248248
*
249249
* @param Model $model Model to use for the current query.
250-
*
251250
* @psalm-param TModel $model
252251
*
253-
* @return self<TModel> Query builder instance for chaining.
252+
* @return static<TModel> Query builder instance for chaining.
254253
* @noinspection PhpDeprecationInspection
255254
*/
256-
public function setModel(Model $model): self
255+
public function setModel(Model $model): static
257256
{
257+
/** @var static<TModel> $query */
258258
$query = clone $this;
259259
$query->connection = $this->getConnection();
260260
$query->model = $model;

0 commit comments

Comments
 (0)