From 4248a31398ee6445d977372f82faedd869229b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Parafi=C5=84ski?= Date: Tue, 10 Dec 2024 17:21:33 +0100 Subject: [PATCH] IBX-8534: Changed typehint from abstract Criterion to CriterionInterface (#80) * IBX-8534: Changed typehint from abstract Criterion to CriterionInterface * Cleaned up baseline * fixed codestyle * Dropped removed isPublished property * added status property * added more concrete ternary operator check * added null check for query::query --- phpstan-baseline.neon | 20 ------------------- src/contracts/Query/CriterionVisitor.php | 7 +++---- src/lib/CoreFilter/NativeCoreFilter.php | 14 +++++++------ src/lib/Handler.php | 2 +- .../Common/CriterionVisitor/Aggregate.php | 7 ++++--- .../CriterionVisitor/BaseIsContainer.php | 8 ++++++-- .../CriterionVisitor/CompositeCriterion.php | 10 +++++++--- .../Common/CriterionVisitor/ContentIdIn.php | 6 ++++-- .../CriterionVisitor/ContentTypeGroupIdIn.php | 6 ++++-- .../CriterionVisitor/ContentTypeIdIn.php | 6 ++++-- .../ContentTypeIdentifierIn.php | 6 ++++-- .../CustomField/CustomFieldIn.php | 6 ++++-- .../CustomField/CustomFieldRange.php | 6 ++++-- .../DateMetadata/ModifiedBetween.php | 6 ++++-- .../DateMetadata/ModifiedIn.php | 6 ++++-- .../DateMetadata/PublishedBetween.php | 6 ++++-- .../DateMetadata/PublishedIn.php | 6 ++++-- .../CriterionVisitor/Field/FieldEmpty.php | 6 ++++-- .../Common/CriterionVisitor/Field/FieldIn.php | 7 ++++--- .../CriterionVisitor/Field/FieldLike.php | 7 ++++--- .../CriterionVisitor/Field/FieldRange.php | 11 +++++----- .../CriterionVisitor/Field/FieldRelation.php | 11 +++++----- .../Common/CriterionVisitor/IsUserEnabled.php | 8 ++++++-- .../CriterionVisitor/LanguageCodeIn.php | 6 ++++-- .../Common/CriterionVisitor/LogicalAnd.php | 6 ++++-- .../Common/CriterionVisitor/LogicalNot.php | 6 ++++-- .../Common/CriterionVisitor/LogicalOr.php | 6 ++++-- .../Common/CriterionVisitor/MapLocation.php | 3 ++- .../MapLocation/MapLocationDistanceIn.php | 7 ++++--- .../MapLocation/MapLocationDistanceRange.php | 7 ++++--- .../Common/CriterionVisitor/MatchAll.php | 6 ++++-- .../Common/CriterionVisitor/MatchNone.php | 6 ++++-- .../CriterionVisitor/ObjectStateIdIn.php | 6 ++++-- .../ObjectStateIdentifierIn.php | 8 ++++++-- .../Common/CriterionVisitor/RemoteIdIn.php | 6 ++++-- .../CriterionVisitor/SectionIdentifierIn.php | 8 ++++++-- .../Common/CriterionVisitor/SectionIn.php | 6 ++++-- .../Common/CriterionVisitor/UserEmailIn.php | 8 ++++++-- .../Common/CriterionVisitor/UserIdIn.php | 8 ++++++-- .../Common/CriterionVisitor/UserLoginIn.php | 8 ++++++-- .../CriterionVisitor/UserMetadataIn.php | 6 ++++-- .../QueryConverter/NativeQueryConverter.php | 4 ++-- .../Content/CriterionVisitor/Ancestor.php | 6 ++++-- .../Content/CriterionVisitor/ContentName.php | 8 ++++++-- .../Content/CriterionVisitor/FullText.php | 6 ++++-- .../Content/CriterionVisitor/LocationIdIn.php | 6 ++++-- .../CriterionVisitor/LocationRemoteIdIn.php | 6 ++++-- .../CriterionVisitor/ParentLocationIdIn.php | 6 ++++-- .../Content/CriterionVisitor/SubtreeIn.php | 9 +++++---- .../Content/CriterionVisitor/Visibility.php | 7 +++++-- .../AbstractImageRangeVisitor.php | 7 +++++-- .../AbstractImageTermsVisitor.php | 7 +++++-- .../CriterionVisitor/AbstractImageVisitor.php | 6 ++++-- .../Query/Image/CriterionVisitor/FileSize.php | 3 ++- .../Query/Image/CriterionVisitor/Height.php | 3 ++- .../Query/Image/CriterionVisitor/MimeType.php | 3 ++- .../Image/CriterionVisitor/Orientation.php | 3 ++- .../Query/Image/CriterionVisitor/Width.php | 3 ++- .../Location/CriterionVisitor/Ancestor.php | 6 ++++-- .../Location/CriterionVisitor/FullText.php | 3 ++- .../Location/DepthBetween.php | 6 ++++-- .../CriterionVisitor/Location/DepthIn.php | 6 ++++-- .../Location/IsBookmarked.php | 8 ++++++-- .../Location/IsMainLocation.php | 6 ++++-- .../Location/PriorityBetween.php | 6 ++++-- .../CriterionVisitor/Location/PriorityIn.php | 6 ++++-- .../CriterionVisitor/LocationIdIn.php | 6 ++++-- .../CriterionVisitor/LocationRemoteIdIn.php | 6 ++++-- .../CriterionVisitor/ParentLocationIdIn.php | 6 ++++-- .../Location/CriterionVisitor/SubtreeIn.php | 6 ++++-- .../Location/CriterionVisitor/Visibility.php | 6 ++++-- .../ResultExtractor/NativeResultExtractor.php | 2 +- 72 files changed, 294 insertions(+), 173 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2993acd5..0fc44f74 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -255,11 +255,6 @@ parameters: count: 1 path: src/lib/CoreFilter/NativeCoreFilter.php - - - message: "#^Method Ibexa\\\\Solr\\\\CoreFilter\\\\NativeCoreFilter\\:\\:getLanguageFilter\\(\\) should return Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion but returns Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\\\CustomField\\|Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\\\LogicalAnd\\|Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\\\LogicalNot\\|Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\\\LogicalOr\\|false\\.$#" - count: 1 - path: src/lib/CoreFilter/NativeCoreFilter.php - - message: "#^Parameter \\#2 \\$languageCode of method Ibexa\\\\Solr\\\\DocumentMapper\\\\NativeDocumentMapper\\:\\:generateContentDocumentId\\(\\) expects string\\|null, int\\|string given\\.$#" count: 1 @@ -785,16 +780,6 @@ parameters: count: 1 path: src/lib/Query/Common/CriterionVisitor/Aggregate.php - - - message: "#^Access to an undefined property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\:\\:\\$criteria\\.$#" - count: 1 - path: src/lib/Query/Common/CriterionVisitor/CompositeCriterion.php - - - - message: "#^Cannot call method visit\\(\\) on Ibexa\\\\Contracts\\\\Solr\\\\Query\\\\CriterionVisitor\\|null\\.$#" - count: 1 - path: src/lib/Query/Common/CriterionVisitor/CompositeCriterion.php - - message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\\\|bool\\|float\\|int\\|string given\\.$#" count: 1 @@ -1080,11 +1065,6 @@ parameters: count: 1 path: src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php - - - message: "#^Instanceof between Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion and Ibexa\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Query\\\\Criterion\\\\PermissionSubtree will always evaluate to false\\.$#" - count: 1 - path: src/lib/Query/Content/CriterionVisitor/SubtreeIn.php - - message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\\\|bool\\|float\\|int\\|string given\\.$#" count: 1 diff --git a/src/contracts/Query/CriterionVisitor.php b/src/contracts/Query/CriterionVisitor.php index 8e5d45c9..1d50bf4f 100644 --- a/src/contracts/Query/CriterionVisitor.php +++ b/src/contracts/Query/CriterionVisitor.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; /** * Visits the criterion tree into a Solr query. @@ -20,16 +21,14 @@ abstract class CriterionVisitor * * @return bool */ - abstract public function canVisit(Criterion $criterion); + abstract public function canVisit(CriterionInterface $criterion); /** * Map field value to a proper Solr representation. * - * @param CriterionVisitor $subVisitor - * * @return string */ - abstract public function visit(Criterion $criterion, self $subVisitor = null); + abstract public function visit(CriterionInterface $criterion, self $subVisitor = null); /** * Get Solr range. diff --git a/src/lib/CoreFilter/NativeCoreFilter.php b/src/lib/CoreFilter/NativeCoreFilter.php index 09843a5a..e7d1480c 100644 --- a/src/lib/CoreFilter/NativeCoreFilter.php +++ b/src/lib/CoreFilter/NativeCoreFilter.php @@ -8,7 +8,6 @@ namespace Ibexa\Solr\CoreFilter; use Ibexa\Contracts\Core\Repository\Values\Content\Query; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\CustomField; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalNot; @@ -16,6 +15,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; use Ibexa\Solr\CoreFilter; use Ibexa\Solr\Gateway\EndpointResolver; +use RuntimeException; /** * Native core filter handles:. @@ -132,7 +132,7 @@ private function getCoreCriterion( array $languageCodes, bool $useAlwaysAvailable, bool $excludeTranslationsFromAlwaysAvailable = true - ): Criterion { + ): Query\CriterionInterface { // Handle languages if given if (!empty($languageCodes)) { // Get condition for prioritized languages fallback @@ -164,10 +164,8 @@ private function getCoreCriterion( * Returns criteria for prioritized languages fallback. * * @param string[] $languageCodes - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion */ - private function getLanguageFilter(array $languageCodes) + private function getLanguageFilter(array $languageCodes): Query\CriterionInterface { $languageFilters = []; @@ -209,6 +207,10 @@ private function getLanguageFilter(array $languageCodes) return new LogicalAnd($languageFilters); } + if (empty($languageFilters)) { + throw new RuntimeException('$languageFilters is empty'); + } + return reset($languageFilters); } @@ -220,7 +222,7 @@ private function getLanguageFilter(array $languageCodes) private function getAlwaysAvailableFilter( array $languageCodes, bool $excludeTranslationsFromAlwaysAvailable = true - ): Criterion { + ): Query\CriterionInterface { $excludeOnField = $excludeTranslationsFromAlwaysAvailable // Exclude all translations by given languages ? self::FIELD_LANGUAGES diff --git a/src/lib/Handler.php b/src/lib/Handler.php index 3c98a295..c6be953a 100644 --- a/src/lib/Handler.php +++ b/src/lib/Handler.php @@ -173,7 +173,7 @@ public function findContent(Query $query, array $languageFilter = []) * * @return \Ibexa\Contracts\Core\Persistence\Content */ - public function findSingle(Criterion $filter, array $languageFilter = []) + public function findSingle(Query\CriterionInterface $filter, array $languageFilter = []) { $query = new Query(); $query->filter = $filter; diff --git a/src/lib/Query/Common/CriterionVisitor/Aggregate.php b/src/lib/Query/Common/CriterionVisitor/Aggregate.php index 4ae77397..cd5c3796 100644 --- a/src/lib/Query/Common/CriterionVisitor/Aggregate.php +++ b/src/lib/Query/Common/CriterionVisitor/Aggregate.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -48,7 +49,7 @@ public function addVisitor(CriterionVisitor $visitor) * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return true; } @@ -62,7 +63,7 @@ public function canVisit(Criterion $criterion) * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { foreach ($this->visitors as $visitor) { if ($visitor->canVisit($criterion)) { @@ -70,6 +71,6 @@ public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) } } - throw new NotImplementedException('No visitor available for: ' . \get_class($criterion) . ' with operator ' . $criterion->operator); + throw new NotImplementedException('No visitor available for: ' . \get_class($criterion)); } } diff --git a/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php b/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php index 210033c9..f79f8acb 100644 --- a/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php +++ b/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -19,12 +20,15 @@ abstract class BaseIsContainer extends CriterionVisitor { abstract protected function getTargetField(): string; - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\IsContainer && $criterion->operator === Operator::EQ; } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsContainer $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { $value = $criterion->value; diff --git a/src/lib/Query/Common/CriterionVisitor/CompositeCriterion.php b/src/lib/Query/Common/CriterionVisitor/CompositeCriterion.php index 6647bec4..008ebc50 100644 --- a/src/lib/Query/Common/CriterionVisitor/CompositeCriterion.php +++ b/src/lib/Query/Common/CriterionVisitor/CompositeCriterion.php @@ -9,17 +9,21 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; final class CompositeCriterion extends CriterionVisitor { - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\CompositeCriterion; } - public function visit(Criterion $criterion, ?CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\CompositeCriterion $criterion + */ + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { - return $subVisitor->visit($criterion->criteria, $subVisitor); + return $subVisitor?->visit($criterion->criteria, $subVisitor) ?? ''; } } diff --git a/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php b/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php index 84c8a2eb..bf8d08c7 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class ContentIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\ContentId && @@ -34,11 +35,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentId $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php b/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php index 5d194d1e..dc821cc2 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class ContentTypeGroupIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\ContentTypeGroupId && @@ -34,11 +35,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeGroupId $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php index e276f698..59b941a5 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class ContentTypeIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\ContentTypeId && @@ -34,11 +35,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeId $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php index 820585f1..e29008d7 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php @@ -11,6 +11,7 @@ use Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; @@ -46,7 +47,7 @@ public function __construct(Handler $contentTypeHandler, LoggerInterface $logger * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\ContentTypeIdentifier @@ -59,11 +60,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $validIds = []; $invalidIdentifiers = []; diff --git a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php index d66a0b1b..75f02028 100644 --- a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php +++ b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class CustomFieldIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\CustomField && @@ -36,10 +37,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\CustomField $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $queries = []; $values = (array)$criterion->value; diff --git a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php index 880f6904..42865ca8 100644 --- a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php +++ b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class CustomFieldRange extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\CustomField && @@ -37,11 +38,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\CustomField $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $values = (array)$criterion->value; $start = $values[0]; diff --git a/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php b/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php index 532e9163..f46a5364 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Solr\Query\Common\CriterionVisitor\DateMetadata; @@ -22,7 +23,7 @@ class ModifiedBetween extends DateMetadata * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\DateMetadata && @@ -37,11 +38,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\DateMetadata $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $start = $this->getSolrTime($criterion->value[0]); $end = isset($criterion->value[1]) ? $this->getSolrTime($criterion->value[1]) : null; diff --git a/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php b/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php index bb4829fd..385bf322 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Solr\Query\Common\CriterionVisitor\DateMetadata; @@ -22,7 +23,7 @@ class ModifiedIn extends DateMetadata * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\DateMetadata && @@ -36,11 +37,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\DateMetadata $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $values = []; foreach ($criterion->value as $value) { diff --git a/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php b/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php index e2ebbba7..dc6950ac 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Solr\Query\Common\CriterionVisitor\DateMetadata; @@ -22,7 +23,7 @@ class PublishedBetween extends DateMetadata * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { if (!$criterion instanceof Criterion\DateMetadata) { return false; @@ -44,11 +45,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\DateMetadata $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $start = $this->getSolrTime($criterion->value[0]); $end = isset($criterion->value[1]) ? $this->getSolrTime($criterion->value[1]) : null; diff --git a/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php b/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php index 410ec1b8..28ef5a30 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Solr\Query\Common\CriterionVisitor\DateMetadata; @@ -22,7 +23,7 @@ class PublishedIn extends DateMetadata * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { if (!$criterion instanceof Criterion\DateMetadata) { return false; @@ -40,11 +41,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\DateMetadata $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return implode( ' OR ', diff --git a/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php index a853e9b9..8778975a 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php @@ -9,6 +9,7 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor\Field; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Core\Search\FieldType\BooleanField; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; @@ -41,7 +42,7 @@ public function __construct( /** * Check if visitor is applicable to current criterion. */ - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\IsFieldEmpty; } @@ -51,9 +52,10 @@ public function canVisit(Criterion $criterion): bool * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsFieldEmpty $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { $searchFields = $this->getSearchFields($criterion); diff --git a/src/lib/Query/Common/CriterionVisitor/Field/FieldIn.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldIn.php index 91d7413d..ef10029d 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldIn.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Solr\Query\Common\CriterionVisitor\Field; @@ -25,7 +26,7 @@ class FieldIn extends Field * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Field && @@ -39,12 +40,12 @@ public function canVisit(Criterion $criterion) * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Field $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $searchFields = $this->getSearchFields($criterion); diff --git a/src/lib/Query/Common/CriterionVisitor/Field/FieldLike.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldLike.php index 6f589fdc..8328e36d 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldLike.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldLike.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Solr\Query\Common\CriterionVisitor\Field; @@ -25,7 +26,7 @@ class FieldLike extends Field * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Field && $criterion->operator === Operator::LIKE; } @@ -35,12 +36,12 @@ public function canVisit(Criterion $criterion) * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Field $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $searchFields = $this->getSearchFields($criterion); diff --git a/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php index 27bb486d..9f11b436 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Solr\Query\Common\CriterionVisitor\Field; @@ -25,7 +26,7 @@ class FieldRange extends Field * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Field && @@ -39,14 +40,14 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Field $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string + * + * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $searchFields = $this->getSearchFields($criterion); diff --git a/src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php index 59a8e30e..964c76de 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Solr\Query\Common\CriterionVisitor\Field; @@ -25,7 +26,7 @@ class FieldRelation extends Field * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\FieldRelation && @@ -36,14 +37,14 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\FieldRelation $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string + * + * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $searchFields = $this->getSearchFields($criterion, $criterion->target); diff --git a/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php b/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php index 43b6819e..5ba18e1f 100644 --- a/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php +++ b/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php @@ -9,18 +9,22 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; final class IsUserEnabled extends CriterionVisitor { private const SEARCH_FIELD = 'user_is_enabled_b'; - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\IsUserEnabled; } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsUserEnabled $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { $value = $criterion->value; if (!is_array($value) || !is_bool($value[0])) { diff --git a/src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php b/src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php index c5a04434..021cb9e9 100644 --- a/src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php +++ b/src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class LanguageCodeIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LanguageCode && @@ -32,11 +33,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LanguageCode $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $languageCodeExpressions = array_map( static function ($value) { diff --git a/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php b/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php index a0c58fac..e4f94f50 100644 --- a/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php +++ b/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use RuntimeException; @@ -21,7 +22,7 @@ class LogicalAnd extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LogicalAnd; } @@ -29,11 +30,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd $criterion */ if (!isset($criterion->criteria[0])) { diff --git a/src/lib/Query/Common/CriterionVisitor/LogicalNot.php b/src/lib/Query/Common/CriterionVisitor/LogicalNot.php index 8c22b23e..51270b44 100644 --- a/src/lib/Query/Common/CriterionVisitor/LogicalNot.php +++ b/src/lib/Query/Common/CriterionVisitor/LogicalNot.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -20,7 +21,7 @@ class LogicalNot extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LogicalNot; } @@ -28,11 +29,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalNot $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { if (!isset($criterion->criteria[0]) || (\count($criterion->criteria) > 1)) { diff --git a/src/lib/Query/Common/CriterionVisitor/LogicalOr.php b/src/lib/Query/Common/CriterionVisitor/LogicalOr.php index eaf749fd..d05e8bcb 100644 --- a/src/lib/Query/Common/CriterionVisitor/LogicalOr.php +++ b/src/lib/Query/Common/CriterionVisitor/LogicalOr.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use RuntimeException; @@ -21,7 +22,7 @@ class LogicalOr extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LogicalOr; } @@ -29,11 +30,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalOr $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd $criterion */ if (!isset($criterion->criteria[0])) { diff --git a/src/lib/Query/Common/CriterionVisitor/MapLocation.php b/src/lib/Query/Common/CriterionVisitor/MapLocation.php index eadd910e..447ca80e 100644 --- a/src/lib/Query/Common/CriterionVisitor/MapLocation.php +++ b/src/lib/Query/Common/CriterionVisitor/MapLocation.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Search\Common\FieldNameResolver; @@ -61,7 +62,7 @@ public function __construct(FieldNameResolver $fieldNameResolver, $fieldTypeIden * @return array */ protected function getSearchFields( - Criterion $criterion, + CriterionInterface $criterion, $fieldDefinitionIdentifier, $fieldTypeIdentifier = null, $name = null diff --git a/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php b/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php index 7f7e1ac1..fcc7b8c8 100644 --- a/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php +++ b/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Solr\Query\Common\CriterionVisitor\MapLocation; @@ -25,7 +26,7 @@ class MapLocationDistanceIn extends MapLocation * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\MapLocationDistance && @@ -38,12 +39,12 @@ public function canVisit(Criterion $criterion) * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\MapLocationDistance $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Value\MapLocationValue $location */ $location = $criterion->valueData; diff --git a/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php b/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php index 083583d7..4778f187 100644 --- a/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php +++ b/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Solr\Query\Common\CriterionVisitor\MapLocation; @@ -25,7 +26,7 @@ class MapLocationDistanceRange extends MapLocation * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\MapLocationDistance && @@ -41,12 +42,12 @@ public function canVisit(Criterion $criterion) * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException If no searchable fields are found for the given criterion target. * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\MapLocationDistance $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $criterion->value = (array)$criterion->value; diff --git a/src/lib/Query/Common/CriterionVisitor/MatchAll.php b/src/lib/Query/Common/CriterionVisitor/MatchAll.php index 29892fc0..ca4e980e 100644 --- a/src/lib/Query/Common/CriterionVisitor/MatchAll.php +++ b/src/lib/Query/Common/CriterionVisitor/MatchAll.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -20,7 +21,7 @@ class MatchAll extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\MatchAll; } @@ -28,11 +29,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\MatchAll $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '*:*'; } diff --git a/src/lib/Query/Common/CriterionVisitor/MatchNone.php b/src/lib/Query/Common/CriterionVisitor/MatchNone.php index 023e397f..22cd100f 100644 --- a/src/lib/Query/Common/CriterionVisitor/MatchNone.php +++ b/src/lib/Query/Common/CriterionVisitor/MatchNone.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Common\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -20,7 +21,7 @@ class MatchNone extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\MatchNone; } @@ -28,11 +29,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\MatchNone $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(NOT *:*)'; } diff --git a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php index 3916b02c..f40ba2a4 100644 --- a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class ObjectStateIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\ObjectStateId && @@ -34,11 +35,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ObjectStateId $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php index d09c96d9..36bb5898 100644 --- a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php @@ -10,11 +10,12 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; class ObjectStateIdentifierIn extends CriterionVisitor { - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\ObjectStateIdentifier && @@ -24,7 +25,10 @@ public function canVisit(Criterion $criterion): bool ); } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ObjectStateIdentifier $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { $target = $criterion->target ?? '*'; diff --git a/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php b/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php index 7922dc2c..0f3f7174 100644 --- a/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class RemoteIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\RemoteId && @@ -34,11 +35,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\RemoteId $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php b/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php index de2898d6..a3bb925c 100644 --- a/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php +++ b/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php @@ -10,11 +10,12 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; class SectionIdentifierIn extends CriterionVisitor { - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\SectionIdentifier && @@ -24,7 +25,10 @@ public function canVisit(Criterion $criterion): bool ); } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\SectionIdentifier $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', diff --git a/src/lib/Query/Common/CriterionVisitor/SectionIn.php b/src/lib/Query/Common/CriterionVisitor/SectionIn.php index a4fd45a1..f5b650fb 100644 --- a/src/lib/Query/Common/CriterionVisitor/SectionIn.php +++ b/src/lib/Query/Common/CriterionVisitor/SectionIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class SectionIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\SectionId && @@ -34,11 +35,12 @@ public function canVisit(Criterion $criterion) /** * Map field value to a proper Solr representation. * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\SectionId $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php b/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php index 7cc226c2..11388ef2 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php @@ -10,12 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Solr\FieldMapper\ContentFieldMapper\UserDocumentFields; final class UserEmailIn extends CriterionVisitor { - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { if (!$criterion instanceof Criterion\UserEmail) { return false; @@ -24,7 +25,10 @@ public function canVisit(Criterion $criterion): bool return in_array($criterion->operator ?? Operator::IN, [Operator::IN, Operator::EQ], true); } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserEmail $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', diff --git a/src/lib/Query/Common/CriterionVisitor/UserIdIn.php b/src/lib/Query/Common/CriterionVisitor/UserIdIn.php index 34365833..d1cb90ab 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserIdIn.php @@ -10,11 +10,12 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; final class UserIdIn extends CriterionVisitor { - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { if (!$criterion instanceof Criterion\UserId) { return false; @@ -23,7 +24,10 @@ public function canVisit(Criterion $criterion): bool return in_array($criterion->operator ?? Operator::IN, [Operator::IN, Operator::EQ], true); } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserId $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', diff --git a/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php b/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php index 36065a95..d228b82d 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php @@ -10,12 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Solr\FieldMapper\ContentFieldMapper\UserDocumentFields; final class UserLoginIn extends CriterionVisitor { - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { if (!$criterion instanceof Criterion\UserLogin) { return false; @@ -24,7 +25,10 @@ public function canVisit(Criterion $criterion): bool return in_array($criterion->operator ?? Operator::IN, [Operator::IN, Operator::EQ], true); } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserLogin $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', diff --git a/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php b/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php index 81772f15..9beaa22d 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -22,7 +23,7 @@ class UserMetadataIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\UserMetadata && @@ -35,11 +36,12 @@ public function canVisit(Criterion $criterion) * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException * + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserMetadata $criterion * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { switch ($criterion->target) { case Criterion\UserMetadata::MODIFIER: diff --git a/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php b/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php index bd7fe32f..43fe0234 100644 --- a/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php +++ b/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php @@ -67,8 +67,8 @@ public function __construct( public function convert(Query $query, array $languageSettings = []) { $params = [ - 'q' => '{!lucene}' . $this->criterionVisitor->visit($query->query), - 'fq' => '{!lucene}' . $this->criterionVisitor->visit($query->filter), + 'q' => '{!lucene}' . ($query->query !== null ? $this->criterionVisitor->visit($query->query) : ''), + 'fq' => '{!lucene}' . ($query->filter !== null ? $this->criterionVisitor->visit($query->filter) : ''), 'sort' => $this->getSortClauses($query->sortClauses), 'start' => $query->offset, 'rows' => $query->limit, diff --git a/src/lib/Query/Content/CriterionVisitor/Ancestor.php b/src/lib/Query/Content/CriterionVisitor/Ancestor.php index fe927c56..28069f3d 100644 --- a/src/lib/Query/Content/CriterionVisitor/Ancestor.php +++ b/src/lib/Query/Content/CriterionVisitor/Ancestor.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Ancestor as AncestorCriterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class Ancestor extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof AncestorCriterion; } @@ -30,10 +31,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Ancestor $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $idSet = []; foreach ($criterion->value as $value) { diff --git a/src/lib/Query/Content/CriterionVisitor/ContentName.php b/src/lib/Query/Content/CriterionVisitor/ContentName.php index 71a94208..77e8518e 100644 --- a/src/lib/Query/Content/CriterionVisitor/ContentName.php +++ b/src/lib/Query/Content/CriterionVisitor/ContentName.php @@ -9,6 +9,7 @@ namespace Ibexa\Solr\Query\Content\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -16,13 +17,16 @@ */ final class ContentName extends CriterionVisitor { - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\ContentName && $criterion->operator === Criterion\Operator::LIKE; } - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentName $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { /** @var string $value */ $value = $criterion->value; diff --git a/src/lib/Query/Content/CriterionVisitor/FullText.php b/src/lib/Query/Content/CriterionVisitor/FullText.php index d5cbbf67..2e0acb5c 100644 --- a/src/lib/Query/Content/CriterionVisitor/FullText.php +++ b/src/lib/Query/Content/CriterionVisitor/FullText.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\FullText as FullTextCriterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Search\Common\FieldNameResolver; use QueryTranslator\Languages\Galach\Generators\ExtendedDisMax; @@ -83,7 +84,7 @@ protected function getSearchFields(Criterion $criterion, $fieldDefinitionIdentif * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof FullTextCriterion; } @@ -92,10 +93,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\FullText $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\FullText $criterion */ $tokenSequence = $this->tokenizer->tokenize($criterion->value); diff --git a/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php b/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php index 93842f6b..ca5477b5 100644 --- a/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php +++ b/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class LocationIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LocationId && @@ -33,10 +34,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LocationId $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php b/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php index 84e98309..c972f02b 100644 --- a/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php +++ b/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class LocationRemoteIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LocationRemoteId && @@ -33,10 +34,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LocationRemoteId $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php b/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php index d89aa4da..3b1c4b41 100644 --- a/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php +++ b/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class ParentLocationIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\ParentLocationId && @@ -33,10 +34,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ParentLocationId $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php b/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php index 948181fd..b668404b 100644 --- a/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php +++ b/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php @@ -9,8 +9,8 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; -use Ibexa\Core\Repository\Values\Content\Query\Criterion\PermissionSubtree; /** * Visits the Subtree criterion. @@ -22,10 +22,10 @@ class SubtreeIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return - ($criterion instanceof Criterion\Subtree || $criterion instanceof PermissionSubtree) && + $criterion instanceof Criterion\Subtree && (($criterion->operator ?: Operator::IN) === Operator::IN || $criterion->operator === Operator::EQ); } @@ -34,10 +34,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Subtree $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Content/CriterionVisitor/Visibility.php b/src/lib/Query/Content/CriterionVisitor/Visibility.php index d3026a7a..0511f996 100644 --- a/src/lib/Query/Content/CriterionVisitor/Visibility.php +++ b/src/lib/Query/Content/CriterionVisitor/Visibility.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class Visibility extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Visibility && $criterion->operator === Operator::EQ; } @@ -30,10 +31,12 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Visibility $criterion + * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return 'location_visible_b:' . ($criterion->value[0] === Criterion\Visibility::VISIBLE ? 'true' : 'false'); } diff --git a/src/lib/Query/Image/CriterionVisitor/AbstractImageRangeVisitor.php b/src/lib/Query/Image/CriterionVisitor/AbstractImageRangeVisitor.php index 46dca9c3..9b5d6391 100644 --- a/src/lib/Query/Image/CriterionVisitor/AbstractImageRangeVisitor.php +++ b/src/lib/Query/Image/CriterionVisitor/AbstractImageRangeVisitor.php @@ -8,12 +8,15 @@ namespace Ibexa\Solr\Query\Image\CriterionVisitor; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; abstract class AbstractImageRangeVisitor extends AbstractImageVisitor { - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageRangeCriterion $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { /** @var array{0: int, 1?: int|null} $criterionValue */ $criterionValue = $criterion->value; diff --git a/src/lib/Query/Image/CriterionVisitor/AbstractImageTermsVisitor.php b/src/lib/Query/Image/CriterionVisitor/AbstractImageTermsVisitor.php index 51167542..ce9984ae 100644 --- a/src/lib/Query/Image/CriterionVisitor/AbstractImageTermsVisitor.php +++ b/src/lib/Query/Image/CriterionVisitor/AbstractImageTermsVisitor.php @@ -8,12 +8,15 @@ namespace Ibexa\Solr\Query\Image\CriterionVisitor; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; abstract class AbstractImageTermsVisitor extends AbstractImageVisitor { - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null): string + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageRangeCriterion $criterion + */ + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { $queries = []; /** @var array|string $criterionValue */ diff --git a/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php b/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php index 9cd613ec..1b46dd9c 100644 --- a/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php +++ b/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php @@ -8,7 +8,7 @@ namespace Ibexa\Solr\Query\Image\CriterionVisitor; -use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Core\Base\Exceptions\InvalidArgumentException; use Ibexa\Core\FieldType\Image\Type; @@ -31,11 +31,13 @@ public function __construct( abstract protected function getSearchFieldName(): string; /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageRangeCriterion $criterion + * * @return array * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ - protected function getSearchFieldNames(Criterion $criterion): array + protected function getSearchFieldNames(CriterionInterface $criterion): array { $searchFieldNames = array_keys( $this->fieldNameResolver->getFieldTypes( diff --git a/src/lib/Query/Image/CriterionVisitor/FileSize.php b/src/lib/Query/Image/CriterionVisitor/FileSize.php index 9c2c43fb..a8d92432 100644 --- a/src/lib/Query/Image/CriterionVisitor/FileSize.php +++ b/src/lib/Query/Image/CriterionVisitor/FileSize.php @@ -10,12 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; final class FileSize extends AbstractImageRangeVisitor { private const SEARCH_FIELD_FILE_SIZE = 'file_size'; - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Image\FileSize && ( diff --git a/src/lib/Query/Image/CriterionVisitor/Height.php b/src/lib/Query/Image/CriterionVisitor/Height.php index 87c2cb39..683d1470 100644 --- a/src/lib/Query/Image/CriterionVisitor/Height.php +++ b/src/lib/Query/Image/CriterionVisitor/Height.php @@ -10,12 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; final class Height extends AbstractImageRangeVisitor { private const SEARCH_FIELD_HEIGHT = 'height'; - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Image\Height && ( diff --git a/src/lib/Query/Image/CriterionVisitor/MimeType.php b/src/lib/Query/Image/CriterionVisitor/MimeType.php index dd42384b..2ff6b65d 100644 --- a/src/lib/Query/Image/CriterionVisitor/MimeType.php +++ b/src/lib/Query/Image/CriterionVisitor/MimeType.php @@ -10,12 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; final class MimeType extends AbstractImageTermsVisitor { private const SEARCH_FIELD_MIME_TYPE = 'mime_type'; - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Image\MimeType && ( diff --git a/src/lib/Query/Image/CriterionVisitor/Orientation.php b/src/lib/Query/Image/CriterionVisitor/Orientation.php index 4bec2dbe..e090aece 100644 --- a/src/lib/Query/Image/CriterionVisitor/Orientation.php +++ b/src/lib/Query/Image/CriterionVisitor/Orientation.php @@ -10,12 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; final class Orientation extends AbstractImageTermsVisitor { private const SEARCH_FIELD_ORIENTATION = 'orientation'; - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Image\Orientation && ( diff --git a/src/lib/Query/Image/CriterionVisitor/Width.php b/src/lib/Query/Image/CriterionVisitor/Width.php index 18ca6250..90dae94f 100644 --- a/src/lib/Query/Image/CriterionVisitor/Width.php +++ b/src/lib/Query/Image/CriterionVisitor/Width.php @@ -10,12 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; final class Width extends AbstractImageRangeVisitor { private const SEARCH_FIELD_WIDTH = 'width'; - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Image\Width && ( diff --git a/src/lib/Query/Location/CriterionVisitor/Ancestor.php b/src/lib/Query/Location/CriterionVisitor/Ancestor.php index 58068fb9..dd71f00d 100644 --- a/src/lib/Query/Location/CriterionVisitor/Ancestor.php +++ b/src/lib/Query/Location/CriterionVisitor/Ancestor.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Ancestor as AncestorCriterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class Ancestor extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof AncestorCriterion; } @@ -30,10 +31,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Ancestor $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $idSet = []; foreach ($criterion->value as $value) { diff --git a/src/lib/Query/Location/CriterionVisitor/FullText.php b/src/lib/Query/Location/CriterionVisitor/FullText.php index 002f2a2d..d7b16330 100644 --- a/src/lib/Query/Location/CriterionVisitor/FullText.php +++ b/src/lib/Query/Location/CriterionVisitor/FullText.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Location\CriterionVisitor; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use Ibexa\Solr\Query\Content\CriterionVisitor\FullText as ContentFullText; @@ -23,7 +24,7 @@ class FullText extends ContentFullText * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $condition = $this->escapeQuote(parent::visit($criterion, $subVisitor)); diff --git a/src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php b/src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php index 44b4f699..40d484a3 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class DepthBetween extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Location\Depth && @@ -38,10 +39,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\Depth $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $start = $criterion->value[0]; $end = isset($criterion->value[1]) ? $criterion->value[1] : null; diff --git a/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php b/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php index 4d9cb848..48db0444 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class DepthIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Location\Depth && @@ -35,10 +36,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\Depth $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $values = []; foreach ($criterion->value as $value) { diff --git a/src/lib/Query/Location/CriterionVisitor/Location/IsBookmarked.php b/src/lib/Query/Location/CriterionVisitor/Location/IsBookmarked.php index fc6b36f8..9916f65a 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/IsBookmarked.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/IsBookmarked.php @@ -10,6 +10,7 @@ use Ibexa\Contracts\Core\Repository\PermissionResolver; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; use LogicException; @@ -24,14 +25,17 @@ public function __construct(PermissionResolver $permissionResolver) $this->permissionResolver = $permissionResolver; } - public function canVisit(Criterion $criterion): bool + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Location\IsBookmarked && $criterion->operator === Criterion\Operator::EQ; } + /** + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\IsBookmarked $criterion + */ public function visit( - Criterion $criterion, + CriterionInterface $criterion, CriterionVisitor $subVisitor = null ): string { if (!is_array($criterion->value)) { diff --git a/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php b/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php index dfebd4a0..41c7292b 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php @@ -8,6 +8,7 @@ namespace Ibexa\Solr\Query\Location\CriterionVisitor\Location; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -20,7 +21,7 @@ class IsMainLocation extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Location\IsMainLocation; } @@ -29,10 +30,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\IsMainLocation $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return 'is_main_location_b:' . ($criterion->value[0] === Criterion\Location\IsMainLocation::MAIN ? 'true' : 'false'); } diff --git a/src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php b/src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php index 237caf55..73b72c49 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class PriorityBetween extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Location\Priority && @@ -38,10 +39,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\Priority $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $start = $criterion->value[0]; $end = isset($criterion->value[1]) ? $criterion->value[1] : null; diff --git a/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php b/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php index 35bbe15d..794f0c35 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class PriorityIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Location\Priority && @@ -35,10 +36,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Location\Priority $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { $values = []; foreach ($criterion->value as $value) { diff --git a/src/lib/Query/Location/CriterionVisitor/LocationIdIn.php b/src/lib/Query/Location/CriterionVisitor/LocationIdIn.php index e26a1be4..54bfc9d6 100644 --- a/src/lib/Query/Location/CriterionVisitor/LocationIdIn.php +++ b/src/lib/Query/Location/CriterionVisitor/LocationIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class LocationIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LocationId && @@ -33,10 +34,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LocationId $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php b/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php index 0d7a1b0c..c299d9e1 100644 --- a/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php +++ b/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class LocationRemoteIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\LocationRemoteId && @@ -35,10 +36,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LocationRemoteId $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php b/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php index 56358d1a..0ec65080 100644 --- a/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php +++ b/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class ParentLocationIdIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\ParentLocationId && @@ -35,10 +36,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ParentLocationId $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php b/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php index f96f3257..00965bf4 100644 --- a/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php +++ b/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class SubtreeIn extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Subtree && @@ -35,10 +36,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Subtree $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return '(' . implode( diff --git a/src/lib/Query/Location/CriterionVisitor/Visibility.php b/src/lib/Query/Location/CriterionVisitor/Visibility.php index d05ae441..af24e868 100644 --- a/src/lib/Query/Location/CriterionVisitor/Visibility.php +++ b/src/lib/Query/Location/CriterionVisitor/Visibility.php @@ -9,6 +9,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Operator; +use Ibexa\Contracts\Core\Repository\Values\Content\Query\CriterionInterface; use Ibexa\Contracts\Solr\Query\CriterionVisitor; /** @@ -21,7 +22,7 @@ class Visibility extends CriterionVisitor * * @return bool */ - public function canVisit(Criterion $criterion) + public function canVisit(CriterionInterface $criterion) { return $criterion instanceof Criterion\Visibility && $criterion->operator === Operator::EQ; } @@ -30,10 +31,11 @@ public function canVisit(Criterion $criterion) * Map field value to a proper Solr representation. * * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor + * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Visibility $criterion * * @return string */ - public function visit(Criterion $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) { return 'invisible_b:' . ($criterion->value[0] === Criterion\Visibility::HIDDEN ? 'true' : 'false'); } diff --git a/src/lib/ResultExtractor/NativeResultExtractor.php b/src/lib/ResultExtractor/NativeResultExtractor.php index e46a6fa2..62170759 100644 --- a/src/lib/ResultExtractor/NativeResultExtractor.php +++ b/src/lib/ResultExtractor/NativeResultExtractor.php @@ -54,13 +54,13 @@ protected function extractContentInfoFromHit($hit) 'contentTypeId' => (int)$hit->content_type_id_id, 'sectionId' => (int)$hit->content_section_id_id, 'currentVersionNo' => $hit->content_version_no_i, - 'isPublished' => true, 'ownerId' => (int)$hit->content_owner_user_id_id, 'modificationDate' => strtotime($hit->content_modification_date_dt), 'publicationDate' => strtotime($hit->content_publication_date_dt), 'alwaysAvailable' => $hit->content_always_available_b, 'remoteId' => $hit->content_remote_id_id, 'mainLanguageCode' => $hit->content_main_language_code_s, + 'status' => ContentInfo::STATUS_PUBLISHED, ] );