Skip to content

Commit 28ab37f

Browse files
committed
phpstan fixes
1 parent a30d529 commit 28ab37f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Eloquent/Builder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use MongoDB\Laravel\Collection;
1212
use MongoDB\Laravel\Helpers\QueriesRelationships;
1313
use MongoDB\Laravel\Internal\FindAndModifyCommandSubscriber;
14+
use MongoDB\Laravel\Query\AggregationBuilder;
1415
use MongoDB\Model\BSONDocument;
1516
use MongoDB\Operation\FindOneAndUpdate;
1617

@@ -57,15 +58,15 @@ class Builder extends EloquentBuilder
5758
];
5859

5960
/**
60-
* @return ($function === null ? PipelineBuilder : self)
61+
* @return ($function is null ? AggregationBuilder : self)
6162
*
6263
* @inheritdoc
6364
*/
6465
public function aggregate($function = null, $columns = ['*'])
6566
{
6667
$result = $this->toBase()->aggregate($function, $columns);
6768

68-
return $result ?? $this;
69+
return $result ?: $this;
6970
}
7071

7172
/** @inheritdoc */

src/Query/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ private function getAggregationBuilder(): AggregationBuilder
301301
// Distinct query
302302
if ($this->distinct) {
303303
// Return distinct results directly
304-
$column = $columns[0] ?? '_id';
304+
$column = $this->columns[0] ?? '_id';
305305

306306
$agg->group(
307307
_id: \MongoDB\Builder\Expression::fieldPath($column),
@@ -596,7 +596,7 @@ public function generateCacheKey()
596596
return md5(serialize(array_values($key)));
597597
}
598598

599-
/** @return ($function === null ? PipelineBuilder : self) */
599+
/** @return ($function is null ? AggregationBuilder : mixed) */
600600
public function aggregate($function = null, $columns = [])
601601
{
602602
if ($function === null) {

0 commit comments

Comments
 (0)