diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c63300cc05..0c8ef97e92 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -319,7 +319,18 @@ parameters: message: "#^Property Ibexa\\\\Bundle\\\\Core\\\\Command\\\\ReindexCommand\\:\\:\\$phpPath \\(string\\) does not accept string\\|null\\.$#" count: 2 path: src/bundle/Core/Command/ReindexCommand.php - + - + message: "#^Call to an undefined method iterable\\\\&Traversable\\:\\:valid\\(\\)\\.$#" + count: 1 + path: src/bundle/Core/Command/ReindexCommand.php + - + message: "#^Call to an undefined method iterable\\\\&Traversable\\:\\:current\\(\\)\\.$#" + count: 1 + path: src/bundle/Core/Command/ReindexCommand.php + - + message: "#^Call to an undefined method iterable\\\\&Traversable\\:\\:next\\(\\)\\.$#" + count: 1 + path: src/bundle/Core/Command/ReindexCommand.php - message: "#^Access to an undefined property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ValueObject\\:\\:\\$fields\\.$#" count: 1 diff --git a/src/bundle/Core/Command/ReindexCommand.php b/src/bundle/Core/Command/ReindexCommand.php index 1d0be4eec7..e40f20dbaf 100644 --- a/src/bundle/Core/Command/ReindexCommand.php +++ b/src/bundle/Core/Command/ReindexCommand.php @@ -481,16 +481,17 @@ public function getDeprecatedAliases(): array private function fetchIterationFromContentList(ContentList $contentList, int $iterationCount): Generator { - $i = 1; - $contentIds = []; - foreach ($contentList as $content) { - $contentIds[] = $content->id; - if ($iterationCount <= $i) { - break; + $contentListIterator = $contentList->getIterator(); + + while ($contentListIterator->valid()) { + $contentIds = []; + for ($i = 0; $i < $iterationCount; ++$i) { + $contentIds[] = $contentListIterator->current()->id; + $contentListIterator->next(); } - ++$i; + + yield $contentIds; } - yield $contentIds; } }