From d9a5eaa2dc9ba26cc7e563b765e16bc498cc70ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Mon, 2 Oct 2023 10:24:21 +0200 Subject: [PATCH] Fixed issues reported by phpstan --- src/bundle/ApiLoader/BoostFactorProviderFactory.php | 5 +++++ src/bundle/ApiLoader/IndexingDepthProviderFactory.php | 5 +++++ .../Common/CriterionVisitor/ContentTypeIdentifierIn.php | 2 +- src/lib/Query/Content/CriterionVisitor/Ancestor.php | 2 +- src/lib/Query/Location/CriterionVisitor/Ancestor.php | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/bundle/ApiLoader/BoostFactorProviderFactory.php b/src/bundle/ApiLoader/BoostFactorProviderFactory.php index 7cf24a26..58298482 100644 --- a/src/bundle/ApiLoader/BoostFactorProviderFactory.php +++ b/src/bundle/ApiLoader/BoostFactorProviderFactory.php @@ -7,6 +7,7 @@ namespace Ibexa\Bundle\Solr\ApiLoader; use Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider; +use Ibexa\Solr\FieldMapper\BoostFactorProvider; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; @@ -48,6 +49,10 @@ public function __construct( public function buildService() { + if ($this->container === null) { + return new BoostFactorProvider(); + } + $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig(); $connection = $this->defaultConnection; diff --git a/src/bundle/ApiLoader/IndexingDepthProviderFactory.php b/src/bundle/ApiLoader/IndexingDepthProviderFactory.php index 8f46fe3b..631e69aa 100644 --- a/src/bundle/ApiLoader/IndexingDepthProviderFactory.php +++ b/src/bundle/ApiLoader/IndexingDepthProviderFactory.php @@ -9,6 +9,7 @@ namespace Ibexa\Bundle\Solr\ApiLoader; use Ibexa\Bundle\Core\ApiLoader\RepositoryConfigurationProvider; +use Ibexa\Solr\FieldMapper\IndexingDepthProvider; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; @@ -43,6 +44,10 @@ public function __construct( public function buildService() { + if ($this->container === null) { + return new IndexingDepthProvider(); + } + $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig(); $connection = $this->defaultConnection; diff --git a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php index f29df011..ccf4b805 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php @@ -70,7 +70,7 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) foreach ($criterion->value as $identifier) { try { - $validIds[] = $contentTypeHandler->loadByIdentifier($identifier)->id; + $validIds[] = $contentTypeHandler->loadByIdentifier((string) $identifier)->id; } catch (NotFoundException $e) { // Filter out non-existing content types, but track for code below $invalidIdentifiers[] = $identifier; diff --git a/src/lib/Query/Content/CriterionVisitor/Ancestor.php b/src/lib/Query/Content/CriterionVisitor/Ancestor.php index eaab4210..09442036 100644 --- a/src/lib/Query/Content/CriterionVisitor/Ancestor.php +++ b/src/lib/Query/Content/CriterionVisitor/Ancestor.php @@ -36,7 +36,7 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) { $idSet = []; foreach ($criterion->value as $value) { - foreach (explode('/', trim($value, '/')) as $id) { + foreach (explode('/', trim((string)$value, '/')) as $id) { $idSet[$id] = true; } } diff --git a/src/lib/Query/Location/CriterionVisitor/Ancestor.php b/src/lib/Query/Location/CriterionVisitor/Ancestor.php index b7aafb45..86f1be4e 100644 --- a/src/lib/Query/Location/CriterionVisitor/Ancestor.php +++ b/src/lib/Query/Location/CriterionVisitor/Ancestor.php @@ -36,7 +36,7 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) { $idSet = []; foreach ($criterion->value as $value) { - foreach (explode('/', trim($value, '/')) as $id) { + foreach (explode('/', trim((string)$value, '/')) as $id) { $idSet[$id] = true; } }