Skip to content

Commit

Permalink
Aggregation uses CursorInterface instead of Cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 6, 2023
1 parent 69e64e7 commit 64ec92e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
use IteratorAggregate;
use MongoDB\Collection;
use MongoDB\Driver\Cursor;
use MongoDB\Driver\CursorInterface;

use function array_merge;
use function assert;

/** @psalm-import-type PipelineExpression from Builder */
final class Aggregation implements IteratorAggregate
Expand All @@ -35,12 +34,11 @@ public function getIterator(): Iterator
$options = array_merge($this->options, ['cursor' => true]);

$cursor = $this->collection->aggregate($this->pipeline, $options);
assert($cursor instanceof Cursor);

return $this->prepareIterator($cursor);

Check failure on line 38 in lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php

View workflow job for this annotation

GitHub Actions / Static Analysis with PHPStan (8.2)

Parameter #1 $cursor of method Doctrine\ODM\MongoDB\Aggregation\Aggregation::prepareIterator() expects Doctrine\ODM\MongoDB\Iterator\Iterator&MongoDB\Driver\CursorInterface, Traversable given.
}

private function prepareIterator(Cursor $cursor): Iterator
private function prepareIterator(CursorInterface&Iterator $cursor): Iterator
{
if ($this->classMetadata) {
$cursor = new HydratingIterator($cursor, $this->dm->getUnitOfWork(), $this->classMetadata);
Expand Down

0 comments on commit 64ec92e

Please sign in to comment.