Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use CursorInterface type instead of Cursor #2546

Closed
wants to merge 1 commit into from
Closed
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
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 @@
$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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW branch 2.6.x requires php ^8.0 while this is valid starting with 8.1. But maybe we could bump requirement to 8.1, 8.0 usage in 2.5.x is rather minimal: https://packagist.org/packages/doctrine/mongodb-odm/php-stats#2.5

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No objections to bumping to PHP 8.1 from my end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumped in #2556

{
if ($this->classMetadata) {
$cursor = new HydratingIterator($cursor, $this->dm->getUnitOfWork(), $this->classMetadata);
Expand Down
Loading