From 2354584c34e0f666210e1c91d20fafa57c328c82 Mon Sep 17 00:00:00 2001 From: pawelpawlik Date: Tue, 12 Sep 2023 10:01:30 +0200 Subject: [PATCH] IBX-5385 fix phpstan errors --- src/bundle/Core/Command/ReindexCommand.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/bundle/Core/Command/ReindexCommand.php b/src/bundle/Core/Command/ReindexCommand.php index 0705a3c7ad..bf46db80f2 100644 --- a/src/bundle/Core/Command/ReindexCommand.php +++ b/src/bundle/Core/Command/ReindexCommand.php @@ -6,13 +6,14 @@ */ namespace Ibexa\Bundle\Core\Command; +use ArrayIterator; use function count; use DateTime; use const DIRECTORY_SEPARATOR; use Generator; use Ibexa\Contracts\Core\Persistence\Content\Location\Handler; use Ibexa\Contracts\Core\Repository\ContentService; -use Ibexa\Contracts\Core\Repository\Values\Content\ContentList; +use Ibexa\Contracts\Core\Repository\Values\Content\Content; use Ibexa\Contracts\Core\Repository\Values\Content\Query; use Ibexa\Contracts\Core\Repository\Values\Filter\Filter; use Ibexa\Contracts\Core\Search\Content\IndexerGateway; @@ -84,6 +85,7 @@ public function __construct( $this->isDebug = $isDebug; $this->projectDir = $projectDir; $this->contentService = $contentService; + $this->phpPath = $phpPath; parent::__construct(); } @@ -275,9 +277,12 @@ protected function indexIncrementally( ->withCriterion( new Query\Criterion\ContentTypeIdentifier($contentType) ); + /** @var \Ibexa\Contracts\Core\Repository\Values\Content\ContentList $contentList */ $contentList = $this->contentService->find($filter); $count = $contentList->getTotalCount(); - $generator = $this->fetchIterationFromContentList($contentList, $iterationCount); + /** @var ArrayIterator $contentListIterator */ + $contentListIterator = $contentList->getIterator(); + $generator = $this->fetchIterationFromContentListIterator($contentListIterator, $iterationCount); $purge = false; } else { $count = $this->gateway->countAllContent(); @@ -478,13 +483,18 @@ public function getDeprecatedAliases(): array return ['ezplatform:reindex']; } - private function fetchIterationFromContentList(ContentList $contentList, int $iterationCount): Generator + /** + * @param ArrayIterator $contentListIterator + * @param int $iterationCount + * + * @return \Generator + */ + private function fetchIterationFromContentListIterator(ArrayIterator $contentListIterator, int $iterationCount): Generator { - $iterator = $contentList->getIterator(); do { $contentIds = []; for ($i = 0; $i < $iterationCount; ++$i) { - $content = $iterator->current(); + $content = $contentListIterator->current(); if ($content) { $contentIds[] = $content->id; } elseif (empty($contentIds)) { @@ -492,7 +502,7 @@ private function fetchIterationFromContentList(ContentList $contentList, int $it } else { break; } - $iterator->next(); + $contentListIterator->next(); } yield $contentIds;