Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ public function getModel()
/**
* Set the model to query
*
* @param TRow $model
* @template TNew of Model
* @phpstan-self-out static<TNew>
*
* @param TNew $model
*
* @return $this
*/
Expand Down Expand Up @@ -577,7 +580,7 @@ public function createHydrator(): Hydrator
* @param string $relation
* @param TRow $source
*
* @return static
* @return static<*>
*
* @throws InvalidArgumentException If the relation with the given name does not exist
*/
Expand All @@ -594,12 +597,14 @@ public function derive($relation, Model $source): static
/**
* Create a sub-query linked to rows of this query
*
* @param Model $target The model to query
* @template TTarget of Model
*
* @param TTarget $target The model to query
* @param string $targetPath The target's absolute relation path
* @param ?TRow $from The source model
* @param bool $link Whether the query should be linked to the parent query
*
* @return static
* @return static<TTarget>
*/
public function createSubQuery(Model $target, string $targetPath, ?Model $from = null, bool $link = true): static
{
Expand All @@ -617,9 +622,11 @@ public function createSubQuery(Model $target, string $targetPath, ?Model $from =
$subQuery->utilize($sourcePath); // TODO: Don't join if there's a matching foreign key

if (! $link) {
return $subQuery->columns(array_map(function ($keyName) use ($sourcePath) {
$subQuery->columns(array_map(function ($keyName) use ($sourcePath) {
return "$sourcePath.$keyName";
}, (array) $subQueryTarget->getKeyName()));

return $subQuery;
}

// TODO: Should be done by the caller. Though, that's not possible until we've got a filter abstraction
Expand Down
1 change: 1 addition & 0 deletions src/ResultSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function __construct(Traversable $traversable, ?int $limit = null)
* Create a new result set from the given query
*
* @template TQueryRow of Model
*
* @param Query<TQueryRow> $query
*
* @return static<TQueryRow>
Expand Down
Loading