diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c847cd89..12459e7c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,70 +1,10 @@ parameters: ignoreErrors: - - message: '#^Method Ibexa\\Bundle\\Solr\\ApiLoader\\BoostFactorProviderFactory\:\:buildService\(\) has no return type specified\.$#' + message: '#^Method Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\:\:canVisit\(\) has no return type specified\.$#' identifier: missingType.return count: 1 - path: src/bundle/ApiLoader/BoostFactorProviderFactory.php - - - - message: '#^Method Ibexa\\Bundle\\Solr\\ApiLoader\\IndexingDepthProviderFactory\:\:buildService\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/ApiLoader/IndexingDepthProviderFactory.php - - - - message: '#^Method Ibexa\\Bundle\\Solr\\ApiLoader\\SolrEngineFactory\:\:__construct\(\) has parameter \$defaultConnection with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/bundle/ApiLoader/SolrEngineFactory.php - - - - message: '#^Method Ibexa\\Bundle\\Solr\\ApiLoader\\SolrEngineFactory\:\:__construct\(\) has parameter \$searchEngineClass with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/bundle/ApiLoader/SolrEngineFactory.php - - - - message: '#^Method Ibexa\\Bundle\\Solr\\ApiLoader\\SolrEngineFactory\:\:buildEngine\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/ApiLoader/SolrEngineFactory.php - - - - message: '#^Method Ibexa\\Bundle\\Solr\\DependencyInjection\\Configuration\:\:__construct\(\) has parameter \$rootNodeName with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/bundle/DependencyInjection/Configuration.php - - - - message: '#^Method Ibexa\\Bundle\\Solr\\DependencyInjection\\Configuration\:\:addConnectionsSection\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/DependencyInjection/Configuration.php - - - - message: '#^Method Ibexa\\Bundle\\Solr\\DependencyInjection\\Configuration\:\:addEndpointsSection\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/bundle/DependencyInjection/Configuration.php - - - - message: '#^Property Ibexa\\Bundle\\Solr\\DependencyInjection\\Configuration\:\:\$defaultEndpointValues type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/bundle/DependencyInjection/Configuration.php - - - - message: '#^Property Ibexa\\Bundle\\Solr\\DependencyInjection\\Configuration\:\:\$metaFieldNames has no type specified\.$#' - identifier: missingType.property - count: 1 - path: src/bundle/DependencyInjection/Configuration.php - - - - message: '#^Property Ibexa\\Bundle\\Solr\\DependencyInjection\\Configuration\:\:\$rootNodeName has no type specified\.$#' - identifier: missingType.property - count: 1 - path: src/bundle/DependencyInjection/Configuration.php + path: src/contracts/Query/CriterionVisitor.php - message: '#^Method Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\:\:escapeQuote\(\) should return string but returns string\|null\.$#' @@ -73,64 +13,10 @@ parameters: path: src/contracts/Query/CriterionVisitor.php - - message: '#^Method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/ResultExtractor/AggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/ResultExtractor/AggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\:\:map\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/contracts/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/contracts/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\CoreFilter\:\:apply\(\) has no return type specified\.$#' + message: '#^Method Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\:\:visit\(\) has no return type specified\.$#' identifier: missingType.return count: 1 - path: src/lib/CoreFilter.php - - - - message: '#^Method Ibexa\\Solr\\CoreFilter\:\:apply\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/CoreFilter.php - - - - message: '#^Method Ibexa\\Solr\\CoreFilter\\NativeCoreFilter\:\:apply\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/CoreFilter/NativeCoreFilter.php + path: src/contracts/Query/CriterionVisitor.php - message: '#^Parameter \#2 \$languageCode of method Ibexa\\Solr\\DocumentMapper\\NativeDocumentMapper\:\:generateContentDocumentId\(\) expects string\|null, int\|string given\.$#' @@ -156,54 +42,12 @@ parameters: count: 1 path: src/lib/DocumentMapper/NativeDocumentMapper.php - - - message: '#^Method Ibexa\\Solr\\FieldMapper\\BoostFactorProvider\:\:__construct\(\) has parameter \$map with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/BoostFactorProvider.php - - - - message: '#^Property Ibexa\\Solr\\FieldMapper\\BoostFactorProvider\:\:\$map type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/BoostFactorProvider.php - - - - message: '#^Method Ibexa\\Solr\\FieldMapper\\ContentFieldMapper\\BlockDocumentsBaseContentFields\:\:getAncestorLocationsContentIds\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php - - - - message: '#^Method Ibexa\\Solr\\FieldMapper\\ContentFieldMapper\\BlockDocumentsBaseContentFields\:\:getObjectStateIds\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php - - - - message: '#^Parameter \#1 \$contentId of method Ibexa\\Contracts\\Core\\Persistence\\Content\\Location\\Handler\:\:loadLocationsByContent\(\) expects int, int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php - - message: '#^Parameter \#1 \$locationId of method Ibexa\\Contracts\\Core\\Persistence\\Content\\Location\\Handler\:\:load\(\) expects int, string given\.$#' identifier: argument.type count: 1 path: src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php - - - message: '#^Method Ibexa\\Solr\\FieldMapper\\ContentFieldMapper\\ContentDocumentLocationFields\:\:getAncestors\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/ContentFieldMapper/ContentDocumentLocationFields.php - - - - message: '#^Offset ''ancestors'' might not exist on array\{ids\: non\-empty\-list\, parent_ids\: non\-empty\-list\, remote_ids\: non\-empty\-list\, path_strings\: non\-empty\-list\, ancestors\?\: non\-empty\-list\}\.$#' - identifier: offsetAccess.notFound - count: 1 - path: src/lib/FieldMapper/ContentFieldMapper/ContentDocumentLocationFields.php - - message: '#^Property Ibexa\\Contracts\\Core\\Search\\FieldType\:\:\$boost \(int\) does not accept float\.$#' identifier: assign.propertyType @@ -222,36 +66,12 @@ parameters: count: 1 path: src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentFulltextFields.php - - - message: '#^Method Ibexa\\Solr\\FieldMapper\\IndexingDepthProvider\:\:__construct\(\) has parameter \$contentTypeMap with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/IndexingDepthProvider.php - - - - message: '#^Property Ibexa\\Solr\\FieldMapper\\IndexingDepthProvider\:\:\$contentTypeMap type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/IndexingDepthProvider.php - - - - message: '#^Method Ibexa\\Solr\\FieldMapper\\LocationFieldMapper\\LocationDocumentBaseFields\:\:getAncestors\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php - - message: '#^Method Ibexa\\Solr\\Gateway\:\:bulkIndexDocuments\(\) has no return type specified\.$#' identifier: missingType.return count: 1 path: src/lib/Gateway.php - - - message: '#^Method Ibexa\\Solr\\Gateway\:\:commit\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/Gateway.php - - message: '#^Method Ibexa\\Solr\\Gateway\:\:deleteByQuery\(\) has no return type specified\.$#' identifier: missingType.return @@ -259,1466 +79,586 @@ parameters: path: src/lib/Gateway.php - - message: '#^Method Ibexa\\Solr\\Gateway\:\:findContent\(\) has parameter \$fieldFilters with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\:\:getSearchParameters\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/lib/Gateway.php + path: src/lib/Gateway/DistributionStrategy.php - - message: '#^Method Ibexa\\Solr\\Gateway\:\:findLocations\(\) has parameter \$fieldFilters with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\AbstractDistributionStrategy\:\:getSearchParameters\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/lib/Gateway.php + path: src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php - - message: '#^Method Ibexa\\Solr\\Gateway\:\:purgeIndex\(\) has no return type specified\.$#' - identifier: missingType.return + message: '#^Parameter \#1 \$headers of class Ibexa\\Solr\\Gateway\\Message constructor expects array\\|string\>, non\-empty\-array\\> given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway.php + path: src/lib/Gateway/HttpClient/Stream.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\:\:getSearchParameters\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/Gateway/DistributionStrategy.php + message: '#^Cannot cast list\\|string to string\.$#' + identifier: cast.string + count: 2 + path: src/lib/Gateway/Native.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\:\:getSearchParameters\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:internalFind\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/lib/Gateway/DistributionStrategy.php + path: src/lib/Gateway/Native.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\:\:getSearchParameters\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:search\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/lib/Gateway/DistributionStrategy.php + path: src/lib/Gateway/Native.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\AbstractDistributionStrategy\:\:appendSearchTargets\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$name of method Ibexa\\Solr\\Gateway\\EndpointRegistry\:\:getEndpoint\(\) expects string, string\|null given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php + path: src/lib/Gateway/Native.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\AbstractDistributionStrategy\:\:appendSearchTargets\(\) has parameter \$searchTargets with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#3 \$subject of function str_replace expects array\\|string, string\|null given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php + path: src/lib/Gateway/Native.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\AbstractDistributionStrategy\:\:appendSearchTargets\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializer\:\:buildValue\(\) has parameter \$data with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php + path: src/lib/Gateway/UpdateSerializer/JsonUpdateSerializer.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\AbstractDistributionStrategy\:\:getSearchParameters\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$value of method XMLWriter\:\:writeAttribute\(\) expects string, int given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php + path: src/lib/Gateway/UpdateSerializer/XmlUpdateSerializer.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\AbstractDistributionStrategy\:\:getSearchParameters\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php + message: '#^Access to an undefined property Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject\:\:\$id\.$#' + identifier: property.notFound + count: 2 + path: src/lib/Handler.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\AbstractDistributionStrategy\:\:getSearchParameters\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\Solr\\Query\\Common\\AggregationVisitor\\AbstractRangeAggregationVisitor\:\:formatRangeValue\(\) has parameter \$value with no type specified\.$#' + identifier: missingType.parameter count: 1 - path: src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php + path: src/lib/Query/Common/AggregationVisitor/AbstractRangeAggregationVisitor.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\CloudDistributionStrategy\:\:appendSearchTargets\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Call to an undefined method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\:\:getFieldName\(\)\.$#' + identifier: method.notFound count: 1 - path: src/lib/Gateway/DistributionStrategy/CloudDistributionStrategy.php + path: src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/RawAggregationFieldResolver.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\CloudDistributionStrategy\:\:appendSearchTargets\(\) has parameter \$searchTargets with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^PHPDoc tag @param for parameter \$aggregation with type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\RawAggregation is not subtype of native type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\.$#' + identifier: parameter.phpDocType count: 1 - path: src/lib/Gateway/DistributionStrategy/CloudDistributionStrategy.php + path: src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/RawAggregationFieldResolver.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\CloudDistributionStrategy\:\:appendSearchTargets\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/DistributionStrategy/CloudDistributionStrategy.php + path: src/lib/Query/Common/CriterionVisitor/ContentIdIn.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\StandaloneDistributionStrategy\:\:appendSearchTargets\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/DistributionStrategy/StandaloneDistributionStrategy.php + path: src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\StandaloneDistributionStrategy\:\:appendSearchTargets\(\) has parameter \$searchTargets with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 - path: src/lib/Gateway/DistributionStrategy/StandaloneDistributionStrategy.php + path: src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php - - message: '#^Method Ibexa\\Solr\\Gateway\\DistributionStrategy\\StandaloneDistributionStrategy\:\:appendSearchTargets\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\CustomField\\CustomFieldIn\:\:isRegExp\(\) has parameter \$preparedValue with no type specified\.$#' + identifier: missingType.parameter count: 1 - path: src/lib/Gateway/DistributionStrategy/StandaloneDistributionStrategy.php + path: src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php - - message: '#^Method Ibexa\\Solr\\Gateway\\EndpointResolver\:\:getSearchTargets\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' + identifier: offsetAccess.nonOffsetAccessible count: 1 - path: src/lib/Gateway/EndpointResolver.php + path: src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php - - message: '#^Method Ibexa\\Solr\\Gateway\\EndpointResolver\\NativeEndpointResolver\:\:getSearchTargets\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 - path: src/lib/Gateway/EndpointResolver/NativeEndpointResolver.php + path: src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php - - message: '#^Return type \(string\) of method Ibexa\\Solr\\Gateway\\EndpointResolver\\NativeEndpointResolver\:\:getEntryEndpoint\(\) should be compatible with return type \(Ibexa\\Solr\\Gateway\\Endpoint\) of method Ibexa\\Solr\\Gateway\\EndpointResolver\:\:getEntryEndpoint\(\)$#' - identifier: method.childReturnType + message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' + identifier: offsetAccess.nonOffsetAccessible count: 1 - path: src/lib/Gateway/EndpointResolver/NativeEndpointResolver.php + path: src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Message\:\:__construct\(\) has parameter \$headers with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/Message.php + path: src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php - - message: '#^Property Ibexa\\Solr\\Gateway\\Message\:\:\$headers type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getFieldTypes\(\) expects string, string\|null given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/Message.php + path: src/lib/Query/Common/CriterionVisitor/Field.php - - message: '#^Default value of the parameter \#2 \$languageSettings \(array\{\}\) of method Ibexa\\Solr\\Gateway\\Native\:\:findContent\(\) is incompatible with type array\{languages\: array\\}\.$#' - identifier: parameter.defaultValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/Native.php + path: src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:doBulkIndexDocuments\(\) has no return type specified\.$#' - identifier: missingType.return + message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#' + identifier: method.nonObject count: 1 - path: src/lib/Gateway/Native.php + path: src/lib/Query/Common/CriterionVisitor/LogicalAnd.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:findLocations\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#' + identifier: method.nonObject count: 1 - path: src/lib/Gateway/Native.php + path: src/lib/Query/Common/CriterionVisitor/LogicalNot.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:generateQueryString\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#' + identifier: method.nonObject count: 1 - path: src/lib/Gateway/Native.php + path: src/lib/Query/Common/CriterionVisitor/LogicalOr.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:getSearchTargets\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\MapLocation\:\:getSearchFields\(\) expects string, string\|null given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/Native.php + path: src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:internalFind\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\MapLocation\:\:getSearchFields\(\) expects string, string\|null given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/Native.php + path: src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:internalFind\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: src/lib/Gateway/Native.php + path: src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:purgeEndpoint\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/Gateway/Native.php - - - - message: '#^Method Ibexa\\Solr\\Gateway\\Native\:\:search\(\) has parameter \$parameters with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Gateway/Native.php - - - - message: '#^Parameter \#1 \$name of method Ibexa\\Solr\\Gateway\\EndpointRegistry\:\:getEndpoint\(\) expects string, Ibexa\\Solr\\Gateway\\Endpoint given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Gateway/Native.php - - - - message: '#^Parameter \#1 \$name of method Ibexa\\Solr\\Gateway\\EndpointRegistry\:\:getEndpoint\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Gateway/Native.php - - - - message: '#^Parameter \#3 \$subject of function str_replace expects array\\|string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Gateway/Native.php - - - - message: '#^Method Ibexa\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializer\:\:buildValue\(\) has parameter \$data with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Gateway/UpdateSerializer/JsonUpdateSerializer.php - - - - message: '#^Method Ibexa\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializer\:\:mapDocumentToData\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Gateway/UpdateSerializer/JsonUpdateSerializer.php - - - - message: '#^Parameter \#2 \$value of method XMLWriter\:\:writeAttribute\(\) expects string, int given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Gateway/UpdateSerializer/XmlUpdateSerializer.php - - - - message: '#^Access to an undefined property Ibexa\\Contracts\\Core\\Repository\\Values\\ValueObject\:\:\$id\.$#' - identifier: property.notFound - count: 2 - path: src/lib/Handler.php - - - - message: '#^Method Ibexa\\Solr\\Handler\:\:deleteAllItemsWithoutAdditionalLocation\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/Handler.php - - - - message: '#^Method Ibexa\\Solr\\Handler\:\:deleteAllItemsWithoutAdditionalLocation\(\) has parameter \$locationId with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Handler.php - - - - message: '#^Method Ibexa\\Solr\\Handler\:\:generateDocument\(\) should return Ibexa\\Contracts\\Core\\Search\\Document but returns array\\.$#' - identifier: return.type - count: 1 - path: src/lib/Handler.php - - - - message: '#^Method Ibexa\\Solr\\Handler\:\:suggest\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/Handler.php - - - - message: '#^Method Ibexa\\Solr\\Handler\:\:updateAllElementsWithAdditionalLocation\(\) has no return type specified\.$#' - identifier: missingType.return - count: 1 - path: src/lib/Handler.php - - - - message: '#^Method Ibexa\\Solr\\Handler\:\:updateAllElementsWithAdditionalLocation\(\) has parameter \$locationId with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Handler.php - - - - message: '#^PHPDoc tag @param references unknown parameter\: \$resultExtractor$#' - identifier: parameter.notFound - count: 1 - path: src/lib/Handler.php - - - - message: '#^Parameter \#1 \$documents of method Ibexa\\Solr\\Gateway\:\:bulkIndexDocuments\(\) expects array\\>, array\ given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Handler.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\AggregationVisitor\\AbstractRangeAggregationVisitor\:\:formatRangeValue\(\) has parameter \$value with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Query/Common/AggregationVisitor/AbstractRangeAggregationVisitor.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\AggregationVisitor\\AbstractRangeAggregationVisitor\:\:visit\(\) should return array\ but returns array\\>\|string\>\.$#' - identifier: return.type - count: 1 - path: src/lib/Query/Common/AggregationVisitor/AbstractRangeAggregationVisitor.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\AggregationVisitor\\AbstractStatsAggregationVisitor\:\:visit\(\) should return array\ but returns array\\|string\>\.$#' - identifier: return.type - count: 1 - path: src/lib/Query/Common/AggregationVisitor/AbstractStatsAggregationVisitor.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\AggregationVisitor\\AbstractTermAggregationVisitor\:\:visit\(\) should return array\ but returns array\\.$#' - identifier: return.type - count: 1 - path: src/lib/Query/Common/AggregationVisitor/AbstractTermAggregationVisitor.php - - - - message: '#^Call to an undefined method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\:\:getFieldName\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/RawAggregationFieldResolver.php - - - - message: '#^PHPDoc tag @param for parameter \$aggregation with type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\RawAggregation is not subtype of native type Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\.$#' - identifier: parameter.phpDocType - count: 1 - path: src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/RawAggregationFieldResolver.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\AggregationVisitor\\ObjectStateAggregationVisitor\:\:visit\(\) should return array\ but returns array\\.$#' - identifier: return.type - count: 1 - path: src/lib/Query/Common/AggregationVisitor/ObjectStateAggregationVisitor.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\AggregationVisitor\\SubtreeTermAggregationVisitor\:\:visit\(\) should return array\ but returns array\\>\|string\>\.$#' - identifier: return.type - count: 1 - path: src/lib/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitor.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/ContentIdIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php - - - - message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\CustomField\\CustomFieldIn\:\:isRegExp\(\) has parameter \$preparedValue with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php - - - - message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php - - - - message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php - - - - message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php - - - - message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getFieldTypes\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/Field.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\Field\:\:getSearchFields\(\) invoked with 2 parameters, 1 required\.$#' - identifier: arguments.count - count: 1 - path: src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php - - - - message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/lib/Query/Common/CriterionVisitor/LogicalAnd.php - - - - message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/lib/Query/Common/CriterionVisitor/LogicalNot.php - - - - message: '#^Cannot call method visit\(\) on Ibexa\\Contracts\\Solr\\Query\\CriterionVisitor\|null\.$#' - identifier: method.nonObject - count: 1 - path: src/lib/Query/Common/CriterionVisitor/LogicalOr.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\MapLocation\:\:getSearchFields\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Query/Common/CriterionVisitor/MapLocation.php - - - - message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\MapLocation\:\:getSearchFields\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php - - - - message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Solr\\Query\\Common\\CriterionVisitor\\MapLocation\:\:getSearchFields\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php - - - - message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' - identifier: argument.type + message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' + identifier: argument.type count: 1 path: src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php - - - - message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/SectionIn.php - - - - message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: \(lowercase\-string&non\-falsy\-string\) given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/UserEmailIn.php - - - - message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/UserIdIn.php - - - - message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: \(lowercase\-string&non\-falsy\-string\) given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/UserLoginIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php - - - - message: '#^Default value of the parameter \#2 \$languageSettings \(array\{\}\) of method Ibexa\\Solr\\Query\\Common\\QueryConverter\\NativeQueryConverter\:\:convert\(\) is incompatible with type array\{languages\: array\\}\.$#' - identifier: parameter.defaultValue - count: 1 - path: src/lib/Query/Common/QueryConverter/NativeQueryConverter.php - - - - message: '#^Method Ibexa\\Contracts\\Solr\\Query\\SortClauseVisitor\:\:visit\(\) invoked with 2 parameters, 1 required\.$#' - identifier: arguments.count - count: 1 - path: src/lib/Query/Common/SortClauseVisitor/Aggregate.php - - - - message: '#^Binary operation "\." between array and string results in an error\.$#' - identifier: binaryOp.invalid - count: 1 - path: src/lib/Query/Common/SortClauseVisitor/Field.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\SortClauseVisitor\\Field\:\:getSortFieldName\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Query/Common/SortClauseVisitor/Field.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\SortClauseVisitor\\Field\:\:getSortFieldName\(\) should return array but returns string\|null\.$#' - identifier: return.type - count: 1 - path: src/lib/Query/Common/SortClauseVisitor/Field.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\SortClauseVisitor\\MapLocationDistance\:\:getSortFieldName\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Query/Common/SortClauseVisitor/MapLocationDistance.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Common\\SortClauseVisitor\\MapLocationDistance\:\:getSortFieldName\(\) should return array but returns string\|null\.$#' - identifier: return.type - count: 1 - path: src/lib/Query/Common/SortClauseVisitor/MapLocationDistance.php - - - - message: '#^Part \$fieldName \(array\) of encapsed string cannot be cast to string\.$#' - identifier: encapsedStringPart.nonString - count: 1 - path: src/lib/Query/Common/SortClauseVisitor/MapLocationDistance.php - - - - message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/lib/Query/Content/CriterionVisitor/Ancestor.php - - - - message: '#^Method Ibexa\\Solr\\Query\\Content\\CriterionVisitor\\FullText\:\:getSearchFields\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Query/Content/CriterionVisitor/FullText.php - - - - message: '#^Parameter \#1 \$string of method QueryTranslator\\Languages\\Galach\\Tokenizer\:\:tokenize\(\) expects string, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Content/CriterionVisitor/FullText.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Content/CriterionVisitor/LocationIdIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Content/CriterionVisitor/SubtreeIn.php - - - - message: '#^Parameter \#3 \$subject of function str_replace expects array\\|string, bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Content/CriterionVisitor/SubtreeIn.php - - - - message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Query/Content/CriterionVisitor/Visibility.php - - - - message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getFieldTypes\(\) expects string, string\|null given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php - - - - message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/lib/Query/Location/CriterionVisitor/Ancestor.php - - - - message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php - - - - message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php - - - - message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php - - - - message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php - - - - message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Location/CriterionVisitor/LocationIdIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php - - - - message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Location/CriterionVisitor/SubtreeIn.php - - - - message: '#^Parameter \#3 \$subject of function str_replace expects array\\|string, bool\|float\|int\|string given\.$#' - identifier: argument.type - count: 1 - path: src/lib/Query/Location/CriterionVisitor/SubtreeIn.php - - - - message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' - identifier: offsetAccess.nonOffsetAccessible - count: 1 - path: src/lib/Query/Location/CriterionVisitor/Visibility.php - - - - message: '#^Default value of the parameter \#2 \$languageSettings \(array\{\}\) of method Ibexa\\Solr\\Query\\QueryConverter\:\:convert\(\) is incompatible with type array\{languages\: array\\}\.$#' - identifier: parameter.defaultValue - count: 1 - path: src/lib/Query/QueryConverter.php - - - - message: '#^Method Ibexa\\Solr\\Query\\QueryConverter\:\:convert\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/Query/QueryConverter.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\:\:extractAggregations\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\:\:extractSearchHit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\:\:extractSearchHit\(\) return type with generic class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\SearchHit does not specify its types\: T$#' - identifier: missingType.generics - count: 1 - path: src/lib/ResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\DispatcherAggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\DispatcherAggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\DispatcherAggregationResultExtractor\:\:findExtractor\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\NestedAggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\NestedAggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\DateTimeRangeAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/DateTimeRangeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\FloatRangeAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/FloatRangeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\IntRangeAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/IntRangeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\NullRangeAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/NullRangeAggregationKeyMapper.php - - - - message: '#^Argument of an invalid type stdClass supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php - - - - message: '#^Parameter \#1 \$key of class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry constructor expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\Range\, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\Range\ given\.$#' - identifier: argument.type - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\StatsAggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\StatsAggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\AuthorAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\AuthorAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\BooleanAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/BooleanAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\BooleanAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/BooleanAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\BooleanAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/BooleanAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeGroupAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapper.php - - - - message: '#^Call to an undefined method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\:\:getType\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:__construct\(\) has parameter \$countriesInfo with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:findCountryInfoByIDC\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - - - message: '#^Property Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:\$countriesInfo type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\InvertedBooleanAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/InvertedBooleanAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\InvertedBooleanAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/InvertedBooleanAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\InvertedBooleanAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/InvertedBooleanAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LanguageAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LanguageAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LanguageAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LocationAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LocationAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LocationAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\NullAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/NullAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\NullAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/NullAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\NullAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/NullAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ObjectStateAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ObjectStateAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ObjectStateAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SectionAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SubtreeAggregationKeyMapper\:\:getAncestors\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SubtreeAggregationKeyMapper\:\:map\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SubtreeAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SubtreeAggregationKeyMapper\:\:map\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php - - - - message: '#^Call to an undefined method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\:\:getType\(\)\.$#' - identifier: method.notFound - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\UserMetadataAggregationKeyMapper\:\:map\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapper.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationResultExtractor\:\:canVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationResultExtractor\:\:extract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationResultExtractor\:\:getKeys\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractor.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\DependencyInjection\\IbexaSolrExtensionExtensionTest\:\:testBoostFactorMap\(\) has parameter \$configuration with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\DependencyInjection\\IbexaSolrExtensionExtensionTest\:\:testBoostFactorMap\(\) has parameter \$map with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\DependencyInjection\\IbexaSolrExtensionExtensionTest\:\:testConnectionLoad\(\) has parameter \$configurationValues with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializerTest\:\:getDataForTestSerialize\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializerTest\:\:testSerialize\(\) has parameter \$expectedData with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php - - - - message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializerTest\:\:testSerialize\(\) has parameter \$inputDocuments with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php - - - - message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Solr\\\\CoreFilter'' and Ibexa\\Solr\\CoreFilter will always evaluate to true\.$#' - identifier: staticMethod.alreadyNarrowedType - count: 1 - path: tests/lib/CoreFilter/CoreFilterRegistryTest.php - - - - message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Solr\\\\Gateway'' and Ibexa\\Solr\\Gateway will always evaluate to true\.$#' - identifier: staticMethod.alreadyNarrowedType - count: 1 - path: tests/lib/Gateway/GatewayRegistryTest.php - - - - message: '#^Method Ibexa\\Tests\\Solr\\Gateway\\UpdateSerializerFactoryTest\:\:getDataForTestGetSerializer\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Gateway/UpdateSerializerFactoryTest.php - - - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\FieldMapper\\BoostFactorProviderTest\:\:getContentTypeStub\(\) has parameter \$identifier with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/lib/Search/FieldMapper/BoostFactorProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\FieldMapper\\BoostFactorProviderTest\:\:getFieldBoostProvider\(\) has parameter \$map with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Search/FieldMapper/BoostFactorProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\FieldMapper\\BoostFactorProviderTest\:\:getFieldDefinitionStub\(\) has parameter \$identifier with no type specified\.$#' - identifier: missingType.parameter - count: 1 - path: tests/lib/Search/FieldMapper/BoostFactorProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\FieldMapper\\BoostFactorProviderTest\:\:testGetContentFieldBoostFactor\(\) has parameter \$map with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue - count: 1 - path: tests/lib/Search/FieldMapper/BoostFactorProviderTest.php - - - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\FieldMapper\\BoostFactorProviderTest\:\:testGetContentMetaFieldBoostFactor\(\) has parameter \$map with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/FieldMapper/BoostFactorProviderTest.php + path: src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php - - message: '#^Parameter \#1 \$endpointRegistry of class Ibexa\\Solr\\Gateway\\DistributionStrategy\\StandaloneDistributionStrategy constructor expects Ibexa\\Solr\\Gateway\\EndpointRegistry, PHPUnit\\Framework\\MockObject\\MockObject given\.$#' + message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/DistributionStrategy/StandaloneDistributionStrategyTest.php + path: src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php - - message: '#^Property Ibexa\\Tests\\Solr\\Search\\Gateway\\DistributionStrategy\\StandaloneDistributionStrategyTest\:\:\$endpointRegistry \(Ibexa\\Solr\\Gateway\\EndpointRegistry&PHPUnit\\Framework\\MockObject\\MockObject\) does not accept PHPUnit\\Framework\\MockObject\\MockObject\.$#' - identifier: assign.propertyType + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/DistributionStrategy/StandaloneDistributionStrategyTest.php + path: src/lib/Query/Common/CriterionVisitor/SectionIn.php - - message: '#^Instanceof between Ibexa\\Solr\\Gateway\\EndpointResolver\\NativeEndpointResolver and Ibexa\\Solr\\Gateway\\SingleEndpointResolver will always evaluate to true\.$#' - identifier: instanceof.alwaysTrue + message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: \(lowercase\-string&non\-falsy\-string\) given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Common/CriterionVisitor/UserEmailIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:getEndpointResolver\(\) has parameter \$defaultEndpoint with no type specified\.$#' - identifier: missingType.parameter + message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Common/CriterionVisitor/UserIdIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:getEndpointResolver\(\) has parameter \$endpointMap with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: \(lowercase\-string&non\-falsy\-string\) given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Common/CriterionVisitor/UserLoginIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:getEndpointResolver\(\) has parameter \$entryEndpoints with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:getEndpointResolver\(\) has parameter \$mainLanguagesEndpoint with no type specified\.$#' - identifier: missingType.parameter + message: '#^Method Ibexa\\Contracts\\Solr\\Query\\SortClauseVisitor\:\:visit\(\) invoked with 2 parameters, 1 required\.$#' + identifier: arguments.count count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Common/SortClauseVisitor/Aggregate.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:providerForTestGetSearchTargets\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Content/CriterionVisitor/Ancestor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:testGetSearchTargets\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$string of method QueryTranslator\\Languages\\Galach\\Tokenizer\:\:tokenize\(\) expects string, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Content/CriterionVisitor/FullText.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:testGetSearchTargetsThrowsRuntimeException\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php + path: src/lib/Query/Content/CriterionVisitor/LocationIdIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\Query\\Content\\CriterionVisitor\\FullTextTest\:\:getFullTextCriterionVisitor\(\) has parameter \$fieldTypes with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php + path: src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php - - message: '#^PHPDoc tag @var with type Ibexa\\Core\\Search\\Common\\FieldNameResolver is not subtype of native type PHPUnit\\Framework\\MockObject\\MockObject\.$#' - identifier: varTag.nativeType + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php + path: src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\AbstractAggregationResultExtractorTest\:\:dataProviderForTestCanVisit\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php + path: src/lib/Query/Content/CriterionVisitor/SubtreeIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\AbstractAggregationResultExtractorTest\:\:dataProviderForTestExtract\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php + path: src/lib/Query/Content/CriterionVisitor/SubtreeIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\AbstractAggregationResultExtractorTest\:\:testCanVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' + identifier: offsetAccess.nonOffsetAccessible count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php + path: src/lib/Query/Content/CriterionVisitor/Visibility.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\AbstractAggregationResultExtractorTest\:\:testExtract\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$fieldDefinitionIdentifier of method Ibexa\\Core\\Search\\Common\\FieldNameResolver\:\:getFieldTypes\(\) expects string, string\|null given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php + path: src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php - - message: '#^Call to an undefined method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\:\:method\(\)\.$#' - identifier: method.notFound + message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractorTest.php + path: src/lib/Query/Location/CriterionVisitor/Ancestor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\DispatcherAggregationResultExtractorTest\:\:createExtractorMockWithCanVisit\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' + identifier: offsetAccess.nonOffsetAccessible count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractorTest.php + path: src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\AbstractRangeAggregationKeyMapperTest\:\:dataProviderForTestMap\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/AbstractRangeAggregationKeyMapperTest.php + path: src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\AbstractRangeAggregationKeyMapperTest\:\:testMap\(\) has parameter \$expectedResult with no type specified\.$#' - identifier: missingType.parameter + message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' + identifier: offsetAccess.nonOffsetAccessible count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/AbstractRangeAggregationKeyMapperTest.php + path: src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\AbstractRangeAggregationKeyMapperTest\:\:testMap\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' + identifier: offsetAccess.nonOffsetAccessible count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/AbstractRangeAggregationKeyMapperTest.php + path: src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\DateTimeRangeAggregationKeyMapperTest\:\:dataProviderForTestMap\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Argument of an invalid type array\\|bool\|float\|int\|string supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/DateTimeRangeAggregationKeyMapperTest.php + path: src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\FloatRangeAggregationKeyMapperTest\:\:dataProviderForTestMap\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/FloatRangeAggregationKeyMapperTest.php + path: src/lib/Query/Location/CriterionVisitor/LocationIdIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\IntRangeAggregationKeyMapperTest\:\:dataProviderForTestMap\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/IntRangeAggregationKeyMapperTest.php + path: src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationKeyMapper\\NullRangeAggregationKeyMapperTest\:\:dataProviderForTestMap\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/NullRangeAggregationKeyMapperTest.php + path: src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationResultExtractorTest\:\:dataProviderForTestCanVisit\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$callback of function array_map expects \(callable\(bool\|float\|int\|string\)\: mixed\)\|null, Closure\(string\)\: non\-falsy\-string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php + path: src/lib/Query/Location/CriterionVisitor/SubtreeIn.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationResultExtractorTest\:\:dataProviderForTestExtract\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#2 \$array of function array_map expects array, array\\|bool\|float\|int\|string given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php + path: src/lib/Query/Location/CriterionVisitor/SubtreeIn.php - - message: '#^Parameter \#2 \$entries of class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResult constructor expects iterable\\>, array\{Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry\, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry\, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry\\} given\.$#' - identifier: argument.type + message: '#^Cannot access offset 0 on array\\|bool\|float\|int\|string\.$#' + identifier: offsetAccess.nonOffsetAccessible count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php + path: src/lib/Query/Location/CriterionVisitor/Visibility.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\StatsAggregationResultExtractorTest\:\:dataProviderForTestCanVisit\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\Solr\\ResultExtractor\:\:extractSearchHit\(\) return type with generic class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\SearchHit does not specify its types\: T$#' + identifier: missingType.generics count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractorTest.php + path: src/lib/ResultExtractor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\StatsAggregationResultExtractorTest\:\:dataProviderForTestExtract\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: ''' + #^PHPDoc tag @param has invalid value \(\\stdClass\{ + document_type_id\: string, + content_id_id\: int\|string, + content_name_s\: string, + content_type_id_id\: int\|string, + content_section_id_id\: int\|string, + content_version_no_i\: int, + content_owner_user_id_id\: int\|string, + content_modification_date_dt\: string, + content_publication_date_dt\: string, + content_always_available_b\: bool, + content_remote_id_id\: string, + content_main_language_code_s\: string, + main_location_id\?\: int\|string, + location_id\: int\|string, + priority_i\: int, + hidden_b\: bool, + invisible_b\: bool, + remote_id_id\: string, + parent_id_id\: int\|string, + path_string_id\: string, + depth_i\: int, + sort_field_id\: int\|string, + sort_order_id\: int\|string + \}&\\stdClass \$hit\)\: Unexpected token "\{", expected variable at offset 163 on line 5$# + ''' + identifier: phpDoc.parseError count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractorTest.php + path: src/lib/ResultExtractor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\AuthorAggregationKeyMapperTest\:\:dataProviderForTestMap\(\) return type has no value type specified in iterable type iterable\.$#' + message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\DispatcherAggregationResultExtractor\:\:findExtractor\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\AuthorAggregationKeyMapperTest\:\:testMap\(\) has parameter \$expectedResult with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Argument of an invalid type stdClass supplied for foreach, only iterables are supported\.$#' + identifier: foreach.nonIterable count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\AuthorAggregationKeyMapperTest\:\:testMap\(\) has parameter \$keys with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$key of class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry constructor expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\Range\, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\Range\ given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\AuthorAggregationKeyMapperTest\:\:testMap\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Call to an undefined method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\:\:getType\(\)\.$#' + identifier: method.notFound count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeAggregationKeyMapperTest\:\:createContentTypesList\(\) has parameter \$ids with no value type specified in iterable type iterable\.$#' + message: '#^Method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:findCountryInfoByIDC\(\) return type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeAggregationKeyMapperTest\:\:createContentTypesList\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Call to an undefined method Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\:\:getType\(\)\.$#' + identifier: method.notFound count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapper.php - - message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\ContentTypeTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation&PHPUnit\\Framework\\MockObject\\MockObject given\.$#' + message: '#^Parameter \#1 \$hit of method Ibexa\\Solr\\ResultExtractor\\NativeResultExtractor\:\:extractContentInfoFromHit\(\) expects object\{document_type_id\: string, content_id_id\: int\|string, content_name_s\: string, content_type_id_id\: int\|string, content_section_id_id\: int\|string, content_version_no_i\: int, content_owner_user_id_id\: int\|string, content_modification_date_dt\: string, content_publication_date_dt\: string, content_always_available_b\: bool, content_remote_id_id\: string, content_main_language_code_s\: string, main_location_id\?\: int\|string\}&stdClass, stdClass given\.$#' identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/NativeResultExtractor.php - - message: '#^Parameter \#3 \$keys of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeAggregationKeyMapper\:\:map\(\) expects array\, array\ given\.$#' + message: '#^Parameter \#1 \$hit of method Ibexa\\Solr\\ResultExtractor\\NativeResultExtractor\:\:extractLocationFromHit\(\) expects object\{location_id\: int\|string, priority_i\: int, hidden_b\: bool, invisible_b\: bool, remote_id_id\: string, content_id_id\: int\|string, parent_id_id\: int\|string, path_string_id\: string, depth_i\: int, sort_field_id\: int\|string, sort_order_id\: int\|string\}&stdClass, stdClass given\.$#' identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php + path: src/lib/ResultExtractor/NativeResultExtractor.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeGroupAggregationKeyMapperTest\:\:createExpectedLanguages\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\DependencyInjection\\IbexaSolrExtensionExtensionTest\:\:testBoostFactorMap\(\) has parameter \$configuration with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapperTest.php + path: tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php - - message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeGroupAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\ContentTypeGroupTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation&PHPUnit\\Framework\\MockObject\\MockObject given\.$#' - identifier: argument.type + message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\DependencyInjection\\IbexaSolrExtensionExtensionTest\:\:testBoostFactorMap\(\) has parameter \$map with no value type specified in iterable type array\.$#' + identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapperTest.php + path: tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapperTest\:\:dataProviderForTestMap\(\) return type has no value type specified in iterable type iterable\.$#' + message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\DependencyInjection\\IbexaSolrExtensionExtensionTest\:\:testConnectionLoad\(\) has parameter \$configurationValues with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php + path: tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapperTest\:\:testMap\(\) has parameter \$expectedResult with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializerTest\:\:getDataForTestSerialize\(\) return type has no value type specified in iterable type iterable\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php + path: tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapperTest\:\:testMap\(\) has parameter \$keys with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializerTest\:\:testSerialize\(\) has parameter \$expectedData with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php + path: tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapperTest\:\:testMap\(\) has parameter \$languageFilter with no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Tests\\Bundle\\Solr\\Gateway\\UpdateSerializer\\JsonUpdateSerializerTest\:\:testSerialize\(\) has parameter \$inputDocuments with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php + path: tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php - - message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\Field\\CountryTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation given\.$#' - identifier: argument.type + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Solr\\\\CoreFilter'' and Ibexa\\Solr\\CoreFilter will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php + path: tests/lib/CoreFilter/CoreFilterRegistryTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LanguageAggregationKeyMapperTest\:\:configureLanguageServiceMock\(\) has parameter \$languageCodes with no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertInstanceOf\(\) with ''Ibexa\\\\Solr\\\\Gateway'' and Ibexa\\Solr\\Gateway will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapperTest.php + path: tests/lib/Gateway/GatewayRegistryTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LanguageAggregationKeyMapperTest\:\:configureLanguageServiceMock\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Instanceof between Ibexa\\Solr\\Gateway\\EndpointResolver\\NativeEndpointResolver and Ibexa\\Solr\\Gateway\\SingleEndpointResolver will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapperTest.php + path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LocationAggregationKeyMapperTest\:\:createExpectedLocations\(\) has parameter \$locationIds with no value type specified in iterable type iterable\.$#' + message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:testGetSearchTargets\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapperTest.php + path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\LocationAggregationKeyMapperTest\:\:createExpectedLocations\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Tests\\Solr\\Search\\Gateway\\EndpointResolver\\NativeEndpointResolverTest\:\:testGetSearchTargetsThrowsRuntimeException\(\) has parameter \$languageSettings with no value type specified in iterable type array\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapperTest.php + path: tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ObjectStateAggregationKeyMapperTest\:\:configureObjectStateService\(\) has parameter \$objectStateIdentifiers with no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\Tests\\Solr\\Search\\Query\\Common\\AggregationVisitor\\RangeAggregationVisitorTest\:\:dataProviderForVisit\(\) return type with generic class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\AbstractRangeAggregation does not specify its types\: TValue$#' + identifier: missingType.generics count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapperTest.php + path: tests/lib/Search/Query/Common/AggregationVisitor/RangeAggregationVisitorTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ObjectStateAggregationKeyMapperTest\:\:configureObjectStateService\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^PHPDoc tag @var with type Ibexa\\Core\\Search\\Common\\FieldNameResolver is not subtype of native type PHPUnit\\Framework\\MockObject\\MockObject\.$#' + identifier: varTag.nativeType count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapperTest.php + path: tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SectionAggregationKeyMapperTest\:\:configureSectionServiceMock\(\) has parameter \$sectionIds with no value type specified in iterable type iterable\.$#' + message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\AbstractAggregationResultExtractorTest\:\:dataProviderForTestCanVisit\(\) return type has no value type specified in iterable type iterable\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SectionAggregationKeyMapperTest\:\:configureSectionServiceMock\(\) return type has no value type specified in iterable type array\.$#' + message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\AbstractAggregationResultExtractorTest\:\:dataProviderForTestExtract\(\) return type has no value type specified in iterable type iterable\.$#' identifier: missingType.iterableValue count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php - - message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SectionAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\SectionTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation&PHPUnit\\Framework\\MockObject\\MockObject given\.$#' + message: '#^Call to an undefined method Ibexa\\Contracts\\Solr\\ResultExtractor\\AggregationResultExtractor\:\:method\(\)\.$#' + identifier: method.notFound + count: 1 + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractorTest.php + + - + message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\RangeAggregationResultExtractorTest\:\:dataProviderForTestExtract\(\) return type with generic class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResult does not specify its types\: TValue$#' + identifier: missingType.generics + count: 1 + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php + + - + message: '#^Parameter \#2 \$entries of class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResult constructor expects iterable\\>, array\{Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry\, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry\, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\RangeAggregationResultEntry\\} given\.$#' identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php - - message: '#^Parameter \#3 \$keys of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SectionAggregationKeyMapper\:\:map\(\) expects array\, array\ given\.$#' + message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\ContentTypeTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation&PHPUnit\\Framework\\MockObject\\MockObject given\.$#' identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SubtreeAggregationKeyMapperTest\:\:createExpectedLocations\(\) has parameter \$locationIds with no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\ContentTypeGroupAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\ContentTypeGroupTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation&PHPUnit\\Framework\\MockObject\\MockObject given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapperTest.php + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapperTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SubtreeAggregationKeyMapperTest\:\:createExpectedLocations\(\) return type has no value type specified in iterable type array\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\CountryAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\Field\\CountryTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapperTest.php + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationResultExtractorTest\:\:dataProviderForTestCanVisit\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Parameter \#1 \$aggregation of method Ibexa\\Solr\\ResultExtractor\\AggregationResultExtractor\\TermAggregationKeyMapper\\SectionAggregationKeyMapper\:\:map\(\) expects Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation\\SectionTermAggregation, Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Query\\Aggregation&PHPUnit\\Framework\\MockObject\\MockObject given\.$#' + identifier: argument.type count: 1 - path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractorTest.php + path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php - - message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationResultExtractorTest\:\:dataProviderForTestExtract\(\) return type has no value type specified in iterable type iterable\.$#' - identifier: missingType.iterableValue + message: '#^Method Ibexa\\Tests\\Solr\\Search\\ResultExtractor\\AggregationResultExtractor\\TermAggregationResultExtractorTest\:\:dataProviderForTestExtract\(\) return type with generic class Ibexa\\Contracts\\Core\\Repository\\Values\\Content\\Search\\AggregationResult\\TermAggregationResult does not specify its types\: TKey$#' + identifier: missingType.generics count: 1 path: tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractorTest.php diff --git a/src/bundle/ApiLoader/BoostFactorProviderFactory.php b/src/bundle/ApiLoader/BoostFactorProviderFactory.php index e1c33625..a5e2aaab 100644 --- a/src/bundle/ApiLoader/BoostFactorProviderFactory.php +++ b/src/bundle/ApiLoader/BoostFactorProviderFactory.php @@ -8,44 +8,26 @@ namespace Ibexa\Bundle\Solr\ApiLoader; use Ibexa\Contracts\Core\Container\ApiLoader\RepositoryConfigurationProviderInterface; +use Ibexa\Solr\FieldMapper\BoostFactorProvider; use Symfony\Component\DependencyInjection\ContainerInterface; /** * BoostFactorProvider service factory takes into account boost factor semantic configuration. */ -class BoostFactorProviderFactory +readonly class BoostFactorProviderFactory { - private ContainerInterface $container; - - private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider; - - /** - * @var string - */ - private $defaultConnection; - - /** - * @var string - */ - private $boostFactorProviderClass; - /** - * @param string $defaultConnection - * @param string $boostFactorProviderClass + * @param class-string<\Ibexa\Solr\FieldMapper\BoostFactorProvider> $boostFactorProviderClass */ public function __construct( - ContainerInterface $container, - RepositoryConfigurationProviderInterface $repositoryConfigurationProvider, - $defaultConnection, - $boostFactorProviderClass + private ContainerInterface $container, + private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider, + private string $defaultConnection, + private string $boostFactorProviderClass ) { - $this->container = $container; - $this->repositoryConfigurationProvider = $repositoryConfigurationProvider; - $this->defaultConnection = $defaultConnection; - $this->boostFactorProviderClass = $boostFactorProviderClass; } - public function buildService() + public function buildService(): BoostFactorProvider { $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig(); @@ -55,7 +37,7 @@ public function buildService() } return new $this->boostFactorProviderClass( - $this->container->getParameter( + (array)$this->container->getParameter( "ibexa.solr.connection.{$connection}.boost_factor_map_id" ) ); diff --git a/src/bundle/ApiLoader/IndexingDepthProviderFactory.php b/src/bundle/ApiLoader/IndexingDepthProviderFactory.php index efec56a8..750122dd 100644 --- a/src/bundle/ApiLoader/IndexingDepthProviderFactory.php +++ b/src/bundle/ApiLoader/IndexingDepthProviderFactory.php @@ -9,31 +9,23 @@ namespace Ibexa\Bundle\Solr\ApiLoader; use Ibexa\Contracts\Core\Container\ApiLoader\RepositoryConfigurationProviderInterface; +use Ibexa\Solr\FieldMapper\IndexingDepthProvider; use Symfony\Component\DependencyInjection\ContainerInterface; -class IndexingDepthProviderFactory +readonly class IndexingDepthProviderFactory { - private ContainerInterface $container; - - private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider; - - private string $defaultConnection; - - private string $indexingDepthProviderClass; - + /** + * @param class-string<\Ibexa\Solr\FieldMapper\IndexingDepthProvider> $indexingDepthProviderClass + */ public function __construct( - ContainerInterface $container, - RepositoryConfigurationProviderInterface $repositoryConfigurationProvider, - string $defaultConnection, - string $indexingDepthProviderClass + private ContainerInterface $container, + private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider, + private string $defaultConnection, + private string $indexingDepthProviderClass ) { - $this->container = $container; - $this->repositoryConfigurationProvider = $repositoryConfigurationProvider; - $this->defaultConnection = $defaultConnection; - $this->indexingDepthProviderClass = $indexingDepthProviderClass; } - public function buildService() + public function buildService(): IndexingDepthProvider { $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig(); @@ -43,10 +35,10 @@ public function buildService() } return new $this->indexingDepthProviderClass( - $this->container->getParameter( + (array)$this->container->getParameter( "ibexa.solr.connection.{$connection}.indexing_depth.map" ), - $this->container->getParameter( + (int)$this->container->getParameter( "ibexa.solr.connection.{$connection}.indexing_depth.default" ) ); diff --git a/src/bundle/ApiLoader/SolrEngineFactory.php b/src/bundle/ApiLoader/SolrEngineFactory.php index fb16e92b..fb153139 100644 --- a/src/bundle/ApiLoader/SolrEngineFactory.php +++ b/src/bundle/ApiLoader/SolrEngineFactory.php @@ -14,51 +14,25 @@ use Ibexa\Solr\Gateway\GatewayRegistry; use Ibexa\Solr\ResultExtractor; -class SolrEngineFactory +readonly class SolrEngineFactory { - private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider; - - /** @var string */ - private $defaultConnection; - - /** @var string */ - private $searchEngineClass; - - private GatewayRegistry $gatewayRegistry; - - private CoreFilterRegistry $coreFilterRegistry; - - private Handler $contentHandler; - - private DocumentMapper $documentMapper; - - private ResultExtractor $contentResultExtractor; - - private ResultExtractor $locationResultExtractor; - + /** + * @param class-string<\Ibexa\Solr\Handler> $searchEngineClass + */ public function __construct( - RepositoryConfigurationProviderInterface $repositoryConfigurationProvider, - $defaultConnection, - $searchEngineClass, - GatewayRegistry $gatewayRegistry, - CoreFilterRegistry $coreFilterRegistry, - Handler $contentHandler, - DocumentMapper $documentMapper, - ResultExtractor $contentResultExtractor, - ResultExtractor $locationResultExtractor + private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider, + private string $defaultConnection, + private string $searchEngineClass, + private GatewayRegistry $gatewayRegistry, + private CoreFilterRegistry $coreFilterRegistry, + private Handler $contentHandler, + private DocumentMapper $documentMapper, + private ResultExtractor $contentResultExtractor, + private ResultExtractor $locationResultExtractor ) { - $this->repositoryConfigurationProvider = $repositoryConfigurationProvider; - $this->defaultConnection = $defaultConnection; - $this->searchEngineClass = $searchEngineClass; - $this->gatewayRegistry = $gatewayRegistry; - $this->coreFilterRegistry = $coreFilterRegistry; - $this->contentHandler = $contentHandler; - $this->documentMapper = $documentMapper; - $this->contentResultExtractor = $contentResultExtractor; - $this->locationResultExtractor = $locationResultExtractor; } - public function buildEngine() + public function buildEngine(): \Ibexa\Solr\Handler { $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig(); diff --git a/src/bundle/DependencyInjection/Configuration.php b/src/bundle/DependencyInjection/Configuration.php index 07bdd953..cd65a3fc 100644 --- a/src/bundle/DependencyInjection/Configuration.php +++ b/src/bundle/DependencyInjection/Configuration.php @@ -13,17 +13,15 @@ class Configuration implements ConfigurationInterface { - public const SOLR_HTTP_CLIENT_DEFAULT_TIMEOUT = 10; - public const SOLR_HTTP_CLIENT_DEFAULT_MAX_RETRIES = 3; - - protected $rootNodeName; + public const int SOLR_HTTP_CLIENT_DEFAULT_TIMEOUT = 10; + public const int SOLR_HTTP_CLIENT_DEFAULT_MAX_RETRIES = 3; /** * Holds default endpoint values. * - * @var array + * @var array */ - protected $defaultEndpointValues = [ + protected array $defaultEndpointValues = [ 'scheme' => 'http', 'host' => '127.0.0.1', 'port' => 8983, @@ -32,14 +30,15 @@ class Configuration implements ConfigurationInterface 'path' => '/solr', ]; - protected $metaFieldNames = [ + /** @var list */ + protected array $metaFieldNames = [ 'name', 'text', ]; - public function __construct($rootNodeName) - { - $this->rootNodeName = $rootNodeName; + public function __construct( + protected string $rootNodeName + ) { } public function getConfigTreeBuilder(): TreeBuilder @@ -58,7 +57,7 @@ public function getConfigTreeBuilder(): TreeBuilder /** * Adds endpoints definition. */ - protected function addEndpointsSection(ArrayNodeDefinition $node) + protected function addEndpointsSection(ArrayNodeDefinition $node): void { $node->children() ->arrayNode('endpoints') @@ -103,7 +102,7 @@ protected function addEndpointsSection(ArrayNodeDefinition $node) * * @throws \RuntimeException */ - protected function addConnectionsSection(ArrayNodeDefinition $node) + protected function addConnectionsSection(ArrayNodeDefinition $node): void { $node->children() ->scalarNode('default_connection') @@ -116,11 +115,7 @@ protected function addConnectionsSection(ArrayNodeDefinition $node) ->prototype('array') ->beforeNormalization() ->ifTrue( - static function ($v): bool { - return - !empty($v['mapping']) && !\is_array($v['mapping']) - ; - } + static fn ($v): bool => !empty($v['mapping']) && !\is_array($v['mapping']) ) ->then( static function (array $v) { @@ -136,16 +131,12 @@ static function (array $v) { ->end() ->beforeNormalization() ->ifTrue( - static function ($v): bool { - return - empty($v['entry_endpoints']) && - ( - !empty($v['mapping']['translations']) || - !empty($v['mapping']['default']) || - !empty($v['mapping']['main_translations']) - ) - ; - } + static fn ($v): bool => empty($v['entry_endpoints']) && + ( + !empty($v['mapping']['translations']) || + !empty($v['mapping']['default']) || + !empty($v['mapping']['main_translations']) + ) ) ->then( // If entry endpoints are not provided use mapping endpoints diff --git a/src/bundle/DependencyInjection/IbexaSolrExtension.php b/src/bundle/DependencyInjection/IbexaSolrExtension.php index c70f1697..6603f776 100644 --- a/src/bundle/DependencyInjection/IbexaSolrExtension.php +++ b/src/bundle/DependencyInjection/IbexaSolrExtension.php @@ -71,6 +71,7 @@ class IbexaSolrExtension extends ConfigurableExtension public const string GATEWAY_UPDATE_SERIALIZER_TAG = 'ibexa.solr.gateway.serializer.update'; + #[\Override] public function getAlias(): string { return 'ibexa_solr'; @@ -125,10 +126,9 @@ protected function processConnectionConfiguration(ContainerBuilder $container, a $config['default_connection'] ); } elseif (!empty($config['connections'])) { - reset($config['connections']); $container->setParameter( "{$alias}.default_connection", - key($config['connections']) + array_key_first($config['connections']) ); } @@ -265,6 +265,7 @@ protected function defineEndpoint(ContainerBuilder $container, string $alias, ar /** * @param array> $config */ + #[\Override] public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { return new Configuration($this->getAlias()); diff --git a/src/bundle/IbexaSolrBundle.php b/src/bundle/IbexaSolrBundle.php index 498d9532..205b03ae 100644 --- a/src/bundle/IbexaSolrBundle.php +++ b/src/bundle/IbexaSolrBundle.php @@ -36,6 +36,7 @@ public function build(ContainerBuilder $container): void $container->addCompilerPass(new CoreFilterRegistryPass()); } + #[\Override] public function getContainerExtension(): ?ExtensionInterface { if (!isset($this->extension)) { diff --git a/src/contracts/DocumentMapper.php b/src/contracts/DocumentMapper.php index 4396e918..1e20a24d 100644 --- a/src/contracts/DocumentMapper.php +++ b/src/contracts/DocumentMapper.php @@ -20,17 +20,13 @@ interface DocumentMapper { /** * Identifier of Content documents. - * - * @var string */ - public const DOCUMENT_TYPE_IDENTIFIER_CONTENT = 'content'; + public const string DOCUMENT_TYPE_IDENTIFIER_CONTENT = 'content'; /** * Identifier of Location documents. - * - * @var string */ - public const DOCUMENT_TYPE_IDENTIFIER_LOCATION = 'location'; + public const string DOCUMENT_TYPE_IDENTIFIER_LOCATION = 'location'; /** * Maps given Content and it's Locations to a collection of nested Documents, @@ -38,9 +34,9 @@ interface DocumentMapper * * Each Content Document contains nested Documents representing it's Locations. * - * @return \Ibexa\Contracts\Core\Search\Document[] + * @return list<\Ibexa\Contracts\Core\Search\Document> */ - public function mapContentBlock(Content $content); + public function mapContentBlock(Content $content): array; /** * Generates the Solr backend document ID for Content object. @@ -49,13 +45,8 @@ public function mapContentBlock(Content $content); * of all Content's documents (there will be one document per translation). * The above is useful when targeting all Content's documents, without * the knowledge of it's translations. - * - * @param int|string $contentId - * @param string $languageCode - * - * @return string */ - public function generateContentDocumentId($contentId, $languageCode = null); + public function generateContentDocumentId(int $contentId, ?string $languageCode = null): string; /** * Generates the Solr backend document ID for Location object. @@ -64,11 +55,6 @@ public function generateContentDocumentId($contentId, $languageCode = null); * of all Location's documents (there will be one document per translation). * The above is useful when targeting all Location's documents, without * the knowledge of it's Content's translations. - * - * @param int|string $locationId - * @param string $languageCode - * - * @return string */ - public function generateLocationDocumentId($locationId, $languageCode = null); + public function generateLocationDocumentId(int $locationId, ?string $languageCode = null): string; } diff --git a/src/contracts/FieldMapper/ContentFieldMapper.php b/src/contracts/FieldMapper/ContentFieldMapper.php index 29936c98..552ff947 100644 --- a/src/contracts/FieldMapper/ContentFieldMapper.php +++ b/src/contracts/FieldMapper/ContentFieldMapper.php @@ -18,15 +18,13 @@ abstract class ContentFieldMapper { /** * Indicates if the mapper accepts the given $content for mapping. - * - * @return bool */ - abstract public function accept(SPIContent $content); + abstract public function accept(SPIContent $content): bool; /** * Maps given $content to an array of search fields. * - * @return \Ibexa\Contracts\Core\Search\Field[] + * @return list<\Ibexa\Contracts\Core\Search\Field> */ - abstract public function mapFields(SPIContent $content); + abstract public function mapFields(SPIContent $content): array; } diff --git a/src/contracts/FieldMapper/ContentTranslationFieldMapper.php b/src/contracts/FieldMapper/ContentTranslationFieldMapper.php index 7c0fdb11..1a99cd35 100644 --- a/src/contracts/FieldMapper/ContentTranslationFieldMapper.php +++ b/src/contracts/FieldMapper/ContentTranslationFieldMapper.php @@ -19,19 +19,13 @@ abstract class ContentTranslationFieldMapper { /** * Indicates if the mapper accepts given $content and $languageCode for mapping. - * - * @param string $languageCode - * - * @return bool */ - abstract public function accept(SPIContent $content, $languageCode); + abstract public function accept(SPIContent $content, string $languageCode): bool; /** * Maps given $content for $languageCode to an array of search fields. * - * @param string $languageCode - * - * @return \Ibexa\Contracts\Core\Search\Field[] + * @return list<\Ibexa\Contracts\Core\Search\Field> */ - abstract public function mapFields(SPIContent $content, $languageCode); + abstract public function mapFields(SPIContent $content, string $languageCode): array; } diff --git a/src/contracts/FieldMapper/LocationFieldMapper.php b/src/contracts/FieldMapper/LocationFieldMapper.php index 79ff1f9a..9f10a6d3 100644 --- a/src/contracts/FieldMapper/LocationFieldMapper.php +++ b/src/contracts/FieldMapper/LocationFieldMapper.php @@ -18,15 +18,13 @@ abstract class LocationFieldMapper { /** * Indicates if the mapper accepts given $location for mapping. - * - * @return bool */ - abstract public function accept(SPILocation $location); + abstract public function accept(SPILocation $location): bool; /** * Maps given $location to an array of search fields. * - * @return \Ibexa\Contracts\Core\Search\Field[] + * @return list<\Ibexa\Contracts\Core\Search\Field> */ - abstract public function mapFields(SPILocation $location); + abstract public function mapFields(SPILocation $location): array; } diff --git a/src/contracts/Query/AggregationVisitor.php b/src/contracts/Query/AggregationVisitor.php index c74ac5a2..4f3732ff 100644 --- a/src/contracts/Query/AggregationVisitor.php +++ b/src/contracts/Query/AggregationVisitor.php @@ -15,14 +15,14 @@ interface AggregationVisitor /** * Check if visitor is applicable to current aggreagtion. * - * @phpstan-param array{languages: string[]} $languageFilter + * @phpstan-param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter */ public function canVisit(Aggregation $aggregation, array $languageFilter): bool; /** - * @phpstan-param array{languages: string[]} $languageFilter + * @phpstan-param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter * - * @return string[] + * @return array */ public function visit( AggregationVisitor $dispatcherVisitor, diff --git a/src/contracts/Query/CriterionVisitor.php b/src/contracts/Query/CriterionVisitor.php index a11fc861..2e191f7e 100644 --- a/src/contracts/Query/CriterionVisitor.php +++ b/src/contracts/Query/CriterionVisitor.php @@ -7,7 +7,6 @@ namespace Ibexa\Contracts\Solr\Query; -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; @@ -18,17 +17,13 @@ abstract class CriterionVisitor { /** * CHeck if visitor is applicable to current criterion. - * - * @return bool */ abstract public function canVisit(CriterionInterface $criterion); /** * Map field value to a proper Solr representation. - * - * @return string */ - abstract public function visit(CriterionInterface $criterion, self $subVisitor = null); + abstract public function visit(CriterionInterface $criterion, ?self $subVisitor = null); /** * Get Solr range. @@ -41,14 +36,8 @@ abstract public function visit(CriterionInterface $criterion, self $subVisitor = * - case Operator::LT: * - case Operator::LTE: * - case Operator::BETWEEN: - * - * @param mixed $operator - * @param mixed $start - * @param mixed $end - * - * @return string */ - protected function getRange($operator, $start, $end) + protected function getRange(string $operator, mixed $start, mixed $end): string { $startBrace = '['; $startValue = '*'; @@ -91,35 +80,22 @@ protected function getRange($operator, $start, $end) /** * Converts given $value to the appropriate Solr string representation. - * - * @param mixed $value - * - * @return string */ - protected function toString($value) + protected function toString(mixed $value): string { - switch (\gettype($value)) { - case 'boolean': - return $value ? 'true' : 'false'; - case 'double': - return sprintf('%F', $value); - - default: - return (string)$value; - } + return match (\gettype($value)) { + 'boolean' => $value ? 'true' : 'false', + 'double' => sprintf('%F', $value), + default => (string)$value, + }; } /** * Escapes given $string for wrapping inside single or double quotes. * * Does not include quotes in the returned string, this needs to be done by the consumer code. - * - * @param string $string - * @param bool $doubleQuote - * - * @return string */ - protected function escapeQuote($string, $doubleQuote = false) + protected function escapeQuote(string $string, bool $doubleQuote = false): string { $pattern = ($doubleQuote ? '/("|\\\)/' : '/(\'|\\\)/'); @@ -129,12 +105,9 @@ protected function escapeQuote($string, $doubleQuote = false) /** * Escapes value for use in expressions. * - * @param string $string * @param bool $allowWildcard Allow "*" in expression. - * - * @return mixed */ - protected function escapeExpressions($string, $allowWildcard = false) + protected function escapeExpressions(string $string, bool $allowWildcard = false): ?string { if ($allowWildcard) { $reservedCharacters = preg_quote('+-&|!(){}[]^"~?:\\ '); @@ -144,9 +117,7 @@ protected function escapeExpressions($string, $allowWildcard = false) return preg_replace_callback( '/([' . $reservedCharacters . '])/', - static function ($matches): string { - return '\\' . $matches[0]; - }, + static fn (array $matches): string => '\\' . $matches[0], $string ); } diff --git a/src/contracts/Query/SortClauseVisitor.php b/src/contracts/Query/SortClauseVisitor.php index 2b28090b..d22d87da 100644 --- a/src/contracts/Query/SortClauseVisitor.php +++ b/src/contracts/Query/SortClauseVisitor.php @@ -15,25 +15,19 @@ abstract class SortClauseVisitor { /** - * CHeck if visitor is applicable to current sort clause. - * - * @return bool + * Check if visitor is applicable to current sort clause. */ - abstract public function canVisit(SortClause $sortClause); + abstract public function canVisit(SortClause $sortClause): bool; /** * Map field value to a proper Solr representation. - * - * @return string */ - abstract public function visit(SortClause $sortClause); + abstract public function visit(SortClause $sortClause): string; /** * Get solr sort direction for sort clause. - * - * @return string */ - protected function getDirection(SortClause $sortClause) + protected function getDirection(SortClause $sortClause): string { return ' ' . ($sortClause->direction === 'descending' ? 'desc' : 'asc'); } diff --git a/src/contracts/ResultExtractor/AggregationResultExtractor.php b/src/contracts/ResultExtractor/AggregationResultExtractor.php index d7365d4b..9d6e2227 100644 --- a/src/contracts/ResultExtractor/AggregationResultExtractor.php +++ b/src/contracts/ResultExtractor/AggregationResultExtractor.php @@ -14,7 +14,13 @@ interface AggregationResultExtractor { + /** + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter + */ public function canVisit(Aggregation $aggregation, array $languageFilter): bool; + /** + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter + */ public function extract(Aggregation $aggregation, array $languageFilter, stdClass $data): AggregationResult; } diff --git a/src/contracts/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper.php b/src/contracts/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper.php index 1ffc8c5c..f9bd99fb 100644 --- a/src/contracts/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper.php +++ b/src/contracts/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper.php @@ -12,5 +12,8 @@ interface RangeAggregationKeyMapper { - public function map(Aggregation $aggregation, array $languageFilter, string $key); + /** + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter + */ + public function map(Aggregation $aggregation, array $languageFilter, string $key): mixed; } diff --git a/src/contracts/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper.php b/src/contracts/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper.php index 62fc1e9c..81f21ada 100644 --- a/src/contracts/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper.php +++ b/src/contracts/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper.php @@ -12,5 +12,11 @@ interface TermAggregationKeyMapper { + /** + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter + * @param array $keys + * + * @return array + */ public function map(Aggregation $aggregation, array $languageFilter, array $keys): array; } diff --git a/src/contracts/Test/IbexaSolrTestKernel.php b/src/contracts/Test/IbexaSolrTestKernel.php index 6c05ab83..ce0df379 100644 --- a/src/contracts/Test/IbexaSolrTestKernel.php +++ b/src/contracts/Test/IbexaSolrTestKernel.php @@ -23,6 +23,7 @@ */ final class IbexaSolrTestKernel extends BaseIbexaTestKernel { + #[\Override] public function registerBundles(): iterable { yield from parent::registerBundles(); @@ -30,6 +31,7 @@ public function registerBundles(): iterable yield new IbexaSolrBundle(); } + #[\Override] protected static function getExposedServicesById(): iterable { yield from parent::getExposedServicesById(); @@ -37,6 +39,7 @@ protected static function getExposedServicesById(): iterable yield SolrHandler::class => Handler::class; } + #[\Override] public function registerContainerConfiguration(LoaderInterface $loader): void { parent::registerContainerConfiguration($loader); diff --git a/src/lib/Container/Compiler/AggregateFacetBuilderVisitorPass.php b/src/lib/Container/Compiler/AggregateFacetBuilderVisitorPass.php deleted file mode 100644 index e69de29b..00000000 diff --git a/src/lib/Container/Compiler/BaseFieldMapperPass.php b/src/lib/Container/Compiler/BaseFieldMapperPass.php index d28e23b2..bdb8023a 100644 --- a/src/lib/Container/Compiler/BaseFieldMapperPass.php +++ b/src/lib/Container/Compiler/BaseFieldMapperPass.php @@ -19,12 +19,12 @@ abstract class BaseFieldMapperPass implements CompilerPassInterface /** * Service ID of the aggregate plugin. */ - public const AGGREGATE_MAPPER_SERVICE_ID = null; + public const string AGGREGATE_MAPPER_SERVICE_ID = ''; /** * Service tag of plugins registering to the aggregate one. */ - public const AGGREGATE_MAPPER_SERVICE_TAG = null; + public const string AGGREGATE_MAPPER_SERVICE_TAG = ''; public function process(ContainerBuilder $container): void { diff --git a/src/lib/Container/Compiler/CoreFilterRegistryPass.php b/src/lib/Container/Compiler/CoreFilterRegistryPass.php index 480b1833..8c3eddbe 100644 --- a/src/lib/Container/Compiler/CoreFilterRegistryPass.php +++ b/src/lib/Container/Compiler/CoreFilterRegistryPass.php @@ -15,7 +15,7 @@ final class CoreFilterRegistryPass implements CompilerPassInterface { - public const CORE_FILTER_SERVICE_TAG = 'ibexa.search.solr.core.filter'; + public const string CORE_FILTER_SERVICE_TAG = 'ibexa.search.solr.core.filter'; public function process(ContainerBuilder $container): void { diff --git a/src/lib/Container/Compiler/EndpointRegistryPass.php b/src/lib/Container/Compiler/EndpointRegistryPass.php index 25a12404..29a5f39b 100644 --- a/src/lib/Container/Compiler/EndpointRegistryPass.php +++ b/src/lib/Container/Compiler/EndpointRegistryPass.php @@ -19,8 +19,6 @@ class EndpointRegistryPass implements CompilerPassInterface { /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container - * * @throws \LogicException */ public function process(ContainerBuilder $container): void diff --git a/src/lib/Container/Compiler/FieldMapperPass/BlockFieldMapperPass.php b/src/lib/Container/Compiler/FieldMapperPass/BlockFieldMapperPass.php index 046aae01..ada9b6b3 100644 --- a/src/lib/Container/Compiler/FieldMapperPass/BlockFieldMapperPass.php +++ b/src/lib/Container/Compiler/FieldMapperPass/BlockFieldMapperPass.php @@ -14,6 +14,6 @@ */ class BlockFieldMapperPass extends BaseFieldMapperPass { - public const AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.block'; - public const AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.block'; + public const string AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.block'; + public const string AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.block'; } diff --git a/src/lib/Container/Compiler/FieldMapperPass/BlockTranslationFieldMapperPass.php b/src/lib/Container/Compiler/FieldMapperPass/BlockTranslationFieldMapperPass.php index 047c3962..4d089930 100644 --- a/src/lib/Container/Compiler/FieldMapperPass/BlockTranslationFieldMapperPass.php +++ b/src/lib/Container/Compiler/FieldMapperPass/BlockTranslationFieldMapperPass.php @@ -15,6 +15,6 @@ */ class BlockTranslationFieldMapperPass extends BaseFieldMapperPass { - public const AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.block_translation'; - public const AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.block.translation'; + public const string AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.block_translation'; + public const string AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.block.translation'; } diff --git a/src/lib/Container/Compiler/FieldMapperPass/ContentFieldMapperPass.php b/src/lib/Container/Compiler/FieldMapperPass/ContentFieldMapperPass.php index 9d4863fe..0c058b1e 100644 --- a/src/lib/Container/Compiler/FieldMapperPass/ContentFieldMapperPass.php +++ b/src/lib/Container/Compiler/FieldMapperPass/ContentFieldMapperPass.php @@ -14,6 +14,6 @@ */ class ContentFieldMapperPass extends BaseFieldMapperPass { - public const AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.content'; - public const AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.content'; + public const string AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.content'; + public const string AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.content'; } diff --git a/src/lib/Container/Compiler/FieldMapperPass/ContentTranslationFieldMapperPass.php b/src/lib/Container/Compiler/FieldMapperPass/ContentTranslationFieldMapperPass.php index 179ee114..66865617 100644 --- a/src/lib/Container/Compiler/FieldMapperPass/ContentTranslationFieldMapperPass.php +++ b/src/lib/Container/Compiler/FieldMapperPass/ContentTranslationFieldMapperPass.php @@ -15,6 +15,6 @@ */ class ContentTranslationFieldMapperPass extends BaseFieldMapperPass { - public const AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.content_translation'; - public const AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.content.translation'; + public const string AGGREGATE_MAPPER_SERVICE_ID = 'ibexa.solr.field_mapper.content_translation'; + public const string AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.content.translation'; } diff --git a/src/lib/Container/Compiler/FieldMapperPass/LocationFieldMapperPass.php b/src/lib/Container/Compiler/FieldMapperPass/LocationFieldMapperPass.php index c9008d09..6ef958f6 100644 --- a/src/lib/Container/Compiler/FieldMapperPass/LocationFieldMapperPass.php +++ b/src/lib/Container/Compiler/FieldMapperPass/LocationFieldMapperPass.php @@ -15,6 +15,6 @@ */ class LocationFieldMapperPass extends BaseFieldMapperPass { - public const AGGREGATE_MAPPER_SERVICE_ID = Aggregate::class; - public const AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.location'; + public const string AGGREGATE_MAPPER_SERVICE_ID = Aggregate::class; + public const string AGGREGATE_MAPPER_SERVICE_TAG = 'ibexa.search.solr.field.mapper.location'; } diff --git a/src/lib/Container/Compiler/GatewayRegistryPass.php b/src/lib/Container/Compiler/GatewayRegistryPass.php index 19eee9ef..87cfe5a3 100644 --- a/src/lib/Container/Compiler/GatewayRegistryPass.php +++ b/src/lib/Container/Compiler/GatewayRegistryPass.php @@ -15,7 +15,7 @@ final class GatewayRegistryPass implements CompilerPassInterface { - public const GATEWAY_SERVICE_TAG = 'ibexa.search.solr.gateway'; + public const string GATEWAY_SERVICE_TAG = 'ibexa.search.solr.gateway'; public function process(ContainerBuilder $container): void { diff --git a/src/lib/CoreFilter.php b/src/lib/CoreFilter.php index 15ceeca6..193ed2b0 100644 --- a/src/lib/CoreFilter.php +++ b/src/lib/CoreFilter.php @@ -18,7 +18,7 @@ abstract class CoreFilter /** * Applies conditions on the $query using given $languageSettings. * - * @param string $documentTypeIdentifier + * @param array $languageSettings */ - abstract public function apply(Query $query, array $languageSettings, $documentTypeIdentifier); + abstract public function apply(Query $query, array $languageSettings, string $documentTypeIdentifier): void; } diff --git a/src/lib/CoreFilter/CoreFilterRegistry.php b/src/lib/CoreFilter/CoreFilterRegistry.php index 76de550f..784fd7f0 100644 --- a/src/lib/CoreFilter/CoreFilterRegistry.php +++ b/src/lib/CoreFilter/CoreFilterRegistry.php @@ -12,19 +12,16 @@ final class CoreFilterRegistry { - /** @var \Ibexa\Solr\CoreFilter[] */ - private array $coreFilters; - /** - * @param \Ibexa\Solr\CoreFilter[] $coreFilters + * @param array $coreFilters */ - public function __construct(array $coreFilters = []) - { - $this->coreFilters = $coreFilters; + public function __construct( + private array $coreFilters = [] + ) { } /** - * @return \Ibexa\Solr\CoreFilter[] $coreFilters + * @return array $coreFilters */ public function getCoreFilters(): array { @@ -32,7 +29,7 @@ public function getCoreFilters(): array } /** - * @param \Ibexa\Solr\CoreFilter[] $coreFilters + * @param array $coreFilters */ public function setCoreFilters(array $coreFilters): void { diff --git a/src/lib/CoreFilter/NativeCoreFilter.php b/src/lib/CoreFilter/NativeCoreFilter.php index de2669b1..504b83b9 100644 --- a/src/lib/CoreFilter/NativeCoreFilter.php +++ b/src/lib/CoreFilter/NativeCoreFilter.php @@ -30,55 +30,43 @@ class NativeCoreFilter extends CoreFilter /** * Name of the Solr backend field holding document type identifier * ('content' or 'location'). - * - * @var string */ - public const FIELD_DOCUMENT_TYPE = 'document_type_id'; + public const string FIELD_DOCUMENT_TYPE = 'document_type_id'; /** * Name of the Solr backend field holding list of all translation's Content * language codes. - * - * @var string */ - public const FIELD_LANGUAGES = 'content_language_codes_ms'; + public const string FIELD_LANGUAGES = 'content_language_codes_ms'; /** * Name of the Solr backend field holding language code of the indexed * translation. - * - * @var string */ - public const FIELD_LANGUAGE = 'meta_indexed_language_code_s'; + public const string FIELD_LANGUAGE = 'meta_indexed_language_code_s'; /** * Name of the Solr backend field indicating if the indexed translation * is in the main language. - * - * @var string */ - public const FIELD_IS_MAIN_LANGUAGE = 'meta_indexed_is_main_translation_b'; + public const string FIELD_IS_MAIN_LANGUAGE = 'meta_indexed_is_main_translation_b'; /** * Name of the Solr backend field indicating if the indexed translation * is always available. - * - * @var string */ - public const FIELD_IS_ALWAYS_AVAILABLE = 'meta_indexed_is_main_translation_and_always_available_b'; + public const string FIELD_IS_ALWAYS_AVAILABLE = 'meta_indexed_is_main_translation_and_always_available_b'; /** * Name of the Solr backend field indicating if the indexed document is * located in the main translations index. - * - * @var string */ - public const FIELD_IS_MAIN_LANGUAGES_INDEX = 'meta_indexed_main_translation_b'; + public const string FIELD_IS_MAIN_LANGUAGES_INDEX = 'meta_indexed_main_translation_b'; /** * Indicates presence of main languages index. */ - private bool $hasMainLanguagesEndpoint; + private readonly bool $hasMainLanguagesEndpoint; public function __construct(EndpointResolver $endpointResolver) { @@ -87,7 +75,7 @@ public function __construct(EndpointResolver $endpointResolver) ); } - public function apply(Query $query, array $languageSettings, $documentTypeIdentifier): void + public function apply(Query $query, array $languageSettings, string $documentTypeIdentifier): void { $languages = ( empty($languageSettings['languages']) ? @@ -124,7 +112,7 @@ public function apply(Query $query, array $languageSettings, $documentTypeIdenti * The condition ensures the same Content will be matched only once across all * targeted translation endpoints. * - * @param string[] $languageCodes + * @param list $languageCodes */ private function getCoreCriterion( array $languageCodes, @@ -161,7 +149,7 @@ private function getCoreCriterion( /** * Returns criteria for prioritized languages fallback. * - * @param string[] $languageCodes + * @param list $languageCodes */ private function getLanguageFilter(array $languageCodes): Query\CriterionInterface { @@ -215,7 +203,9 @@ private function getLanguageFilter(array $languageCodes): Query\CriterionInterfa /** * Returns criteria for always available translation fallback. * - * @param string[] $languageCodes + * @param list $languageCodes + * + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidCriterionArgumentException */ private function getAlwaysAvailableFilter( array $languageCodes, @@ -260,12 +250,11 @@ private function getAlwaysAvailableFilter( * * If $selectedLanguageCode is omitted, all languages will be returned. * - * @param string[] $languageCodes - * @param string|null $selectedLanguageCode + * @param list $languageCodes * - * @return string[] + * @return list */ - private function getExcludedLanguageCodes(array $languageCodes, $selectedLanguageCode = null): array + private function getExcludedLanguageCodes(array $languageCodes, ?string $selectedLanguageCode = null): array { $excludedLanguageCodes = []; diff --git a/src/lib/DocumentMapper/NativeDocumentMapper.php b/src/lib/DocumentMapper/NativeDocumentMapper.php index d2e7564e..c3c6e641 100644 --- a/src/lib/DocumentMapper/NativeDocumentMapper.php +++ b/src/lib/DocumentMapper/NativeDocumentMapper.php @@ -10,7 +10,6 @@ use Ibexa\Contracts\Core\Persistence\Content; use Ibexa\Contracts\Core\Persistence\Content\Location; use Ibexa\Contracts\Core\Persistence\Content\Location\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as LocationHandler; use Ibexa\Contracts\Core\Search\Document; use Ibexa\Contracts\Solr\DocumentMapper; use Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper; @@ -22,38 +21,17 @@ */ class NativeDocumentMapper implements DocumentMapper { - private ContentFieldMapper $blockFieldMapper; - - private ContentTranslationFieldMapper $blockTranslationFieldMapper; - - private ContentFieldMapper $contentFieldMapper; - - private ContentTranslationFieldMapper $contentTranslationFieldMapper; - - private LocationFieldMapper $locationFieldMapper; - - /** - * Location handler. - */ - protected Handler $locationHandler; - /** * Creates a new document mapper. */ public function __construct( - ContentFieldMapper $blockFieldMapper, - ContentTranslationFieldMapper $blockTranslationFieldMapper, - ContentFieldMapper $contentFieldMapper, - ContentTranslationFieldMapper $contentTranslationFieldMapper, - LocationFieldMapper $locationFieldMapper, - LocationHandler $locationHandler + private readonly ContentFieldMapper $blockFieldMapper, + private readonly ContentTranslationFieldMapper $blockTranslationFieldMapper, + private readonly ContentFieldMapper $contentFieldMapper, + private readonly ContentTranslationFieldMapper $contentTranslationFieldMapper, + private readonly LocationFieldMapper $locationFieldMapper, + protected readonly Handler $locationHandler ) { - $this->blockFieldMapper = $blockFieldMapper; - $this->blockTranslationFieldMapper = $blockTranslationFieldMapper; - $this->contentFieldMapper = $contentFieldMapper; - $this->contentTranslationFieldMapper = $contentTranslationFieldMapper; - $this->locationFieldMapper = $locationFieldMapper; - $this->locationHandler = $locationHandler; } /** @@ -84,7 +62,7 @@ public function mapContentBlock(Content $content): array foreach ($locations as $location) { $translationLocationDocuments[] = new Document( [ - 'id' => $this->generateLocationDocumentId($location->id, $languageCode), + 'id' => $this->generateLocationDocumentId((int)$location->id, $languageCode), 'fields' => array_merge( $blockFields, $locationFieldsMap[$location->id], @@ -104,7 +82,7 @@ public function mapContentBlock(Content $content): array $documents[] = new Document( [ 'id' => $this->generateContentDocumentId( - $contentInfo->id, + (int)$contentInfo->id, $languageCode ), 'languageCode' => $languageCode, @@ -133,13 +111,8 @@ public function mapContentBlock(Content $content): array * The above is useful when targeting all Content's documents, without * the knowledge of it's translations, and thanks to "lang" string it will not * risk matching other documents (as was the case in EZP-26484). - * - * @param int|string $contentId - * @param string|null $languageCode - * - * @return string */ - public function generateContentDocumentId($contentId, $languageCode = null): string + public function generateContentDocumentId(int $contentId, ?string $languageCode = null): string { return strtolower("content{$contentId}lang{$languageCode}"); } @@ -153,13 +126,8 @@ public function generateContentDocumentId($contentId, $languageCode = null): str * The above is useful when targeting all Location's documents, without * the knowledge of it's translations, and thanks to "lang" string it will not * risk matching other documents (as was the case in EZP-26484). - * - * @param int|string $locationId - * @param string|null $languageCode - * - * @return string */ - public function generateLocationDocumentId($locationId, $languageCode = null): string + public function generateLocationDocumentId(int $locationId, ?string $languageCode = null): string { return strtolower("location{$locationId}lang{$languageCode}"); } @@ -170,7 +138,7 @@ public function generateLocationDocumentId($locationId, $languageCode = null): s * * @return \Ibexa\Contracts\Core\Search\Field[] */ - private function getBlockFields(Content $content) + private function getBlockFields(Content $content): array { $fields = []; @@ -187,7 +155,7 @@ private function getBlockFields(Content $content) * * @return \Ibexa\Contracts\Core\Search\Field[] */ - private function getBlockTranslationFields(Content $content, string $languageCode) + private function getBlockTranslationFields(Content $content, string $languageCode): array { $fields = []; @@ -204,7 +172,7 @@ private function getBlockTranslationFields(Content $content, string $languageCod * * @return \Ibexa\Contracts\Core\Search\Field[] */ - private function getContentFields(Content $content) + private function getContentFields(Content $content): array { $fields = []; @@ -221,7 +189,7 @@ private function getContentFields(Content $content) * * @return \Ibexa\Contracts\Core\Search\Field[] */ - private function getContentTranslationFields(Content $content, string $languageCode) + private function getContentTranslationFields(Content $content, string $languageCode): array { $fields = []; @@ -238,7 +206,7 @@ private function getContentTranslationFields(Content $content, string $languageC * * @return \Ibexa\Contracts\Core\Search\Field[] */ - private function getLocationFields(Location $location) + private function getLocationFields(Location $location): array { $fields = []; diff --git a/src/lib/FieldMapper/BoostFactorProvider.php b/src/lib/FieldMapper/BoostFactorProvider.php index 5d4bd80a..8d91b79f 100644 --- a/src/lib/FieldMapper/BoostFactorProvider.php +++ b/src/lib/FieldMapper/BoostFactorProvider.php @@ -30,58 +30,57 @@ class BoostFactorProvider */ private static string $keyAny = '*'; - /** - * Internal map of field boost factors. - * - * ```php - * $map = [ - * 'content-fields' => [ - * '*' => [ - * 'title' => 1.5, - * 'name' = 2.5, - * ], - * 'article' => [ - * 'title' => 3.0, - * '*' => 2.0, - * ], - * 'news' => [ - * 'description' => 3.0, - * ], - * ], - * 'meta-fields' => [ - * '*' => [ - * 'name' = 2.5, - * 'text' => 1.5, - * ], - * 'article' => [ - * 'name' => 3.0, - * '*' => 2.0, - * ], - * 'news' => [ - * 'text' => 2.0, - * ], - * ], - * ]; - * ``` - */ - private array $map; - /** * Boost factor to be used if no mapping is found. */ private float $defaultBoostFactor = 1.0; - public function __construct(array $map = []) - { - $this->map = $map; + /** + * @param array $map + */ + public function __construct( + /** + * Internal map of field boost factors. + * + * ```php + * $map = [ + * 'content-fields' => [ + * '*' => [ + * 'title' => 1.5, + * 'name' = 2.5, + * ], + * 'article' => [ + * 'title' => 3.0, + * '*' => 2.0, + * ], + * 'news' => [ + * 'description' => 3.0, + * ], + * ], + * 'meta-fields' => [ + * '*' => [ + * 'name' = 2.5, + * 'text' => 1.5, + * ], + * 'article' => [ + * 'name' => 3.0, + * '*' => 2.0, + * ], + * 'news' => [ + * 'text' => 2.0, + * ], + * ], + * ]; + * ``` + */ + private array $map = [] + ) { } /** * Get boost factor for a Content field by the given $contentType and $fieldDefinition. - * - * @return float */ - public function getContentFieldBoostFactor(ContentType $contentType, FieldDefinition $fieldDefinition) + public function getContentFieldBoostFactor(ContentType $contentType, FieldDefinition $fieldDefinition): float { $typeIdentifier = $contentType->identifier; $fieldIdentifier = $fieldDefinition->identifier; @@ -94,21 +93,13 @@ public function getContentFieldBoostFactor(ContentType $contentType, FieldDefini $fieldIdentifier = self::$keyAny; } - if (isset($this->map[self::$keyContentFields][$typeIdentifier][$fieldIdentifier])) { - return $this->map[self::$keyContentFields][$typeIdentifier][$fieldIdentifier]; - } - - return $this->defaultBoostFactor; + return $this->map[self::$keyContentFields][$typeIdentifier][$fieldIdentifier] ?? $this->defaultBoostFactor; } /** * Get boost factor for a Content meta field by the given $fieldName. - * - * @param string $fieldName - * - * @return float */ - public function getContentMetaFieldBoostFactor(ContentType $contentType, $fieldName) + public function getContentMetaFieldBoostFactor(ContentType $contentType, string $fieldName): float { $typeIdentifier = $contentType->identifier; @@ -120,10 +111,6 @@ public function getContentMetaFieldBoostFactor(ContentType $contentType, $fieldN $fieldName = self::$keyAny; } - if (isset($this->map[self::$keyMetaFields][$typeIdentifier][$fieldName])) { - return $this->map[self::$keyMetaFields][$typeIdentifier][$fieldName]; - } - - return $this->defaultBoostFactor; + return $this->map[self::$keyMetaFields][$typeIdentifier][$fieldName] ?? $this->defaultBoostFactor; } } diff --git a/src/lib/FieldMapper/ContentFieldMapper/Aggregate.php b/src/lib/FieldMapper/ContentFieldMapper/Aggregate.php index 8a0c9698..c73b9ec2 100644 --- a/src/lib/FieldMapper/ContentFieldMapper/Aggregate.php +++ b/src/lib/FieldMapper/ContentFieldMapper/Aggregate.php @@ -20,7 +20,7 @@ class Aggregate extends ContentFieldMapper * * @var \Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper[] */ - protected $mappers = []; + protected array $mappers = []; /** * @param \Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper[] $mappers @@ -46,9 +46,6 @@ public function accept(Content $content): bool return true; } - /** - * @return mixed[] - */ public function mapFields(Content $content): array { $fields = []; diff --git a/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php b/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php index 22ec41a7..582ea282 100644 --- a/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php +++ b/src/lib/FieldMapper/ContentFieldMapper/BlockDocumentsBaseContentFields.php @@ -9,7 +9,6 @@ use Ibexa\Contracts\Core\Persistence\Content; use Ibexa\Contracts\Core\Persistence\Content\Location\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as LocationHandler; use Ibexa\Contracts\Core\Persistence\Content\ObjectState\Handler as ObjectStateHandler; use Ibexa\Contracts\Core\Persistence\Content\Section\Handler as SectionHandler; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandler; @@ -23,24 +22,12 @@ */ class BlockDocumentsBaseContentFields extends ContentFieldMapper { - protected Handler $locationHandler; - - protected ContentTypeHandler $contentTypeHandler; - - protected ObjectStateHandler $objectStateHandler; - - protected SectionHandler $sectionHandler; - public function __construct( - LocationHandler $locationHandler, - ContentTypeHandler $contentTypeHandler, - ObjectStateHandler $objectStateHandler, - SectionHandler $sectionHandler + protected readonly Handler $locationHandler, + protected readonly ContentTypeHandler $contentTypeHandler, + protected readonly ObjectStateHandler $objectStateHandler, + protected readonly SectionHandler $sectionHandler ) { - $this->locationHandler = $locationHandler; - $this->contentTypeHandler = $contentTypeHandler; - $this->objectStateHandler = $objectStateHandler; - $this->sectionHandler = $sectionHandler; } public function accept(Content $content): bool @@ -57,7 +44,7 @@ public function mapFields(Content $content): array // Locations hierarchy. We index all ancestor Location Content ids of all // Locations of an owner. $ancestorLocationsContentIds = $this->getAncestorLocationsContentIds( - $contentInfo->ownerId + (int)$contentInfo->ownerId ); // Add owner user id as it can also be considered as user group. $ancestorLocationsContentIds[] = $contentInfo->ownerId; @@ -174,12 +161,12 @@ public function mapFields(Content $content): array ), new Field( 'content_object_state_ids', - $this->getObjectStateIds($contentInfo->id), + $this->getObjectStateIds((int)$contentInfo->id), new FieldType\MultipleIdentifierField() ), new Field( 'content_object_state_identifiers', - $this->getObjectStateIdentifiers($contentInfo->id), + $this->getObjectStateIdentifiers((int)$contentInfo->id), new FieldType\MultipleStringField() ), ]; @@ -188,11 +175,9 @@ public function mapFields(Content $content): array /** * Returns an array of object state ids of a Content with given $contentId. * - * @param int|string $contentId - * - * @return array + * @return list */ - protected function getObjectStateIds($contentId): array + protected function getObjectStateIds(int $contentId): array { $objectStateIds = []; @@ -202,7 +187,7 @@ protected function getObjectStateIds($contentId): array $contentId, $objectStateGroup->id )->id; - } catch (NotFoundException $e) { + } catch (NotFoundException) { // // Ignore empty object state groups } } @@ -211,7 +196,7 @@ protected function getObjectStateIds($contentId): array } /** - * @return string[] + * @return list */ protected function getObjectStateIdentifiers(int $contentId): array { @@ -237,11 +222,9 @@ protected function getObjectStateIdentifiers(int $contentId): array * * Used to determine user groups of a user with $contentId. * - * @param int|string $contentId - * - * @return array + * @return list */ - protected function getAncestorLocationsContentIds($contentId) + protected function getAncestorLocationsContentIds(int $contentId): array { $locations = $this->locationHandler->loadLocationsByContent($contentId); $ancestorLocationContentIds = []; diff --git a/src/lib/FieldMapper/ContentFieldMapper/ContentDocumentLocationFields.php b/src/lib/FieldMapper/ContentFieldMapper/ContentDocumentLocationFields.php index 616f31ab..89f4e6a4 100644 --- a/src/lib/FieldMapper/ContentFieldMapper/ContentDocumentLocationFields.php +++ b/src/lib/FieldMapper/ContentFieldMapper/ContentDocumentLocationFields.php @@ -11,7 +11,6 @@ use Ibexa\Contracts\Core\Persistence\Content; use Ibexa\Contracts\Core\Persistence\Content\Location; use Ibexa\Contracts\Core\Persistence\Content\Location\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as LocationHandler; use Ibexa\Contracts\Core\Search\Field; use Ibexa\Contracts\Core\Search\FieldType; use Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper; @@ -21,16 +20,10 @@ */ class ContentDocumentLocationFields extends ContentFieldMapper { - protected Handler $locationHandler; - - private BookmarkHandler $bookmarkHandler; - public function __construct( - BookmarkHandler $bookmarkHandler, - LocationHandler $locationHandler + private readonly BookmarkHandler $bookmarkHandler, + protected readonly Handler $locationHandler ) { - $this->bookmarkHandler = $bookmarkHandler; - $this->locationHandler = $locationHandler; } public function accept(Content $content): bool @@ -38,9 +31,6 @@ public function accept(Content $content): bool return true; } - /** - * @return \Ibexa\Contracts\Core\Search\Field[] - */ public function mapFields(Content $content): array { $locations = $this->locationHandler->loadLocationsByContent($content->versionInfo->contentInfo->id); @@ -94,7 +84,7 @@ public function mapFields(Content $content): array ); $fields[] = new Field( 'location_ancestors', - $locationData['ancestors'], + $locationData['ancestors'] ?? [], new FieldType\MultipleIdentifierField() ); @@ -152,6 +142,9 @@ public function mapFields(Content $content): array return $fields; } + /** + * @return list + */ private function getAncestors(Location $location): array { $ancestorsIds = explode('/', trim($location->pathString, '/')); diff --git a/src/lib/FieldMapper/ContentFieldMapper/UserDocumentFields.php b/src/lib/FieldMapper/ContentFieldMapper/UserDocumentFields.php index 6afe1d64..13c78b84 100644 --- a/src/lib/FieldMapper/ContentFieldMapper/UserDocumentFields.php +++ b/src/lib/FieldMapper/ContentFieldMapper/UserDocumentFields.php @@ -16,7 +16,7 @@ final class UserDocumentFields extends ContentFieldMapper { /** @internal */ - public const HASHING_ALGORITHM = 'sha256'; + public const string HASHING_ALGORITHM = 'sha256'; public function accept(SPIContent $content): bool { diff --git a/src/lib/FieldMapper/ContentTranslationFieldMapper/Aggregate.php b/src/lib/FieldMapper/ContentTranslationFieldMapper/Aggregate.php index 0685efd1..a920f47b 100644 --- a/src/lib/FieldMapper/ContentTranslationFieldMapper/Aggregate.php +++ b/src/lib/FieldMapper/ContentTranslationFieldMapper/Aggregate.php @@ -20,11 +20,10 @@ class Aggregate extends ContentTranslationFieldMapper * * @var \Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper[] */ - protected $mappers = []; + protected array $mappers = []; /** - * @param \Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper[] $mappers - * An array of mappers, sorted by priority. + * @param \Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper[] $mappers An array of mappers, sorted by priority. */ public function __construct(array $mappers = []) { @@ -41,15 +40,12 @@ public function addMapper(ContentTranslationFieldMapper $mapper): void $this->mappers[] = $mapper; } - public function accept(Content $content, $languageCode): bool + public function accept(Content $content, string $languageCode): bool { return true; } - /** - * @return mixed[] - */ - public function mapFields(Content $content, $languageCode): array + public function mapFields(Content $content, string $languageCode): array { $fields = []; diff --git a/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsContentFields.php b/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsContentFields.php index a3558beb..31aa33d5 100644 --- a/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsContentFields.php +++ b/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsContentFields.php @@ -11,7 +11,6 @@ use Ibexa\Contracts\Core\Persistence\Content\Type as ContentType; use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandler; use Ibexa\Contracts\Core\Search\Field; use Ibexa\Contracts\Core\Search\FieldType; use Ibexa\Contracts\Core\Search\FieldType\TextField; @@ -25,35 +24,20 @@ */ class BlockDocumentsContentFields extends ContentTranslationFieldMapper { - protected Handler $contentTypeHandler; - - protected FieldRegistry $fieldRegistry; - - protected FieldNameGenerator $fieldNameGenerator; - - protected BoostFactorProvider $boostFactorProvider; - public function __construct( - ContentTypeHandler $contentTypeHandler, - FieldRegistry $fieldRegistry, - FieldNameGenerator $fieldNameGenerator, - BoostFactorProvider $boostFactorProvider + protected readonly Handler $contentTypeHandler, + protected readonly FieldRegistry $fieldRegistry, + protected readonly FieldNameGenerator $fieldNameGenerator, + protected readonly BoostFactorProvider $boostFactorProvider ) { - $this->contentTypeHandler = $contentTypeHandler; - $this->fieldRegistry = $fieldRegistry; - $this->fieldNameGenerator = $fieldNameGenerator; - $this->boostFactorProvider = $boostFactorProvider; } - public function accept(Content $content, $languageCode): bool + public function accept(Content $content, string $languageCode): bool { return true; } - /** - * @return \Ibexa\Contracts\Core\Search\Field[] - */ - public function mapFields(Content $content, $languageCode): array + public function mapFields(Content $content, string $languageCode): array { $fields = []; $contentType = $this->contentTypeHandler->load( @@ -100,8 +84,6 @@ public function mapFields(Content $content, $languageCode): array /** * Return index field type for the given arguments. - * - * @return \Ibexa\Contracts\Core\Search\FieldType */ private function getIndexFieldType( ContentType $contentType, diff --git a/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsMetaFields.php b/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsMetaFields.php index 60c61863..8685a41a 100644 --- a/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsMetaFields.php +++ b/src/lib/FieldMapper/ContentTranslationFieldMapper/BlockDocumentsMetaFields.php @@ -17,12 +17,12 @@ */ class BlockDocumentsMetaFields extends ContentTranslationFieldMapper { - public function accept(Content $content, $languageCode): bool + public function accept(Content $content, string $languageCode): bool { return true; } - public function mapFields(Content $content, $languageCode): array + public function mapFields(Content $content, string $languageCode): array { return [ new Field( diff --git a/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentEmptyFields.php b/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentEmptyFields.php index 80adc8c8..32a3875e 100644 --- a/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentEmptyFields.php +++ b/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentEmptyFields.php @@ -10,7 +10,6 @@ use Ibexa\Contracts\Core\Persistence\Content; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandler; use Ibexa\Contracts\Core\Search\Field; use Ibexa\Contracts\Core\Search\FieldType; use Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper; @@ -22,40 +21,21 @@ */ class ContentDocumentEmptyFields extends ContentTranslationFieldMapper { - public const IS_EMPTY_NAME = 'is_empty'; - - private Handler $contentTypeHandler; - - private FieldNameGenerator $fieldNameGenerator; - - private FieldTypeRegistry $fieldTypeRegistry; + public const string IS_EMPTY_NAME = 'is_empty'; public function __construct( - ContentTypeHandler $contentTypeHandler, - FieldNameGenerator $fieldNameGenerator, - FieldTypeRegistry $fieldTypeRegistry + private readonly Handler $contentTypeHandler, + private readonly FieldNameGenerator $fieldNameGenerator, + private readonly FieldTypeRegistry $fieldTypeRegistry ) { - $this->contentTypeHandler = $contentTypeHandler; - $this->fieldNameGenerator = $fieldNameGenerator; - $this->fieldTypeRegistry = $fieldTypeRegistry; } - /** - * @param string $languageCode - * - * @return bool - */ - public function accept(Content $content, $languageCode): bool + public function accept(Content $content, string $languageCode): bool { return true; } - /** - * @param string $languageCode - * - * @return \Ibexa\Contracts\Core\Search\Field[] - */ - public function mapFields(Content $content, $languageCode): array + public function mapFields(Content $content, string $languageCode): array { $fields = []; $contentType = $this->contentTypeHandler->load( diff --git a/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentFulltextFields.php b/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentFulltextFields.php index 94b7d9bb..b806d96a 100644 --- a/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentFulltextFields.php +++ b/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentFulltextFields.php @@ -9,7 +9,6 @@ use Ibexa\Contracts\Core\Persistence\Content; use Ibexa\Contracts\Core\Persistence\Content\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler; use Ibexa\Contracts\Core\Persistence\Content\Type as ContentType; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandler; use Ibexa\Contracts\Core\Search\Field; @@ -36,46 +35,22 @@ class ContentDocumentFulltextFields extends ContentTranslationFieldMapper */ private static string $relatedContentFieldName = 'meta_related_content_%d__text'; - protected ContentTypeHandler $contentTypeHandler; - - protected Handler $contentHandler; - - protected FieldRegistry $fieldRegistry; - - protected FieldNameGenerator $fieldNameGenerator; - - protected BoostFactorProvider $boostFactorProvider; - - protected IndexingDepthProvider $indexingDepthProvider; - public function __construct( - ContentTypeHandler $contentTypeHandler, - ContentHandler $contentHandler, - FieldRegistry $fieldRegistry, - FieldNameGenerator $fieldNameGenerator, - BoostFactorProvider $boostFactorProvider, - IndexingDepthProvider $indexingDepthProvider + protected readonly ContentTypeHandler $contentTypeHandler, + protected readonly Handler $contentHandler, + protected readonly FieldRegistry $fieldRegistry, + protected readonly FieldNameGenerator $fieldNameGenerator, + protected readonly BoostFactorProvider $boostFactorProvider, + protected readonly IndexingDepthProvider $indexingDepthProvider ) { - $this->contentTypeHandler = $contentTypeHandler; - $this->contentHandler = $contentHandler; - $this->fieldRegistry = $fieldRegistry; - $this->fieldNameGenerator = $fieldNameGenerator; - $this->boostFactorProvider = $boostFactorProvider; - $this->indexingDepthProvider = $indexingDepthProvider; } - /** - * {@inheritdoc} - */ - public function accept(Content $content, $languageCode): bool + public function accept(Content $content, string $languageCode): bool { return true; } - /** - * {@inheritdoc} - */ - public function mapFields(Content $content, $languageCode) + public function mapFields(Content $content, string $languageCode): array { $contentType = $this->contentTypeHandler->load( $content->versionInfo->contentInfo->contentTypeId @@ -89,16 +64,17 @@ public function mapFields(Content $content, $languageCode) } /** - * @param string $languageCode - * @param int $maxDepth - * @param int $depth - * - * @return \Ibexa\Contracts\Core\Search\Field[] + * @return list<\Ibexa\Contracts\Core\Search\Field> * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ - private function doMapFields(Content $content, ContentType $contentType, $languageCode, $maxDepth, int $depth = 0): array - { + private function doMapFields( + Content $content, + ContentType $contentType, + string $languageCode, + int $maxDepth, + int $depth = 0 + ): array { $fields = []; foreach ($content->fields as $field) { @@ -147,7 +123,6 @@ private function doMapFields(Content $content, ContentType $contentType, $langua * * @param string $languageCode * @param int $maxDepth - * @param int $depth * * @return \Ibexa\Contracts\Core\Search\Field[] * @@ -162,15 +137,11 @@ private function doMapRelatedFields(Content $sourceContent, $languageCode, $maxD ); $relatedContents = $this->contentHandler->loadContentList( - array_map(static function (Content\Relation $relation) { - return $relation->destinationContentId; - }, $relations) + array_map(static fn (Content\Relation $relation): int => $relation->destinationContentId, $relations) ); $contentTypes = $this->contentTypeHandler->loadContentTypeList( - array_map(static function (Content $content) { - return $content->versionInfo->contentInfo->contentTypeId; - }, $relatedContents) + array_map(static fn (Content $content): int => $content->versionInfo->contentInfo->contentTypeId, $relatedContents) ); $fields = []; diff --git a/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentTranslatedContentNameField.php b/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentTranslatedContentNameField.php index f3e47617..728593cf 100644 --- a/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentTranslatedContentNameField.php +++ b/src/lib/FieldMapper/ContentTranslationFieldMapper/ContentDocumentTranslatedContentNameField.php @@ -9,7 +9,6 @@ use Ibexa\Contracts\Core\Persistence\Content; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandler; use Ibexa\Contracts\Core\Search\Field; use Ibexa\Contracts\Core\Search\FieldType; use Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper; @@ -25,24 +24,18 @@ class ContentDocumentTranslatedContentNameField extends ContentTranslationFieldM */ private static string $fieldName = 'meta_content__name'; - protected Handler $contentTypeHandler; - - protected BoostFactorProvider $boostFactorProvider; - public function __construct( - ContentTypeHandler $contentTypeHandler, - BoostFactorProvider $boostFactorProvider + protected readonly Handler $contentTypeHandler, + protected readonly BoostFactorProvider $boostFactorProvider ) { - $this->contentTypeHandler = $contentTypeHandler; - $this->boostFactorProvider = $boostFactorProvider; } - public function accept(Content $content, $languageCode): bool + public function accept(Content $content, string $languageCode): bool { return true; } - public function mapFields(Content $content, $languageCode): array + public function mapFields(Content $content, string $languageCode): array { if (!isset($content->versionInfo->names[$languageCode])) { return []; diff --git a/src/lib/FieldMapper/IndexingDepthProvider.php b/src/lib/FieldMapper/IndexingDepthProvider.php index 34c164c9..6dace0ae 100644 --- a/src/lib/FieldMapper/IndexingDepthProvider.php +++ b/src/lib/FieldMapper/IndexingDepthProvider.php @@ -12,20 +12,13 @@ class IndexingDepthProvider { - private array $contentTypeMap; - - /** - * @var int - */ - private $defaultIndexingDepth; - /** - * @param int $defaultIndexingDepth + * @param array $contentTypeMap */ - public function __construct(array $contentTypeMap = [], $defaultIndexingDepth = 1) - { - $this->contentTypeMap = $contentTypeMap; - $this->defaultIndexingDepth = $defaultIndexingDepth; + public function __construct( + private array $contentTypeMap = [], + private readonly int $defaultIndexingDepth = 1 + ) { } /** @@ -33,11 +26,7 @@ public function __construct(array $contentTypeMap = [], $defaultIndexingDepth = */ public function getMaxDepthForContent(ContentType $contentType): int { - if (isset($this->contentTypeMap[$contentType->identifier])) { - return $this->contentTypeMap[$contentType->identifier]; - } - - return $this->defaultIndexingDepth; + return $this->contentTypeMap[$contentType->identifier] ?? $this->defaultIndexingDepth; } public function getMaxDepth(): int diff --git a/src/lib/FieldMapper/LocationFieldMapper/Aggregate.php b/src/lib/FieldMapper/LocationFieldMapper/Aggregate.php index 64a40a9f..a2bfc7a7 100644 --- a/src/lib/FieldMapper/LocationFieldMapper/Aggregate.php +++ b/src/lib/FieldMapper/LocationFieldMapper/Aggregate.php @@ -20,11 +20,10 @@ class Aggregate extends LocationFieldMapper * * @var \Ibexa\Contracts\Solr\FieldMapper\LocationFieldMapper[] */ - protected $mappers = []; + protected array $mappers = []; /** - * @param \Ibexa\Contracts\Solr\FieldMapper\LocationFieldMapper[] $mappers - * An array of mappers, sorted by priority. + * @param \Ibexa\Contracts\Solr\FieldMapper\LocationFieldMapper[] $mappers An array of mappers, sorted by priority. */ public function __construct(array $mappers = []) { @@ -46,9 +45,6 @@ public function accept(Location $location): bool return true; } - /** - * @return mixed[] - */ public function mapFields(Location $location): array { $fields = []; diff --git a/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php b/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php index 2682d9b1..b7b46303 100644 --- a/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php +++ b/src/lib/FieldMapper/LocationFieldMapper/LocationDocumentBaseFields.php @@ -9,7 +9,6 @@ use Ibexa\Contracts\Core\Persistence\Bookmark\Handler as BookmarkHandler; use Ibexa\Contracts\Core\Persistence\Content\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler; use Ibexa\Contracts\Core\Persistence\Content\Location; use Ibexa\Contracts\Core\Persistence\Content\Type\Handler as ContentTypeHandler; use Ibexa\Contracts\Core\Search\Field; @@ -22,20 +21,11 @@ */ class LocationDocumentBaseFields extends LocationFieldMapper { - protected Handler $contentHandler; - - protected ContentTypeHandler $contentTypeHandler; - - private BookmarkHandler $bookmarkHandler; - public function __construct( - BookmarkHandler $bookmarkHandler, - ContentHandler $contentHandler, - ContentTypeHandler $contentTypeHandler + private readonly BookmarkHandler $bookmarkHandler, + protected readonly Handler $contentHandler, + protected readonly ContentTypeHandler $contentTypeHandler ) { - $this->bookmarkHandler = $bookmarkHandler; - $this->contentHandler = $contentHandler; - $this->contentTypeHandler = $contentTypeHandler; } public function accept(Location $location): bool @@ -133,6 +123,9 @@ public function mapFields(Location $location): array ]; } + /** + * @return list + */ private function getAncestors(Location $location): array { $ancestorsIds = explode('/', trim($location->pathString, '/')); diff --git a/src/lib/Gateway.php b/src/lib/Gateway.php index ec5fc055..66b46230 100644 --- a/src/lib/Gateway.php +++ b/src/lib/Gateway.php @@ -18,29 +18,23 @@ abstract class Gateway /** * Returns search hits for the given query. * - * @param array $fieldFilters - a map of filters for the returned fields. + * @param array $fieldFilters - a map of filters for the returned fields. * Currently supported: array("languages" => array(,..)). - * - * @return mixed */ - abstract public function findContent(Query $query, array $fieldFilters = []); + abstract public function findContent(Query $query, array $fieldFilters = []): mixed; /** * Returns search hits for the given query. * - * @param array $fieldFilters - a map of filters for the returned fields. + * @param array $fieldFilters - a map of filters for the returned fields. * Currently supported: array("languages" => array(,..)). - * - * @return mixed */ - abstract public function findLocations(Query $query, array $fieldFilters = []); + abstract public function findLocations(Query $query, array $fieldFilters = []): mixed; /** * Returns all search hits for given query, that will be performed on all endpoints. - * - * @return mixed */ - abstract public function searchAllEndpoints(Query $query); + abstract public function searchAllEndpoints(Query $query): mixed; /** * Indexes an array of documents. @@ -54,15 +48,13 @@ abstract public function bulkIndexDocuments(array $documents); /** * Deletes documents by the given $query. - * - * @param string $query */ - abstract public function deleteByQuery($query); + abstract public function deleteByQuery(string $query); /** * Purges all contents from the index. */ - abstract public function purgeIndex(); + abstract public function purgeIndex(): void; /** * Commits the data to the Solr index, making it available for search. @@ -70,8 +62,6 @@ abstract public function purgeIndex(); * This will perform Solr 'soft commit', which means there is no guarantee that data * is actually written to the stable storage, it is only made available for search. * Passing true will also write the data to the safe storage, ensuring durability. - * - * @param bool $flush */ - abstract public function commit($flush = false); + abstract public function commit(bool $flush = false): void; } diff --git a/src/lib/Gateway/DistributionStrategy.php b/src/lib/Gateway/DistributionStrategy.php index 8a02df6d..71e0af96 100644 --- a/src/lib/Gateway/DistributionStrategy.php +++ b/src/lib/Gateway/DistributionStrategy.php @@ -10,5 +10,10 @@ interface DistributionStrategy { - public function getSearchParameters(array $parameters, ?array $languageSettings = null); + /** + * @param array $languageSettings + * + * @return array + */ + public function getSearchParameters(array $parameters, ?array $languageSettings = null): array; } diff --git a/src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php b/src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php index 113dac3a..72993f9c 100644 --- a/src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php +++ b/src/lib/Gateway/DistributionStrategy/AbstractDistributionStrategy.php @@ -15,17 +15,10 @@ abstract class AbstractDistributionStrategy implements DistributionStrategy { - /** - * Endpoint registry service. - */ - protected EndpointRegistry $endpointRegistry; - - protected EndpointResolver $endpointResolver; - - public function __construct(EndpointRegistry $endpointRegistry, EndpointResolver $endpointResolver) - { - $this->endpointRegistry = $endpointRegistry; - $this->endpointResolver = $endpointResolver; + public function __construct( + protected readonly EndpointRegistry $endpointRegistry, + protected readonly EndpointResolver $endpointResolver + ) { } public function getSearchParameters(array $parameters, ?array $languageSettings = null): array @@ -45,5 +38,11 @@ public function getSearchParameters(array $parameters, ?array $languageSettings return $parameters; } + /** + * @param array $parameters + * @param list $searchTargets + * + * @return array + */ abstract protected function appendSearchTargets(array $parameters, array $searchTargets): array; } diff --git a/src/lib/Gateway/DistributionStrategy/CloudDistributionStrategy.php b/src/lib/Gateway/DistributionStrategy/CloudDistributionStrategy.php index 0be31287..606fc9b8 100644 --- a/src/lib/Gateway/DistributionStrategy/CloudDistributionStrategy.php +++ b/src/lib/Gateway/DistributionStrategy/CloudDistributionStrategy.php @@ -15,14 +15,12 @@ */ final class CloudDistributionStrategy extends AbstractDistributionStrategy { - private const COLLECTION_SEPARATOR = ','; - private const COLLECTION_PARAMETER = 'collection'; + private const string COLLECTION_SEPARATOR = ','; + private const string COLLECTION_PARAMETER = 'collection'; protected function appendSearchTargets(array $parameters, array $searchTargets): array { - $collections = array_map(function (string $endpointName) { - return $this->endpointRegistry->getEndpoint($endpointName)->core; - }, $searchTargets); + $collections = array_map(fn (string $endpointName) => $this->endpointRegistry->getEndpoint($endpointName)->core, $searchTargets); $parameters[self::COLLECTION_PARAMETER] = implode(self::COLLECTION_SEPARATOR, $collections); diff --git a/src/lib/Gateway/DistributionStrategy/StandaloneDistributionStrategy.php b/src/lib/Gateway/DistributionStrategy/StandaloneDistributionStrategy.php index ed69278a..3f2748ad 100644 --- a/src/lib/Gateway/DistributionStrategy/StandaloneDistributionStrategy.php +++ b/src/lib/Gateway/DistributionStrategy/StandaloneDistributionStrategy.php @@ -15,14 +15,12 @@ */ final class StandaloneDistributionStrategy extends AbstractDistributionStrategy { - private const SHARD_SEPARATOR = ','; - private const SHARD_PARAMETER = 'shards'; + private const string SHARD_SEPARATOR = ','; + private const string SHARD_PARAMETER = 'shards'; protected function appendSearchTargets(array $parameters, array $searchTargets): array { - $shards = array_map(function (string $endpointName) { - return $this->endpointRegistry->getEndpoint($endpointName)->getIdentifier(); - }, $searchTargets); + $shards = array_map(fn (string $endpointName) => $this->endpointRegistry->getEndpoint($endpointName)->getIdentifier(), $searchTargets); $parameters[self::SHARD_PARAMETER] = implode(self::SHARD_SEPARATOR, $shards); diff --git a/src/lib/Gateway/Endpoint.php b/src/lib/Gateway/Endpoint.php index f13750e1..7ce76ca3 100644 --- a/src/lib/Gateway/Endpoint.php +++ b/src/lib/Gateway/Endpoint.php @@ -11,8 +11,8 @@ /** * @property-read string $scheme - * @property-read string $user - * @property-read string $pass + * @property-read string|null $user + * @property-read string|null $pass * @property-read string $host * @property-read int $port * @property-read string $path @@ -22,61 +22,49 @@ class Endpoint extends ValueObject { /** * Holds scheme, 'http' or 'https'. - * - * @var string */ - protected $scheme; + protected string $scheme; /** * Holds basic HTTP authentication username. - * - * @var string */ - protected $user; + protected ?string $user = null; /** * Holds basic HTTP authentication password. - * - * @var string */ - protected $pass; + protected ?string $pass = null; /** * Holds hostname. - * - * @var string */ - protected $host; + protected string $host; /** * Holds port number. - * - * @var int */ - protected $port; + protected string $port; /** * Holds path. - * - * @var string */ - protected $path; + protected string $path; /** * Holds core name. - * - * @var string */ - protected $core; + protected string $core; /** * Parse DSN settings if present, otherwise take parameters as is. + * + * @param array $properties */ public function __construct(array $properties = []) { // If dns is defined parse it to individual parts if (!empty($properties['dsn'])) { - $properties = parse_url($properties['dsn']) + $properties; + $properties = parse_url((string) $properties['dsn']) + $properties; unset($properties['dsn']); // if dns contained fragment we set that on core config, query however will result in exception. @@ -91,8 +79,6 @@ public function __construct(array $properties = []) /** * Returns Endpoint's identifier, to be used for targeting specific logical indexes. - * - * @return string */ public function getIdentifier(): string { @@ -101,8 +87,6 @@ public function getIdentifier(): string /** * Returns full HTTP URL of the Endpoint. - * - * @return string */ public function getURL(): string { diff --git a/src/lib/Gateway/EndpointRegistry.php b/src/lib/Gateway/EndpointRegistry.php index f785d60a..aa365034 100644 --- a/src/lib/Gateway/EndpointRegistry.php +++ b/src/lib/Gateway/EndpointRegistry.php @@ -19,12 +19,12 @@ class EndpointRegistry * * @var array */ - protected $endpoint = []; + protected array $endpoint = []; /** * Construct from optional array of Endpoints. * - * @param \Ibexa\Solr\Gateway\Endpoint[] $endpoints + * @param array $endpoints */ public function __construct(array $endpoints = []) { @@ -35,23 +35,16 @@ public function __construct(array $endpoints = []) /** * Registers $endpoint with $name. - * - * @param string $name - * @param \Ibexa\Solr\Gateway\Endpoint $endpoint */ - public function registerEndpoint($name, Endpoint $endpoint): void + public function registerEndpoint(string $name, Endpoint $endpoint): void { $this->endpoint[$name] = $endpoint; } /** * Get Endpoint with $name. - * - * @param string $name - * - * @return \Ibexa\Solr\Gateway\Endpoint */ - public function getEndpoint($name) + public function getEndpoint(string $name): Endpoint { if (!isset($this->endpoint[$name])) { throw new OutOfBoundsException("No endpoint registered for '{$name}'."); @@ -61,9 +54,7 @@ public function getEndpoint($name) } /** - * Get first Endpoint, for usecases where there is only one. - * - * @return \Ibexa\Solr\Gateway\Endpoint + * Gets first Endpoint, for use cases where there is only one. */ public function getFirstEndpoint(): Endpoint { diff --git a/src/lib/Gateway/EndpointResolver.php b/src/lib/Gateway/EndpointResolver.php index e13d45eb..a24f6562 100644 --- a/src/lib/Gateway/EndpointResolver.php +++ b/src/lib/Gateway/EndpointResolver.php @@ -14,38 +14,32 @@ interface EndpointResolver { /** * Returns name of the Endpoint used as entry point for distributed search. - * - * @return \Ibexa\Solr\Gateway\Endpoint */ - public function getEntryEndpoint(); + public function getEntryEndpoint(): string; /** * Returns name of the Endpoint that indexes Content translations in the given $languageCode. - * - * @param string $languageCode - * - * @return string */ - public function getIndexingTarget($languageCode); + public function getIndexingTarget(string $languageCode): string; /** * Returns name of the Endpoint used to index translations in main languages. - * - * @return string|null */ - public function getMainLanguagesEndpoint(); + public function getMainLanguagesEndpoint(): ?string; /** * Returns an array of Endpoint names for the given $languageSettings. * - * @return string[] + * @param array $languageSettings + * + * @return list */ - public function getSearchTargets(array $languageSettings); + public function getSearchTargets(array $languageSettings): array; /** * Returns names of all Endpoints. * - * @return string[] + * @return list */ - public function getEndpoints(); + public function getEndpoints(): array; } diff --git a/src/lib/Gateway/EndpointResolver/NativeEndpointResolver.php b/src/lib/Gateway/EndpointResolver/NativeEndpointResolver.php index 387f30c1..7a7fd144 100644 --- a/src/lib/Gateway/EndpointResolver/NativeEndpointResolver.php +++ b/src/lib/Gateway/EndpointResolver/NativeEndpointResolver.php @@ -7,6 +7,7 @@ namespace Ibexa\Solr\Gateway\EndpointResolver; +use Ibexa\Solr\Gateway\Endpoint; use Ibexa\Solr\Gateway\EndpointResolver; use Ibexa\Solr\Gateway\SingleEndpointResolver; use RuntimeException; @@ -16,67 +17,43 @@ */ class NativeEndpointResolver implements EndpointResolver, SingleEndpointResolver { - /** - * Holds an array of Solr entry endpoint names. - * - * @var string[] - */ - private array $entryEndpoints; - - /** - * Holds a map of translations to Endpoint names, with language code as key - * and Endpoint name as value. - * - * - * array( - * "cro-HR" => "endpoint1", - * "eng-GB" => "endpoint2", - * ); - * - * - * @var string[] - */ - private array $endpointMap; - - /** - * Holds a name of the default Endpoint used for translations, if configured. - * - * @var string|null - */ - private $defaultEndpoint; - - /** - * Holds a name of the Endpoint used to index translations in main languages, if configured. - * - * @var string|null - */ - private $mainLanguagesEndpoint; - /** * Result of hasMultipleEndpoints() once called the first time. - * - * @var bool|null */ - protected $hasMultiple = null; + protected ?bool $hasMultiple = null; /** * Create from Endpoint names. * - * @param string[] $entryEndpoints - * @param string[] $endpointMap - * @param string|null $defaultEndpoint - * @param string|null $mainLanguagesEndpoint + * @param list $entryEndpoints + * @param array $endpointMap */ public function __construct( - array $entryEndpoints = [], - array $endpointMap = [], - $defaultEndpoint = null, - $mainLanguagesEndpoint = null + /** + * Holds an array of Solr entry endpoint names. + */ + private array $entryEndpoints = [], + /** + * Holds a map of translations to Endpoint names, with language code as key + * and Endpoint name as value. + * + * + * array( + * "cro-HR" => "endpoint1", + * "eng-GB" => "endpoint2", + * ); + * + */ + private readonly array $endpointMap = [], + /** + * Holds a name of the default Endpoint used for translations, if configured. + */ + private readonly ?string $defaultEndpoint = null, + /** + * Holds a name of the Endpoint used to index translations in main languages, if configured. + */ + private readonly ?string $mainLanguagesEndpoint = null ) { - $this->entryEndpoints = $entryEndpoints; - $this->endpointMap = $endpointMap; - $this->defaultEndpoint = $defaultEndpoint; - $this->mainLanguagesEndpoint = $mainLanguagesEndpoint; } public function getEntryEndpoint(): string @@ -88,7 +65,7 @@ public function getEntryEndpoint(): string return reset($this->entryEndpoints); } - public function getIndexingTarget($languageCode) + public function getIndexingTarget(string $languageCode): string { if (isset($this->endpointMap[$languageCode])) { return $this->endpointMap[$languageCode]; @@ -101,12 +78,12 @@ public function getIndexingTarget($languageCode) throw new RuntimeException("Language '{$languageCode}' is not mapped to Solr endpoint"); } - public function getMainLanguagesEndpoint() + public function getMainLanguagesEndpoint(): ?string { return $this->mainLanguagesEndpoint; } - public function getSearchTargets(array $languageSettings) + public function getSearchTargets(array $languageSettings): array { $languages = ( empty($languageSettings['languages']) ? @@ -145,7 +122,7 @@ public function getSearchTargets(array $languageSettings) return array_keys($targetSet); } - public function getEndpoints() + public function getEndpoints(): array { $endpointSet = array_flip($this->endpointMap); @@ -164,12 +141,7 @@ public function getEndpoints() return array_keys($endpointSet); } - /** - * Returns true if current configurations has several endpoints. - * - * @return bool - */ - public function hasMultipleEndpoints() + public function hasMultipleEndpoints(): bool { if ($this->hasMultiple !== null) { return $this->hasMultiple; diff --git a/src/lib/Gateway/GatewayRegistry.php b/src/lib/Gateway/GatewayRegistry.php index 2b163fab..2cc6b2b1 100644 --- a/src/lib/Gateway/GatewayRegistry.php +++ b/src/lib/Gateway/GatewayRegistry.php @@ -15,19 +15,16 @@ */ final class GatewayRegistry { - /** @var \Ibexa\Solr\Gateway[] */ - private array $gateways; - /** - * @param \Ibexa\Solr\Gateway[] $gateways + * @param array $gateways */ - public function __construct(array $gateways = []) - { - $this->gateways = $gateways; + public function __construct( + private array $gateways = [] + ) { } /** - * @return \Ibexa\Solr\Gateway[] + * @return array */ public function getGateways(): array { @@ -35,7 +32,7 @@ public function getGateways(): array } /** - * @param \Ibexa\Solr\Gateway[] $gateways + * @param array $gateways */ public function setGateways(array $gateways): void { diff --git a/src/lib/Gateway/HttpClient.php b/src/lib/Gateway/HttpClient.php index bbbbf398..18541de1 100644 --- a/src/lib/Gateway/HttpClient.php +++ b/src/lib/Gateway/HttpClient.php @@ -16,13 +16,6 @@ interface HttpClient * Execute a HTTP request to the remote server. * * Returns the result from the remote server. - * - * @param string $method - * @param \Ibexa\Solr\Gateway\Endpoint $endpoint - * @param string $path - * @param \Ibexa\Solr\Gateway\Message $message - * - * @return \Ibexa\Solr\Gateway\Message */ - public function request($method, Endpoint $endpoint, $path, Message $message = null); + public function request(string $method, Endpoint $endpoint, string $path, ?Message $message = null): Message; } diff --git a/src/lib/Gateway/HttpClient/Stream.php b/src/lib/Gateway/HttpClient/Stream.php index e6ed0275..55a5f7cf 100644 --- a/src/lib/Gateway/HttpClient/Stream.php +++ b/src/lib/Gateway/HttpClient/Stream.php @@ -25,33 +25,19 @@ class Stream implements HttpClient, LoggerAwareInterface { use LoggerAwareTrait; - private int $connectionTimeout; - - private HttpClientInterface $client; - /** * @param int $timeout Timeout for connection in seconds. */ - public function __construct(HttpClientInterface $client, int $timeout = 10) - { - $this->client = $client; - $this->connectionTimeout = $timeout; + public function __construct( + private readonly HttpClientInterface $client, + private readonly int $timeout = 10 + ) { $this->setLogger(new NullLogger()); } - /** - * Execute an HTTP request to the remote server. - * - * Returns the result from the remote server. - * - * @param string $method - * @param string $path - * - * @return \Ibexa\Solr\Gateway\Message - */ - public function request($method, Endpoint $endpoint, $path, Message $message = null): Message + public function request(string $method, Endpoint $endpoint, string $path, ?Message $message = null): Message { - $message = $message ?? new Message(); + $message ??= new Message(); try { return $this->getResponseMessage( @@ -86,7 +72,7 @@ private function getResponseMessage( $endpoint->getURL() . $path, [ 'headers' => $message->headers, - 'timeout' => $this->connectionTimeout, + 'timeout' => $this->timeout, 'body' => $message->body, ] ); diff --git a/src/lib/Gateway/Message.php b/src/lib/Gateway/Message.php index 7a74090c..fe546ae2 100644 --- a/src/lib/Gateway/Message.php +++ b/src/lib/Gateway/Message.php @@ -13,22 +13,11 @@ class Message { /** - * Request/Response headers. - * - * @var array + * @param array|string> $headers */ - public $headers; - - /** - * Request/Response body. - * - * @var string - */ - public $body; - - public function __construct(array $headers = [], string $body = '') - { - $this->headers = $headers; - $this->body = $body; + public function __construct( + public array $headers = [], + public string $body = '' + ) { } } diff --git a/src/lib/Gateway/Native.php b/src/lib/Gateway/Native.php index da54f3be..72059433 100644 --- a/src/lib/Gateway/Native.php +++ b/src/lib/Gateway/Native.php @@ -21,76 +21,25 @@ */ class Native extends Gateway { - /** - * HTTP client to communicate with Solr server. - */ - protected HttpClient $client; - - protected EndpointResolver $endpointResolver; - - /** - * Endpoint registry service. - */ - protected EndpointRegistry $endpointRegistry; - - /** - * Content Query converter. - */ - protected QueryConverter $contentQueryConverter; - - /** - * Location Query converter. - */ - protected QueryConverter $locationQueryConverter; - - protected UpdateSerializerInterface $updateSerializer; - - protected DistributionStrategy $distributionStrategy; - public function __construct( - HttpClient $client, - EndpointResolver $endpointResolver, - EndpointRegistry $endpointRegistry, - QueryConverter $contentQueryConverter, - QueryConverter $locationQueryConverter, - UpdateSerializerInterface $updateSerializer, - DistributionStrategy $distributionStrategy + protected readonly HttpClient $client, + protected readonly EndpointResolver $endpointResolver, + protected readonly EndpointRegistry $endpointRegistry, + protected readonly QueryConverter $contentQueryConverter, + protected readonly QueryConverter $locationQueryConverter, + protected readonly UpdateSerializerInterface $updateSerializer, + protected readonly DistributionStrategy $distributionStrategy ) { - $this->client = $client; - $this->endpointResolver = $endpointResolver; - $this->endpointRegistry = $endpointRegistry; - $this->contentQueryConverter = $contentQueryConverter; - $this->locationQueryConverter = $locationQueryConverter; - $this->updateSerializer = $updateSerializer; - $this->distributionStrategy = $distributionStrategy; } - /** - * Returns search hits for the given query. - * - * @phpstan-param array{languages: string[]} $languageSettings - * - * @param array $languageSettings - a map of filters for the returned fields. - * Currently supported: array("languages" => array(,..)). - * - * @return mixed - */ - public function findContent(Query $query, array $languageSettings = []) + public function findContent(Query $query, array $languageSettings = []): mixed { $parameters = $this->contentQueryConverter->convert($query, $languageSettings); return $this->internalFind($parameters, $languageSettings); } - /** - * Returns search hits for the given query. - * - * @param array $languageSettings - a map of filters for the returned fields. - * Currently supported: array("languages" => array(,..)). - * - * @return mixed - */ - public function findLocations(Query $query, array $languageSettings = []) + public function findLocations(Query $query, array $languageSettings = []): mixed { $parameters = $this->locationQueryConverter->convert($query); @@ -100,19 +49,17 @@ public function findLocations(Query $query, array $languageSettings = []) /** * Returns search hits for the given array of Solr query parameters. * - * @param array $languageSettings - a map of filters for the returned fields. + * @param array $languageSettings - a map of filters for the returned fields. * Currently supported: array("languages" => array(,..)). - * - * @return mixed */ - protected function internalFind(array $parameters, array $languageSettings = []) + protected function internalFind(array $parameters, array $languageSettings = []): mixed { $parameters = $this->distributionStrategy->getSearchParameters($parameters, $languageSettings); return $this->search($parameters); } - public function searchAllEndpoints(Query $query) + public function searchAllEndpoints(Query $query): mixed { $parameters = $this->contentQueryConverter->convert($query); $parameters = $this->distributionStrategy->getSearchParameters($parameters); @@ -125,6 +72,8 @@ public function searchAllEndpoints(Query $query) * * Array markers, possibly added for the facet parameters, * will be removed from the result. + * + * @param array $parameters */ protected function generateQueryString(array $parameters): string { @@ -142,9 +91,7 @@ protected function generateQueryString(array $parameters): string * * Only return endpoints if there are more then one configured, as this is meant for use on shard parameter. * - * @param array $languageSettings - * - * @return string + * @param array $languageSettings */ protected function getSearchTargets(array $languageSettings): string { @@ -168,8 +115,6 @@ protected function getSearchTargets(array $languageSettings): string * Returns all search targets without language constraint. * * Only return endpoints if there are more then one configured, as this is meant for use on shard parameter. - * - * @return string */ protected function getAllSearchTargets(): string { @@ -199,7 +144,7 @@ protected function getAllSearchTargets(): string * - On large amounts of data make sure to iterate with several calls to this function with a limited * set of documents, amount you have memory for depends on server, size of documents, & PHP version. * - * @param \Ibexa\Contracts\Core\Search\Document[][] $documents + * @param array> $documents */ public function bulkIndexDocuments(array $documents): void { @@ -238,10 +183,8 @@ public function bulkIndexDocuments(array $documents): void /** * Returns version of the $document to be indexed in the always available core. - * - * @return \Ibexa\Contracts\Core\Search\Document */ - protected function getMainTranslationDocument(Document $document) + protected function getMainTranslationDocument(Document $document): Document { // Clone to prevent mutation $document = clone $document; @@ -274,10 +217,9 @@ protected function getMainTranslationDocument(Document $document) } /** - * @param \Ibexa\Solr\Gateway\Endpoint $endpoint * @param \Ibexa\Contracts\Core\Search\Document[] $documents */ - protected function doBulkIndexDocuments(Endpoint $endpoint, array $documents) + protected function doBulkIndexDocuments(Endpoint $endpoint, array $documents): void { $updates = $this->updateSerializer->serialize($documents); $result = $this->client->request( @@ -292,17 +234,18 @@ protected function doBulkIndexDocuments(Endpoint $endpoint, array $documents) ) ); - if ($result->headers['status'] !== 200) { - throw new RuntimeException('Wrong HTTP status received from Solr: ' . $result->headers['status'] . ' on ' . $endpoint->getURL() . "\n" . var_export($endpoint, true) . "\n" . var_export($result, true) . "\n" . var_export($updates, true)); + if ((int)$result->headers['status'] !== 200) { + throw new RuntimeException('Wrong HTTP status received from Solr: ' + . (string)$result->headers['status'] . ' on ' . $endpoint->getURL() + . "\n" . var_export($endpoint, true) . "\n" . var_export($result, true) + . "\n" . var_export($updates, true)); } } /** * Deletes documents by the given $query. - * - * @param string $query */ - public function deleteByQuery($query): void + public function deleteByQuery(string $query): void { $endpoints = $this->endpointResolver->getEndpoints(); @@ -338,11 +281,9 @@ public function purgeIndex(): void } /** - * @param $endpoint - * * @todo error handling */ - protected function purgeEndpoint(Endpoint $endpoint) + protected function purgeEndpoint(Endpoint $endpoint): void { $this->client->request( 'POST', @@ -363,10 +304,8 @@ protected function purgeEndpoint(Endpoint $endpoint) * This will perform Solr 'soft commit', which means there is no guarantee that data * is actually written to the stable storage, it is only made available for search. * Passing true will also write the data to the safe storage, ensuring durability. - * - * @param bool $flush */ - public function commit($flush = false): void + public function commit(bool $flush = false): void { $payload = $flush ? '' : @@ -385,18 +324,20 @@ public function commit($flush = false): void ) ); - if ($result->headers['status'] !== 200) { - throw new RuntimeException('Wrong HTTP status received from Solr: ' . $result->headers['status'] . var_export($result, true)); + if ((int)$result->headers['status'] !== 200) { + throw new RuntimeException( + 'Wrong HTTP status received from Solr: ' + . (string)$result->headers['status'] + . var_export($result, true) + ); } } } /** * Perform request to client to search for records with query string. - * - * @return mixed */ - protected function search(array $parameters) + protected function search(array $parameters): mixed { $queryString = $this->generateQueryString($parameters); diff --git a/src/lib/Gateway/SingleEndpointResolver.php b/src/lib/Gateway/SingleEndpointResolver.php index 0c013d70..36da4cb2 100644 --- a/src/lib/Gateway/SingleEndpointResolver.php +++ b/src/lib/Gateway/SingleEndpointResolver.php @@ -14,8 +14,6 @@ interface SingleEndpointResolver { /** * Returns true if current configurations has several endpoints. - * - * @return bool */ - public function hasMultipleEndpoints(); + public function hasMultipleEndpoints(): bool; } diff --git a/src/lib/Gateway/UpdateSerializer/JsonUpdateSerializer.php b/src/lib/Gateway/UpdateSerializer/JsonUpdateSerializer.php index 062d3246..d67bfd95 100644 --- a/src/lib/Gateway/UpdateSerializer/JsonUpdateSerializer.php +++ b/src/lib/Gateway/UpdateSerializer/JsonUpdateSerializer.php @@ -35,6 +35,9 @@ public function serialize(array $documents): string return json_encode($data, JSON_THROW_ON_ERROR); } + /** + * @return array> + */ private function mapDocumentToData(Document $document): array { $data['id'] = $this->fieldValueMapper->map( @@ -58,12 +61,7 @@ public function getSupportedFormat(): string return 'json'; } - /** - * @param mixed|null $value - * - * @return mixed - */ - private function buildValue($value, string $fieldName, array $data) + private function buildValue(mixed $value, string $fieldName, array $data): mixed { return !array_key_exists($fieldName, $data) || !is_array($data[$fieldName]) ? $value diff --git a/src/lib/Gateway/UpdateSerializer/UpdateSerializer.php b/src/lib/Gateway/UpdateSerializer/UpdateSerializer.php index 82b82988..83a46f8c 100644 --- a/src/lib/Gateway/UpdateSerializer/UpdateSerializer.php +++ b/src/lib/Gateway/UpdateSerializer/UpdateSerializer.php @@ -19,16 +19,10 @@ */ abstract class UpdateSerializer { - protected FieldValueMapper $fieldValueMapper; - - protected FieldNameGenerator $nameGenerator; - public function __construct( - FieldValueMapper $fieldValueMapper, - FieldNameGenerator $nameGenerator + protected readonly FieldValueMapper $fieldValueMapper, + protected readonly FieldNameGenerator $nameGenerator ) { - $this->fieldValueMapper = $fieldValueMapper; - $this->nameGenerator = $nameGenerator; } /** diff --git a/src/lib/Gateway/UpdateSerializer/XmlUpdateSerializer.php b/src/lib/Gateway/UpdateSerializer/XmlUpdateSerializer.php index 6185842c..5e97a7d7 100644 --- a/src/lib/Gateway/UpdateSerializer/XmlUpdateSerializer.php +++ b/src/lib/Gateway/UpdateSerializer/XmlUpdateSerializer.php @@ -15,10 +15,8 @@ /** * @internal - * - * @final */ -class XmlUpdateSerializer extends UpdateSerializer implements UpdateSerializerInterface +final class XmlUpdateSerializer extends UpdateSerializer implements UpdateSerializerInterface { public function serialize(array $documents): string { diff --git a/src/lib/Gateway/UpdateSerializerFactory.php b/src/lib/Gateway/UpdateSerializerFactory.php index 864cd23e..8ccb8e67 100644 --- a/src/lib/Gateway/UpdateSerializerFactory.php +++ b/src/lib/Gateway/UpdateSerializerFactory.php @@ -12,15 +12,12 @@ class UpdateSerializerFactory { - /** @var \Ibexa\Solr\Gateway\UpdateSerializerInterface[]|iterable */ - private iterable $serializers; - /** * @param iterable<\Ibexa\Solr\Gateway\UpdateSerializerInterface> $serializers */ - public function __construct(iterable $serializers) - { - $this->serializers = $serializers; + public function __construct( + private readonly iterable $serializers + ) { } /** diff --git a/src/lib/Handler.php b/src/lib/Handler.php index 3f35781b..0efd240b 100644 --- a/src/lib/Handler.php +++ b/src/lib/Handler.php @@ -45,63 +45,22 @@ class Handler implements VersatileHandler { /* Solr's maxBooleanClauses config value is 1024 */ - public const SOLR_BULK_REMOVE_LIMIT = 1000; + public const int SOLR_BULK_REMOVE_LIMIT = 1000; /* 16b max unsigned integer value due to Solr (JVM) limitations */ - public const SOLR_MAX_QUERY_LIMIT = 65535; - public const DEFAULT_QUERY_LIMIT = 1000; - - /** - * Content locator gateway. - */ - protected Gateway $gateway; - - /** - * Content handler. - */ - protected ContentHandler $contentHandler; - - /** - * Document mapper. - */ - protected DocumentMapper $mapper; - - /** - * Content result extractor. - */ - protected ResultExtractor $contentResultExtractor; - - /** - * Location result extractor. - */ - protected ResultExtractor $locationResultExtractor; - - /** - * Core filter service. - */ - protected CoreFilter $coreFilter; + public const int SOLR_MAX_QUERY_LIMIT = 65535; + public const int DEFAULT_QUERY_LIMIT = 1000; /** * Creates a new content handler. - * - * @param \Ibexa\Solr\Gateway $gateway - * @param \Ibexa\Contracts\Solr\DocumentMapper $mapper - * @param \Ibexa\Solr\ResultExtractor $resultExtractor - * @param \Ibexa\Solr\CoreFilter $coreFilter */ public function __construct( - Gateway $gateway, - ContentHandler $contentHandler, - DocumentMapper $mapper, - ResultExtractor $contentResultExtractor, - ResultExtractor $locationResultExtractor, - CoreFilter $coreFilter + protected Gateway $gateway, + protected ContentHandler $contentHandler, + protected DocumentMapper $mapper, + protected ResultExtractor $contentResultExtractor, + protected ResultExtractor $locationResultExtractor, + protected CoreFilter $coreFilter ) { - $this->gateway = $gateway; - $this->contentHandler = $contentHandler; - $this->mapper = $mapper; - $this->contentResultExtractor = $contentResultExtractor; - $this->locationResultExtractor = $locationResultExtractor; - $this->coreFilter = $coreFilter; } public function findContent(Query $query, array $languageFilter = []): SearchResult @@ -180,10 +139,8 @@ public function findLocations(LocationQuery $query, array $languageFilter = []): * * @param string $prefix * @param string[] $fieldPaths - * @param int $limit - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $filter */ - public function suggest($prefix, $fieldPaths = [], $limit = 10, Criterion $filter = null) + public function suggest($prefix, $fieldPaths = [], $limit = 10, Criterion $filter = null): never { throw new \Exception('@todo: Not implemented yet.'); } @@ -220,7 +177,7 @@ public function bulkIndexContent(array $contentObjects): void foreach ($contentObjects as $content) { try { $documents[] = $this->mapper->mapContentBlock($content); - } catch (NotFoundException $ex) { + } catch (NotFoundException) { // ignore content objects without assigned state id } } @@ -247,7 +204,7 @@ public function indexLocation(Location $location): void */ public function deleteContent($contentId, $versionId = null): void { - $idPrefix = $this->mapper->generateContentDocumentId($contentId); + $idPrefix = $this->mapper->generateContentDocumentId((int)$contentId); $this->gateway->deleteByQuery("_root_:{$idPrefix}*"); } @@ -260,8 +217,8 @@ public function deleteContent($contentId, $versionId = null): void */ public function deleteLocation($locationId, $contentId): void { - $this->deleteAllItemsWithoutAdditionalLocation($locationId); - $this->updateAllElementsWithAdditionalLocation($locationId); + $this->deleteAllItemsWithoutAdditionalLocation((int)$locationId); + $this->updateAllElementsWithAdditionalLocation((int)$locationId); } /** @@ -280,18 +237,13 @@ public function purgeIndex(): void * Passing true will also write the data to the safe storage, ensuring durability. * * @see bulkIndexContent() For info on why this is not on an SPI Interface yet. - * - * @param bool $flush */ - public function commit($flush = false): void + public function commit(bool $flush = false): void { $this->gateway->commit($flush); } - /** - * @param $locationId - */ - protected function deleteAllItemsWithoutAdditionalLocation($locationId) + protected function deleteAllItemsWithoutAdditionalLocation(int $locationId): void { $query = $this->prepareQuery(self::SOLR_MAX_QUERY_LIMIT); $query->filter = new Criterion\LogicalAnd( @@ -308,7 +260,7 @@ protected function deleteAllItemsWithoutAdditionalLocation($locationId) $contentDocumentIds = []; foreach ($searchResult->searchHits as $hit) { - $contentDocumentIds[] = $this->mapper->generateContentDocumentId($hit->valueObject->id) . '*'; + $contentDocumentIds[] = $this->mapper->generateContentDocumentId((int)$hit->valueObject->id) . '*'; } foreach (array_chunk(array_unique($contentDocumentIds), self::SOLR_BULK_REMOVE_LIMIT) as $ids) { @@ -317,10 +269,7 @@ protected function deleteAllItemsWithoutAdditionalLocation($locationId) } } - /** - * @param $locationId - */ - protected function updateAllElementsWithAdditionalLocation($locationId) + protected function updateAllElementsWithAdditionalLocation(int $locationId): void { $query = $this->prepareQuery(self::SOLR_MAX_QUERY_LIMIT); $query->filter = new Criterion\LogicalAnd( @@ -338,7 +287,7 @@ protected function updateAllElementsWithAdditionalLocation($locationId) foreach ($searchResult->searchHits as $searchHit) { try { $contentInfo = $this->contentHandler->loadContentInfo($searchHit->valueObject->id); - } catch (NotFoundException $e) { + } catch (NotFoundException) { continue; } @@ -350,12 +299,8 @@ protected function updateAllElementsWithAdditionalLocation($locationId) /** * Prepare standard query for delete purpose. - * - * @param int $limit - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Query */ - protected function prepareQuery($limit = self::DEFAULT_QUERY_LIMIT): Query + protected function prepareQuery(int $limit = self::DEFAULT_QUERY_LIMIT): Query { return new Query( [ @@ -366,12 +311,7 @@ protected function prepareQuery($limit = self::DEFAULT_QUERY_LIMIT): Query ); } - /** - * @param int $locationId - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\CustomField - */ - protected function allItemsWithinLocation($locationId): CustomField + protected function allItemsWithinLocation(int $locationId): CustomField { return new CustomField( 'location_path_string_mid', @@ -382,8 +322,6 @@ protected function allItemsWithinLocation($locationId): CustomField /** * @param int $locationId - * - * @return \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\CustomField */ protected function allItemsWithinLocationWithAdditionalLocation($locationId): CustomField { @@ -397,9 +335,9 @@ protected function allItemsWithinLocationWithAdditionalLocation($locationId): Cu /** * Generate search document for Content object to be indexed by a search engine. * - * @return \Ibexa\Contracts\Core\Search\Document + * @return list<\Ibexa\Contracts\Core\Search\Document> */ - public function generateDocument(Content $content) + public function generateDocument(Content $content): array { return $this->mapper->mapContentBlock($content); } @@ -412,7 +350,7 @@ public function generateDocument(Content $content) * - On large amounts of data make sure to iterate with several calls to this function with a limited * set of content objects, amount you have memory for depends on server, size of objects, & PHP version. * - * @param \Ibexa\Contracts\Core\Search\Document[] $documents + * @param \Ibexa\Contracts\Core\Search\Document[][] $documents */ public function bulkIndexDocuments(array $documents): void { @@ -421,16 +359,10 @@ public function bulkIndexDocuments(array $documents): void public function supports(int $capabilityFlag): bool { - switch ($capabilityFlag) { - case SearchService::CAPABILITY_SCORING: - case SearchService::CAPABILITY_CUSTOM_FIELDS: - case SearchService::CAPABILITY_SPELLCHECK: - case SearchService::CAPABILITY_ADVANCED_FULLTEXT: - case SearchService::CAPABILITY_AGGREGATIONS: - return true; - default: - return false; - } + return match ($capabilityFlag) { + SearchService::CAPABILITY_SCORING, SearchService::CAPABILITY_CUSTOM_FIELDS, SearchService::CAPABILITY_SPELLCHECK, SearchService::CAPABILITY_ADVANCED_FULLTEXT, SearchService::CAPABILITY_AGGREGATIONS => true, + default => false, + }; } /** diff --git a/src/lib/Indexer.php b/src/lib/Indexer.php index c617958d..3129c29b 100644 --- a/src/lib/Indexer.php +++ b/src/lib/Indexer.php @@ -31,7 +31,7 @@ public function __construct( parent::__construct($logger, $persistenceHandler, $connection, $searchHandler); } - public function getName() + public function getName(): string { return 'Ibexa Solr Search Engine'; } @@ -41,6 +41,9 @@ public function purge(): void $this->searchHandler->purgeIndex(); } + /** + * @param bool $commit + */ public function updateSearchIndex(array $contentIds, $commit): void { $documents = []; @@ -54,7 +57,7 @@ public function updateSearchIndex(array $contentIds, $commit): void } else { $this->searchHandler->deleteContent($contentId); } - } catch (NotFoundException $e) { + } catch (NotFoundException) { $this->searchHandler->deleteContent($contentId); } catch (Exception $e) { $context = [ diff --git a/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/ContentFieldAggregationFieldResolver.php b/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/ContentFieldAggregationFieldResolver.php index 4800e730..5c3aaefe 100644 --- a/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/ContentFieldAggregationFieldResolver.php +++ b/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/ContentFieldAggregationFieldResolver.php @@ -14,22 +14,18 @@ use Ibexa\Core\Search\Common\FieldNameResolver; use RuntimeException; -final class ContentFieldAggregationFieldResolver implements AggregationFieldResolver +final readonly class ContentFieldAggregationFieldResolver implements AggregationFieldResolver { - private FieldNameResolver $fieldNameResolver; - - private string $searchFieldName; - - public function __construct(FieldNameResolver $fieldNameResolver, string $searchFieldName) - { - $this->fieldNameResolver = $fieldNameResolver; - $this->searchFieldName = $searchFieldName; + public function __construct( + private FieldNameResolver $fieldNameResolver, + private string $searchFieldName + ) { } public function resolveTargetField(Aggregation $aggregation): string { if (!($aggregation instanceof FieldAggregation)) { - throw new RuntimeException('Expected instance of ' . FieldAggregation::class . ' , got ' . get_class($aggregation)); + throw new RuntimeException('Expected instance of ' . FieldAggregation::class . ' , got ' . $aggregation::class); } $searchFieldName = $this->fieldNameResolver->getAggregationFieldName( diff --git a/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/SearchFieldAggregationFieldResolver.php b/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/SearchFieldAggregationFieldResolver.php index 73d25548..0bb04a9c 100644 --- a/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/SearchFieldAggregationFieldResolver.php +++ b/src/lib/Query/Common/AggregationVisitor/AggregationFieldResolver/SearchFieldAggregationFieldResolver.php @@ -11,13 +11,11 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\Query\Common\AggregationVisitor\AggregationFieldResolver; -final class SearchFieldAggregationFieldResolver implements AggregationFieldResolver +final readonly class SearchFieldAggregationFieldResolver implements AggregationFieldResolver { - private string $searchIndexFieldName; - - public function __construct(string $searchIndexFieldName) - { - $this->searchIndexFieldName = $searchIndexFieldName; + public function __construct( + private string $searchIndexFieldName + ) { } public function resolveTargetField(Aggregation $aggregation): string diff --git a/src/lib/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitor.php b/src/lib/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitor.php index 88cd9758..06e053de 100644 --- a/src/lib/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitor.php +++ b/src/lib/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitor.php @@ -28,13 +28,10 @@ public function canVisit(Aggregation $aggregation, array $languageFilter): bool */ protected function getTargetField(AbstractRangeAggregation $aggregation): string { - switch ($aggregation->getType()) { - case DateMetadataRangeAggregation::PUBLISHED: - return 'content_publication_date_dt'; - case DateMetadataRangeAggregation::MODIFIED: - return 'content_modification_date_dt'; - default: - throw new RuntimeException("Unsupported DateMetadataRangeAggregation type {$aggregation->getType()}"); - } + return match ($aggregation->getType()) { + DateMetadataRangeAggregation::PUBLISHED => 'content_publication_date_dt', + DateMetadataRangeAggregation::MODIFIED => 'content_modification_date_dt', + default => throw new RuntimeException("Unsupported DateMetadataRangeAggregation type {$aggregation->getType()}"), + }; } } diff --git a/src/lib/Query/Common/AggregationVisitor/DispatcherAggregationVisitor.php b/src/lib/Query/Common/AggregationVisitor/DispatcherAggregationVisitor.php index 2342d489..484e3292 100644 --- a/src/lib/Query/Common/AggregationVisitor/DispatcherAggregationVisitor.php +++ b/src/lib/Query/Common/AggregationVisitor/DispatcherAggregationVisitor.php @@ -12,17 +12,14 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\Query\AggregationVisitor; -final class DispatcherAggregationVisitor implements AggregationVisitor +final readonly class DispatcherAggregationVisitor implements AggregationVisitor { - /** @var iterable<\Ibexa\Contracts\Solr\Query\AggregationVisitor> */ - private iterable $visitors; - /** * @param iterable<\Ibexa\Contracts\Solr\Query\AggregationVisitor> $visitors */ - public function __construct(iterable $visitors) - { - $this->visitors = $visitors; + public function __construct( + private iterable $visitors + ) { } public function canVisit(Aggregation $aggregation, array $languageFilter): bool @@ -39,7 +36,7 @@ public function visit( if ($visitor === null) { throw new NotImplementedException( - 'No visitor available for: ' . get_class($aggregation) + 'No visitor available for: ' . $aggregation::class ); } @@ -47,7 +44,7 @@ public function visit( } /** - * @param array{languages: string[]} $languageFilter + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter */ private function findVisitor(Aggregation $aggregation, array $languageFilter): ?AggregationVisitor { diff --git a/src/lib/Query/Common/AggregationVisitor/Factory/ContentFieldAggregationVisitorFactory.php b/src/lib/Query/Common/AggregationVisitor/Factory/ContentFieldAggregationVisitorFactory.php index 0c4ec668..cd7d3d8e 100644 --- a/src/lib/Query/Common/AggregationVisitor/Factory/ContentFieldAggregationVisitorFactory.php +++ b/src/lib/Query/Common/AggregationVisitor/Factory/ContentFieldAggregationVisitorFactory.php @@ -15,13 +15,11 @@ use Ibexa\Solr\Query\Common\AggregationVisitor\StatsAggregationVisitor; use Ibexa\Solr\Query\Common\AggregationVisitor\TermAggregationVisitor; -final class ContentFieldAggregationVisitorFactory +final readonly class ContentFieldAggregationVisitorFactory { - private FieldNameResolver $fieldNameResolver; - - public function __construct(FieldNameResolver $fieldNameResolver) - { - $this->fieldNameResolver = $fieldNameResolver; + public function __construct( + private FieldNameResolver $fieldNameResolver + ) { } public function createRangeAggregationVisitor( diff --git a/src/lib/Query/Common/AggregationVisitor/RangeAggregationVisitor.php b/src/lib/Query/Common/AggregationVisitor/RangeAggregationVisitor.php index 0b4189ca..92fda6fb 100644 --- a/src/lib/Query/Common/AggregationVisitor/RangeAggregationVisitor.php +++ b/src/lib/Query/Common/AggregationVisitor/RangeAggregationVisitor.php @@ -19,14 +19,10 @@ */ final class RangeAggregationVisitor extends AbstractRangeAggregationVisitor { - private string $aggregationClass; - - private AggregationFieldResolver $aggregationFieldResolver; - - public function __construct(string $aggregationClass, AggregationFieldResolver $aggregationFieldResolver) - { - $this->aggregationClass = $aggregationClass; - $this->aggregationFieldResolver = $aggregationFieldResolver; + public function __construct( + private readonly string $aggregationClass, + private readonly AggregationFieldResolver $aggregationFieldResolver + ) { } /** diff --git a/src/lib/Query/Common/AggregationVisitor/StatsAggregationVisitor.php b/src/lib/Query/Common/AggregationVisitor/StatsAggregationVisitor.php index f75b414f..e2faaa3c 100644 --- a/src/lib/Query/Common/AggregationVisitor/StatsAggregationVisitor.php +++ b/src/lib/Query/Common/AggregationVisitor/StatsAggregationVisitor.php @@ -14,14 +14,10 @@ final class StatsAggregationVisitor extends AbstractStatsAggregationVisitor { - private string $aggregationClass; - - private AggregationFieldResolver $aggregationFieldResolver; - - public function __construct(string $aggregationClass, AggregationFieldResolver $aggregationFieldResolver) - { - $this->aggregationClass = $aggregationClass; - $this->aggregationFieldResolver = $aggregationFieldResolver; + public function __construct( + private readonly string $aggregationClass, + private readonly AggregationFieldResolver $aggregationFieldResolver + ) { } public function canVisit(Aggregation $aggregation, array $languageFilter): bool diff --git a/src/lib/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitor.php b/src/lib/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitor.php index 47e6156a..a2148e18 100644 --- a/src/lib/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitor.php +++ b/src/lib/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitor.php @@ -12,16 +12,12 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Location\SubtreeTermAggregation; use Ibexa\Contracts\Solr\Query\AggregationVisitor; -final class SubtreeTermAggregationVisitor implements AggregationVisitor +final readonly class SubtreeTermAggregationVisitor implements AggregationVisitor { - private string $pathStringFieldName; - - private string $locationIdFieldName; - - public function __construct(string $pathStringFieldName, string $locationIdFieldName) - { - $this->pathStringFieldName = $pathStringFieldName; - $this->locationIdFieldName = $locationIdFieldName; + public function __construct( + private string $pathStringFieldName, + private string $locationIdFieldName + ) { } public function canVisit(Aggregation $aggregation, array $languageFilter): bool diff --git a/src/lib/Query/Common/AggregationVisitor/TermAggregationVisitor.php b/src/lib/Query/Common/AggregationVisitor/TermAggregationVisitor.php index 023242c5..8c216c2f 100644 --- a/src/lib/Query/Common/AggregationVisitor/TermAggregationVisitor.php +++ b/src/lib/Query/Common/AggregationVisitor/TermAggregationVisitor.php @@ -14,14 +14,10 @@ final class TermAggregationVisitor extends AbstractTermAggregationVisitor { - private string $aggregationClass; - - private AggregationFieldResolver $aggregationFieldResolver; - - public function __construct(string $aggregationClass, AggregationFieldResolver $aggregationFieldResolver) - { - $this->aggregationClass = $aggregationClass; - $this->aggregationFieldResolver = $aggregationFieldResolver; + public function __construct( + private readonly string $aggregationClass, + private readonly AggregationFieldResolver $aggregationFieldResolver + ) { } public function canVisit(Aggregation $aggregation, array $languageFilter): bool diff --git a/src/lib/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitor.php b/src/lib/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitor.php index 9003c272..1c89e05e 100644 --- a/src/lib/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitor.php +++ b/src/lib/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitor.php @@ -25,18 +25,14 @@ public function canVisit(Aggregation $aggregation, array $languageFilter): bool */ protected function getTargetField(AbstractTermAggregation $aggregation): string { - switch ($aggregation->getType()) { - case UserMetadataTermAggregation::OWNER: - return 'content_owner_user_id_id'; - case UserMetadataTermAggregation::GROUP: - return 'content_owner_user_group_ids_mid'; - case UserMetadataTermAggregation::MODIFIER: - return 'content_version_creator_user_id_id'; - default: - throw new InvalidArgumentException( - '$type', - 'Unsupported UserMetadataTermAggregation type: ' . $aggregation->getType() - ); - } + return match ($aggregation->getType()) { + UserMetadataTermAggregation::OWNER => 'content_owner_user_id_id', + UserMetadataTermAggregation::GROUP => 'content_owner_user_group_ids_mid', + UserMetadataTermAggregation::MODIFIER => 'content_version_creator_user_id_id', + default => throw new InvalidArgumentException( + '$type', + 'Unsupported UserMetadataTermAggregation type: ' . $aggregation->getType() + ), + }; } } diff --git a/src/lib/Query/Common/CriterionVisitor/Aggregate.php b/src/lib/Query/Common/CriterionVisitor/Aggregate.php index d1441f12..5f64b326 100644 --- a/src/lib/Query/Common/CriterionVisitor/Aggregate.php +++ b/src/lib/Query/Common/CriterionVisitor/Aggregate.php @@ -22,7 +22,7 @@ class Aggregate extends CriterionVisitor * * @var \Ibexa\Contracts\Solr\Query\CriterionVisitor[] */ - protected $visitors = []; + protected array $visitors = []; /** * Construct from optional visitor array. @@ -46,8 +46,6 @@ public function addVisitor(CriterionVisitor $visitor): void /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -58,12 +56,8 @@ public function canVisit(CriterionInterface $criterion): bool * Map field value to a proper Solr representation. * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException - * - * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor - * - * @return string */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null) + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { foreach ($this->visitors as $visitor) { if ($visitor->canVisit($criterion)) { @@ -71,6 +65,6 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito } } - throw new NotImplementedException('No visitor available for: ' . \get_class($criterion)); + throw new NotImplementedException('No visitor available for: ' . $criterion::class); } } diff --git a/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php b/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php index f79f8acb..1ce4a0b3 100644 --- a/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php +++ b/src/lib/Query/Common/CriterionVisitor/BaseIsContainer.php @@ -28,7 +28,7 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsContainer $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $value = $criterion->value; diff --git a/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php b/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php index c9d207c1..22f4fd84 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentIdIn.php @@ -19,8 +19,6 @@ class ContentIdIn extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -36,19 +34,14 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'content_id_id:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'content_id_id:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php b/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php index 43617c6f..0400d7b1 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentTypeGroupIdIn.php @@ -17,11 +17,6 @@ */ class ContentTypeGroupIdIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -36,19 +31,14 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'content_type_group_ids_mid:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'content_type_group_ids_mid:"' . $value . '"', // TODO this should have been casted by criterion??? (array)$criterion->value ) diff --git a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php index 963d09c4..87000337 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdIn.php @@ -17,11 +17,6 @@ */ class ContentTypeIdIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -36,19 +31,14 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'content_type_id_id:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'content_type_id_id:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php index 98419c8e..2decfd61 100644 --- a/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ContentTypeIdentifierIn.php @@ -21,26 +21,20 @@ */ class ContentTypeIdentifierIn extends CriterionVisitor { - /** - * ContentType handler. - */ - protected Handler $contentTypeHandler; - protected LoggerInterface $logger; /** * Create from content type handler and field registry. */ - public function __construct(Handler $contentTypeHandler, LoggerInterface $logger = null) - { - $this->contentTypeHandler = $contentTypeHandler; + public function __construct( + protected readonly Handler $contentTypeHandler, + ?LoggerInterface $logger = null + ) { $this->logger = $logger ?? new NullLogger(); } /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -56,11 +50,8 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $validIds = []; $invalidIdentifiers = []; @@ -69,7 +60,7 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito foreach ($criterion->value as $identifier) { try { $validIds[] = $contentTypeHandler->loadByIdentifier((string) $identifier)->id; - } catch (NotFoundException $e) { + } catch (NotFoundException) { // Filter out non-existing content types, but track for code below $invalidIdentifiers[] = $identifier; } @@ -92,9 +83,7 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito implode( ' OR ', array_map( - static function (string $value): string { - return 'content_type_id_id:"' . $value . '"'; - }, + static fn (string $value): string => 'content_type_id_id:"' . $value . '"', $validIds ) ) . diff --git a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php index 41dea38b..873b76d0 100644 --- a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php +++ b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldIn.php @@ -19,8 +19,6 @@ class CustomFieldIn extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -36,12 +34,9 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $queries = []; $values = (array)$criterion->value; @@ -61,6 +56,6 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito private function isRegExp($preparedValue): int|false { - return preg_match('#^/.*/$#', $preparedValue); + return preg_match('#^/.*/$#', (string) $preparedValue); } } diff --git a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php index ff0bae75..51a8d937 100644 --- a/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php +++ b/src/lib/Query/Common/CriterionVisitor/CustomField/CustomFieldRange.php @@ -19,8 +19,6 @@ class CustomFieldRange extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -39,15 +37,12 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $values = (array)$criterion->value; $start = $values[0]; - $end = isset($values[1]) ? $values[1] : null; + $end = $values[1] ?? null; if (($criterion->operator === Operator::LT) || ($criterion->operator === Operator::LTE)) { $end = $start; diff --git a/src/lib/Query/Common/CriterionVisitor/DateMetadata.php b/src/lib/Query/Common/CriterionVisitor/DateMetadata.php index 7dcc53e0..cb28d54d 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata.php @@ -17,19 +17,15 @@ abstract class DateMetadata extends CriterionVisitor { /** * Map value to a proper Solr date representation. - * - * @param mixed $value - * - * @return string */ - protected function getSolrTime($value) + protected function getSolrTime(mixed $value): string { if (is_numeric($value)) { $date = new \DateTime("@{$value}"); } else { try { $date = new \DateTime($value); - } catch (Exception $e) { + } catch (Exception) { throw new \InvalidArgumentException('Invalid date provided: ' . $value); } } diff --git a/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php b/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php index dceecdf5..88e8ede2 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedBetween.php @@ -20,8 +20,6 @@ class ModifiedBetween extends DateMetadata { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -39,11 +37,8 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $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 ca633a46..c2856c23 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/ModifiedIn.php @@ -20,8 +20,6 @@ class ModifiedIn extends DateMetadata { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -38,11 +36,8 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $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 73a2b853..f7bb9281 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedBetween.php @@ -20,10 +20,8 @@ class PublishedBetween extends DateMetadata { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { if (!$criterion instanceof Criterion\DateMetadata) { return false; @@ -46,11 +44,8 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $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 483149e0..3d427e5f 100644 --- a/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php +++ b/src/lib/Query/Common/CriterionVisitor/DateMetadata/PublishedIn.php @@ -20,10 +20,8 @@ class PublishedIn extends DateMetadata { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { if (!$criterion instanceof Criterion\DateMetadata) { return false; @@ -42,18 +40,13 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return implode( ' OR ', array_map( - function ($value): string { - return 'content_publication_date_dt:"' . $this->getSolrTime($value) . '"'; - }, + fn ($value): string => 'content_publication_date_dt:"' . $this->getSolrTime($value) . '"', $criterion->value ) ); diff --git a/src/lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php b/src/lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php index d7ca7e28..2fad43be 100644 --- a/src/lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php +++ b/src/lib/Query/Common/CriterionVisitor/Factory/FullTextFactoryAbstract.php @@ -25,34 +25,16 @@ */ abstract class FullTextFactoryAbstract { - /** - * Field map. - */ - protected FieldNameResolver $fieldNameResolver; - - protected Tokenizer $tokenizer; - - protected Parser $parser; - - protected ExtendedDisMax $generator; - - protected IndexingDepthProvider $indexingDepthProvider; - /** * Create from content type handler and field registry. */ public function __construct( - FieldNameResolver $fieldNameResolver, - Tokenizer $tokenizer, - Parser $parser, - ExtendedDisMax $generator, - IndexingDepthProvider $indexingDepthProvider + protected readonly FieldNameResolver $fieldNameResolver, + protected readonly Tokenizer $tokenizer, + protected readonly Parser $parser, + protected readonly ExtendedDisMax $generator, + protected readonly IndexingDepthProvider $indexingDepthProvider ) { - $this->fieldNameResolver = $fieldNameResolver; - $this->tokenizer = $tokenizer; - $this->parser = $parser; - $this->generator = $generator; - $this->indexingDepthProvider = $indexingDepthProvider; } /** diff --git a/src/lib/Query/Common/CriterionVisitor/Field.php b/src/lib/Query/Common/CriterionVisitor/Field.php index 66507ab2..5c30c56b 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field.php +++ b/src/lib/Query/Common/CriterionVisitor/Field.php @@ -21,17 +21,10 @@ */ abstract class Field extends CriterionVisitor { - /** - * Field map. - */ - protected FieldNameResolver $fieldNameResolver; - - protected FieldValueMapper $fieldValueMapper; - - public function __construct(FieldNameResolver $fieldNameResolver, FieldValueMapper $fieldValueMapper) - { - $this->fieldNameResolver = $fieldNameResolver; - $this->fieldValueMapper = $fieldValueMapper; + public function __construct( + protected readonly FieldNameResolver $fieldNameResolver, + protected readonly FieldValueMapper $fieldValueMapper + ) { } /** @@ -39,7 +32,7 @@ public function __construct(FieldNameResolver $fieldNameResolver, FieldValueMapp * * @return \Ibexa\Contracts\Core\Search\FieldType[] Array of field types indexed by name. */ - protected function getSearchFields(Criterion $criterion) + protected function getSearchFields(Criterion $criterion): array { return $this->fieldNameResolver->getFieldTypes( $criterion, @@ -49,13 +42,8 @@ protected function getSearchFields(Criterion $criterion) /** * Map search field value to solr value using FieldValueMapper. - * - * @param mixed $value - * @param \Ibexa\Contracts\Core\Search\FieldType $searchFieldType - * - * @return mixed */ - protected function mapSearchFieldValue($value, FieldType $searchFieldType = null) + protected function mapSearchFieldValue(mixed $value, ?FieldType $searchFieldType = null): mixed { if (null === $searchFieldType) { return $value; diff --git a/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php index 6df04b3b..84bd4553 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldEmpty.php @@ -24,16 +24,12 @@ */ final class FieldEmpty extends Field { - private FieldNameGenerator $fieldNameGenerator; - public function __construct( FieldNameResolver $fieldNameResolver, FieldValueMapper $fieldValueMapper, - FieldNameGenerator $fieldNameGenerator + private readonly FieldNameGenerator $fieldNameGenerator ) { parent::__construct($fieldNameResolver, $fieldValueMapper); - - $this->fieldNameGenerator = $fieldNameGenerator; } /** @@ -50,9 +46,8 @@ public function canVisit(CriterionInterface $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(CriterionInterface $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 8a8f37fb..66c17846 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldIn.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldIn.php @@ -23,8 +23,6 @@ class FieldIn extends Field * Check if visitor is applicable to current criterion. * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -41,11 +39,8 @@ public function canVisit(CriterionInterface $criterion): bool * @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\Field $criterion - * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor - * - * @return string */ - public function visit(CriterionInterface $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/FieldLike.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldLike.php index bebefc8a..09bc4242 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldLike.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldLike.php @@ -23,8 +23,6 @@ class FieldLike extends Field * Check if visitor is applicable to current criterion. * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -37,11 +35,8 @@ public function canVisit(CriterionInterface $criterion): bool * @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\Field $criterion - * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor - * - * @return string */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $searchFields = $this->getSearchFields($criterion); @@ -57,7 +52,7 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito $preparedValue = $this->toString($this->mapSearchFieldValue($criterion->value, $fieldType)); // Check if there is user supplied wildcard or not - if (strpos($preparedValue, '*') !== false) { + if (str_contains($preparedValue, '*')) { $queries[] = $name . ':' . $this->escapeExpressions($preparedValue, true); } else { $queries[] = $name . ':"' . $this->escapeQuote($preparedValue, true) . '"'; diff --git a/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php index cf73c80a..cc9d8f71 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldRange.php @@ -23,8 +23,6 @@ class FieldRange extends Field * Check if visitor is applicable to current criterion. * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -41,13 +39,10 @@ public function canVisit(CriterionInterface $criterion): bool * Map field value to a proper Solr representation. * * @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(CriterionInterface $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/FieldRelation.php b/src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php index 8f0482b1..222f200b 100644 --- a/src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php +++ b/src/lib/Query/Common/CriterionVisitor/Field/FieldRelation.php @@ -23,8 +23,6 @@ class FieldRelation extends Field * Check if visitor is applicable to current criterion. * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -38,15 +36,12 @@ public function canVisit(CriterionInterface $criterion): bool * Map field value to a proper Solr representation. * * @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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { - $searchFields = $this->getSearchFields($criterion, $criterion->target); + $searchFields = $this->getSearchFields($criterion); if (empty($searchFields)) { throw new InvalidArgumentException( @@ -67,14 +62,10 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito } } - switch ($criterion->operator) { - case Operator::CONTAINS: - $op = ' AND '; - break; - case Operator::IN: - default: - $op = ' OR '; - } + $op = match ($criterion->operator) { + Operator::CONTAINS => ' AND ', + default => ' OR ', + }; return '(' . implode($op, $queries) . ')'; } diff --git a/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php b/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php index 5ba18e1f..9411abf4 100644 --- a/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php +++ b/src/lib/Query/Common/CriterionVisitor/IsUserEnabled.php @@ -14,7 +14,7 @@ final class IsUserEnabled extends CriterionVisitor { - private const SEARCH_FIELD = 'user_is_enabled_b'; + private const string SEARCH_FIELD = 'user_is_enabled_b'; public function canVisit(CriterionInterface $criterion): bool { @@ -24,7 +24,7 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\IsUserEnabled $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + 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 e1d6b489..c4e678ee 100644 --- a/src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php +++ b/src/lib/Query/Common/CriterionVisitor/LanguageCodeIn.php @@ -19,8 +19,6 @@ class LanguageCodeIn extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -34,16 +32,11 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $languageCodeExpressions = array_map( - static function (bool|float|int|string $value): string { - return 'content_language_codes_ms:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'content_language_codes_ms:"' . $value . '"', $criterion->value ); diff --git a/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php b/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php index ae5d05e0..4a706edd 100644 --- a/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php +++ b/src/lib/Query/Common/CriterionVisitor/LogicalAnd.php @@ -19,10 +19,8 @@ class LogicalAnd extends CriterionVisitor { /** * CHeck if visitor is applicable to current criterion. - * - * @return bool */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\LogicalAnd; } @@ -31,11 +29,8 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): false|string + public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd $criterion */ if (!isset($criterion->criteria[0])) { @@ -43,14 +38,12 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito } $subCriteria = array_map( - static function ($value) use ($subVisitor) { - return $subVisitor->visit($value); - }, + static fn (CriterionInterface $value): string => $subVisitor->visit($value), $criterion->criteria ); if (\count($subCriteria) === 1) { - return reset($subCriteria); + return $subCriteria[array_key_first($subCriteria)]; } return '(' . implode(' AND ', $subCriteria) . ')'; diff --git a/src/lib/Query/Common/CriterionVisitor/LogicalNot.php b/src/lib/Query/Common/CriterionVisitor/LogicalNot.php index 56ed669f..12a29910 100644 --- a/src/lib/Query/Common/CriterionVisitor/LogicalNot.php +++ b/src/lib/Query/Common/CriterionVisitor/LogicalNot.php @@ -16,12 +16,7 @@ */ class LogicalNot extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\LogicalNot; } @@ -30,11 +25,8 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { 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 ff49c54c..71e464e2 100644 --- a/src/lib/Query/Common/CriterionVisitor/LogicalOr.php +++ b/src/lib/Query/Common/CriterionVisitor/LogicalOr.php @@ -17,12 +17,7 @@ */ class LogicalOr extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\LogicalOr; } @@ -31,11 +26,8 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): false|string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd $criterion */ if (!isset($criterion->criteria[0])) { @@ -43,14 +35,12 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito } $subCriteria = array_map( - static function ($value) use ($subVisitor) { - return $subVisitor->visit($value); - }, + static fn (CriterionInterface $value): string => $subVisitor->visit($value), $criterion->criteria ); if (\count($subCriteria) === 1) { - return reset($subCriteria); + return $subCriteria[array_key_first($subCriteria)]; } return '(' . implode(' OR ', $subCriteria) . ')'; diff --git a/src/lib/Query/Common/CriterionVisitor/MapLocation.php b/src/lib/Query/Common/CriterionVisitor/MapLocation.php index 7e7ef034..74d08f90 100644 --- a/src/lib/Query/Common/CriterionVisitor/MapLocation.php +++ b/src/lib/Query/Common/CriterionVisitor/MapLocation.php @@ -17,54 +17,30 @@ */ abstract class MapLocation extends CriterionVisitor { - /** - * Field map. - */ - protected FieldNameResolver $fieldNameResolver; - - /** - * Identifier of the field type that criterion can handle. - * - * @var string - */ - protected $fieldTypeIdentifier; - - /** - * Name of the field type's indexed field that criterion can handle. - * - * @var string - */ - protected $fieldName; - /** * Create from FieldNameResolver, FieldType identifier and field name. * - * @param string $fieldTypeIdentifier - * @param string $fieldName + * @param string $fieldTypeIdentifier Identifier of the field type that criterion can handle. + * @param string $fieldName Name of the field type's indexed field that criterion can handle. */ - public function __construct(FieldNameResolver $fieldNameResolver, $fieldTypeIdentifier, $fieldName) - { - $this->fieldTypeIdentifier = $fieldTypeIdentifier; - $this->fieldName = $fieldName; - - $this->fieldNameResolver = $fieldNameResolver; + public function __construct( + protected FieldNameResolver $fieldNameResolver, + protected string $fieldTypeIdentifier, + protected string $fieldName + ) { } /** * Get array of search fields. * - * @param string $fieldDefinitionIdentifier - * @param string $fieldTypeIdentifier - * @param string $name - * - * @return array + * @return array */ protected function getSearchFields( CriterionInterface $criterion, - $fieldDefinitionIdentifier, - $fieldTypeIdentifier = null, - $name = null - ) { + string $fieldDefinitionIdentifier, + ?string $fieldTypeIdentifier = null, + ?string $name = null + ): array { return $this->fieldNameResolver->getFieldTypes( $criterion, $fieldDefinitionIdentifier, diff --git a/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php b/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php index 95e78310..1edbf323 100644 --- a/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php +++ b/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceIn.php @@ -23,8 +23,6 @@ class MapLocationDistanceIn extends MapLocation * Check if visitor is applicable to current criterion. * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -40,11 +38,8 @@ public function canVisit(CriterionInterface $criterion): bool * @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\MapLocationDistance $criterion - * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor - * - * @return string */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { /** @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 2a7daba0..fb249974 100644 --- a/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php +++ b/src/lib/Query/Common/CriterionVisitor/MapLocation/MapLocationDistanceRange.php @@ -23,8 +23,6 @@ class MapLocationDistanceRange extends MapLocation * Check if visitor is applicable to current criterion. * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion $criterion - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -43,16 +41,13 @@ public function canVisit(CriterionInterface $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\MapLocationDistance $criterion - * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor - * - * @return string */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $criterion->value = (array)$criterion->value; $start = $criterion->value[0]; - $end = isset($criterion->value[1]) ? $criterion->value[1] : 63510; + $end = $criterion->value[1] ?? 63510; if (($criterion->operator === Operator::LT) || ($criterion->operator === Operator::LTE)) { diff --git a/src/lib/Query/Common/CriterionVisitor/MatchAll.php b/src/lib/Query/Common/CriterionVisitor/MatchAll.php index 5820f4e9..e6467a94 100644 --- a/src/lib/Query/Common/CriterionVisitor/MatchAll.php +++ b/src/lib/Query/Common/CriterionVisitor/MatchAll.php @@ -16,12 +16,7 @@ */ class MatchAll extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\MatchAll; } @@ -30,11 +25,8 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '*:*'; } diff --git a/src/lib/Query/Common/CriterionVisitor/MatchNone.php b/src/lib/Query/Common/CriterionVisitor/MatchNone.php index ade56566..3bb05c96 100644 --- a/src/lib/Query/Common/CriterionVisitor/MatchNone.php +++ b/src/lib/Query/Common/CriterionVisitor/MatchNone.php @@ -16,12 +16,7 @@ */ class MatchNone extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\MatchNone; } @@ -30,11 +25,8 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(NOT *:*)'; } diff --git a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php index 1232aebb..9d674563 100644 --- a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdIn.php @@ -19,8 +19,6 @@ class ObjectStateIdIn extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -36,20 +34,16 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { + static fn (bool|float|int|string $value): string => // TODO this should not be multiple??? - return 'content_object_state_ids_mid:"' . $value . '"'; - }, + 'content_object_state_ids_mid:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php index 8a8853d2..94b64936 100644 --- a/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php +++ b/src/lib/Query/Common/CriterionVisitor/ObjectStateIdentifierIn.php @@ -28,7 +28,7 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ObjectStateIdentifier $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $target = $criterion->target ?? '*'; @@ -37,12 +37,10 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito implode( ' OR ', array_map( - function (string $value) use ($target): string { - return sprintf( - 'content_object_state_identifiers_ms:%s', - $this->escapeExpressions("{$target}:{$value}", true) - ); - }, + fn (string $value): string => sprintf( + 'content_object_state_identifiers_ms:%s', + $this->escapeExpressions("{$target}:{$value}", true) + ), (array)$criterion->value ) ) diff --git a/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php b/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php index d3b180e2..d52811bc 100644 --- a/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/RemoteIdIn.php @@ -19,8 +19,6 @@ class RemoteIdIn extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -36,19 +34,14 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'content_remote_id_id:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'content_remote_id_id:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php b/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php index 7165650a..921bead8 100644 --- a/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php +++ b/src/lib/Query/Common/CriterionVisitor/SectionIdentifierIn.php @@ -28,16 +28,14 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\SectionIdentifier $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', implode( ' OR ', array_map( - static function (string $value): string { - return 'content_section_identifier_id:"' . $value . '"'; - }, + static fn (string $value): string => 'content_section_identifier_id:"' . $value . '"', (array) $criterion->value ) ) diff --git a/src/lib/Query/Common/CriterionVisitor/SectionIn.php b/src/lib/Query/Common/CriterionVisitor/SectionIn.php index ab93aaa7..562bbe5d 100644 --- a/src/lib/Query/Common/CriterionVisitor/SectionIn.php +++ b/src/lib/Query/Common/CriterionVisitor/SectionIn.php @@ -19,8 +19,6 @@ class SectionIn extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -36,19 +34,14 @@ public function canVisit(CriterionInterface $criterion): bool * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'content_section_id_id:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'content_section_id_id:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php b/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php index 11388ef2..a1cdb426 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserEmailIn.php @@ -28,16 +28,14 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserEmail $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', implode( ' OR ', array_map( - static function (string $value): string { - return 'user_email_id:"' . hash(UserDocumentFields::HASHING_ALGORITHM, $value) . '"'; - }, + static fn (string $value): string => 'user_email_id:"' . hash(UserDocumentFields::HASHING_ALGORITHM, $value) . '"', (array) $criterion->value ) ) diff --git a/src/lib/Query/Common/CriterionVisitor/UserIdIn.php b/src/lib/Query/Common/CriterionVisitor/UserIdIn.php index d1cb90ab..526e20bc 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserIdIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserIdIn.php @@ -27,16 +27,14 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserId $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', implode( ' OR ', array_map( - static function (string $value): string { - return 'content_id_id:"' . $value . '"'; - }, + static fn (string $value): string => 'content_id_id:"' . $value . '"', (array) $criterion->value ) ) diff --git a/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php b/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php index d228b82d..aaafe678 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserLoginIn.php @@ -28,16 +28,14 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\UserLogin $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return sprintf( '(%s)', implode( ' OR ', array_map( - static function (string $value): string { - return 'user_login_id:"' . hash(UserDocumentFields::HASHING_ALGORITHM, $value) . '"'; - }, + static fn (string $value): string => 'user_login_id:"' . hash(UserDocumentFields::HASHING_ALGORITHM, $value) . '"', (array) $criterion->value ) ) diff --git a/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php b/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php index 3912c195..123a077b 100644 --- a/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php +++ b/src/lib/Query/Common/CriterionVisitor/UserMetadataIn.php @@ -20,8 +20,6 @@ class UserMetadataIn extends CriterionVisitor { /** * Check if visitor is applicable to current criterion. - * - * @return bool */ public function canVisit(CriterionInterface $criterion): bool { @@ -37,34 +35,21 @@ public function canVisit(CriterionInterface $criterion): bool * @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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string { - switch ($criterion->target) { - case Criterion\UserMetadata::MODIFIER: - $solrField = 'content_version_creator_user_id_id'; - break; - case Criterion\UserMetadata::OWNER: - $solrField = 'content_owner_user_id_id'; - break; - case Criterion\UserMetadata::GROUP: - $solrField = 'content_owner_user_group_ids_mid'; - break; - - default: - throw new NotImplementedException('No visitor available for target: ' . $criterion->target . ' with operator: ' . $criterion->operator); - } + $solrField = match ($criterion->target) { + Criterion\UserMetadata::MODIFIER => 'content_version_creator_user_id_id', + Criterion\UserMetadata::OWNER => 'content_owner_user_id_id', + Criterion\UserMetadata::GROUP => 'content_owner_user_group_ids_mid', + default => throw new NotImplementedException('No visitor available for target: ' . $criterion->target . ' with operator: ' . $criterion->operator), + }; return '(' . implode( ' OR ', array_map( - static function ($value) use ($solrField): string { - return "{$solrField}:\"{$value}\""; - }, + static fn ($value): string => "{$solrField}:\"{$value}\"", $criterion->value ) ) . diff --git a/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php b/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php index f53284a5..502840a4 100644 --- a/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php +++ b/src/lib/Query/Common/QueryConverter/NativeQueryConverter.php @@ -18,37 +18,13 @@ */ class NativeQueryConverter extends QueryConverter { - /** - * Query visitor. - */ - protected CriterionVisitor $criterionVisitor; - - /** - * Sort clause visitor. - */ - protected SortClauseVisitor $sortClauseVisitor; - - private AggregationVisitor $aggregationVisitor; - - /** - * Construct from visitors. - * - * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $criterionVisitor - * @param \Ibexa\Contracts\Solr\Query\SortClauseVisitor $sortClauseVisitor - */ public function __construct( - CriterionVisitor $criterionVisitor, - SortClauseVisitor $sortClauseVisitor, - AggregationVisitor $aggregationVisitor + protected readonly CriterionVisitor $criterionVisitor, + protected readonly SortClauseVisitor $sortClauseVisitor, + private readonly AggregationVisitor $aggregationVisitor ) { - $this->criterionVisitor = $criterionVisitor; - $this->sortClauseVisitor = $sortClauseVisitor; - $this->aggregationVisitor = $aggregationVisitor; } - /** - * @return mixed[] - */ public function convert(Query $query, array $languageSettings = []): array { $params = [ @@ -93,15 +69,13 @@ public function convert(Query $query, array $languageSettings = []): array * Converts an array of sort clause objects to a proper Solr representation. * * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause[] $sortClauses - * - * @return string */ private function getSortClauses(array $sortClauses): string { return implode( ', ', array_map( - [$this->sortClauseVisitor, 'visit'], + $this->sortClauseVisitor->visit(...), $sortClauses ) ); diff --git a/src/lib/Query/Common/QueryTranslator/Generator/WordVisitor.php b/src/lib/Query/Common/QueryTranslator/Generator/WordVisitor.php index 1fd997e8..d8a8d39e 100644 --- a/src/lib/Query/Common/QueryTranslator/Generator/WordVisitor.php +++ b/src/lib/Query/Common/QueryTranslator/Generator/WordVisitor.php @@ -16,7 +16,11 @@ */ class WordVisitor extends WordBase { - public function visit(Node $node, Visitor $subVisitor = null, $options = null): string + /** + * @param array|null $options + */ + #[\Override] + public function visit(Node $node, ?Visitor $subVisitor = null, $options = null): string { $word = parent::visit($node, $subVisitor, $options); @@ -33,6 +37,8 @@ public function visit(Node $node, Visitor $subVisitor = null, $options = null): * * Note: additionally to what is defined above we also escape blank space, * and we don't escape an asterisk. + * + * @param string $string */ protected function escapeWord($string): ?string { diff --git a/src/lib/Query/Common/SortClauseVisitor/Aggregate.php b/src/lib/Query/Common/SortClauseVisitor/Aggregate.php index a3e12ba7..e3c6b029 100644 --- a/src/lib/Query/Common/SortClauseVisitor/Aggregate.php +++ b/src/lib/Query/Common/SortClauseVisitor/Aggregate.php @@ -21,7 +21,7 @@ class Aggregate extends SortClauseVisitor * * @var \Ibexa\Contracts\Solr\Query\SortClauseVisitor[] */ - protected $visitors = []; + protected array $visitors = []; /** * Construct from optional visitor array. @@ -35,9 +35,6 @@ public function __construct(array $visitors = []) } } - /** - * Adds visitor. - */ public function addVisitor(SortClauseVisitor $visitor): void { $this->visitors[] = $visitor; @@ -45,8 +42,6 @@ public function addVisitor(SortClauseVisitor $visitor): void /** * Check if visitor is applicable to current sortClause. - * - * @return bool */ public function canVisit(SortClause $sortClause): bool { @@ -57,10 +52,8 @@ public function canVisit(SortClause $sortClause): bool * Map field value to a proper Solr representation. * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotImplementedException - * - * @return string */ - public function visit(SortClause $sortClause) + public function visit(SortClause $sortClause): string { foreach ($this->visitors as $visitor) { if ($visitor->canVisit($sortClause)) { @@ -68,6 +61,6 @@ public function visit(SortClause $sortClause) } } - throw new NotImplementedException('No visitor available for: ' . \get_class($sortClause)); + throw new NotImplementedException('No visitor available for: ' . $sortClause::class); } } diff --git a/src/lib/Query/Common/SortClauseVisitor/ContentId.php b/src/lib/Query/Common/SortClauseVisitor/ContentId.php index 768e739a..05314194 100644 --- a/src/lib/Query/Common/SortClauseVisitor/ContentId.php +++ b/src/lib/Query/Common/SortClauseVisitor/ContentId.php @@ -15,21 +15,11 @@ */ class ContentId extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\ContentId; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'content_id_normalized_i' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Common/SortClauseVisitor/ContentName.php b/src/lib/Query/Common/SortClauseVisitor/ContentName.php index 0b66c4ec..e717f94e 100644 --- a/src/lib/Query/Common/SortClauseVisitor/ContentName.php +++ b/src/lib/Query/Common/SortClauseVisitor/ContentName.php @@ -15,21 +15,11 @@ */ class ContentName extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\ContentName; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'content_name_s' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Common/SortClauseVisitor/DateModified.php b/src/lib/Query/Common/SortClauseVisitor/DateModified.php index 5fdc68cc..8dd36c5e 100644 --- a/src/lib/Query/Common/SortClauseVisitor/DateModified.php +++ b/src/lib/Query/Common/SortClauseVisitor/DateModified.php @@ -15,21 +15,11 @@ */ class DateModified extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\DateModified; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'content_modification_date_dt' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Common/SortClauseVisitor/DatePublished.php b/src/lib/Query/Common/SortClauseVisitor/DatePublished.php index 1f001f70..b4c2320e 100644 --- a/src/lib/Query/Common/SortClauseVisitor/DatePublished.php +++ b/src/lib/Query/Common/SortClauseVisitor/DatePublished.php @@ -15,21 +15,11 @@ */ class DatePublished extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\DatePublished; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'content_publication_date_dt' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Common/SortClauseVisitor/Field.php b/src/lib/Query/Common/SortClauseVisitor/Field.php index ed570e8d..03ddf7d6 100644 --- a/src/lib/Query/Common/SortClauseVisitor/Field.php +++ b/src/lib/Query/Common/SortClauseVisitor/Field.php @@ -17,35 +17,16 @@ */ class Field extends SortClauseVisitor { - /** - * Field name resolver. - */ - protected FieldNameResolver $fieldNameResolver; - - /** - * Create from field name resolver. - * - * @param \Ibexa\Core\Search\Common\FieldNameResolver $fieldNameResolver - */ - public function __construct(FieldNameResolver $fieldNameResolver) - { - $this->fieldNameResolver = $fieldNameResolver; + public function __construct( + protected readonly FieldNameResolver $fieldNameResolver + ) { } - /** - * Get sort field name. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * @param string $contentTypeIdentifier - * @param string $fieldDefinitionIdentifier - * - * @return array - */ protected function getSortFieldName( SortClause $sortClause, - $contentTypeIdentifier, - $fieldDefinitionIdentifier - ) { + string $contentTypeIdentifier, + string $fieldDefinitionIdentifier + ): ?string { return $this->fieldNameResolver->getSortFieldName( $sortClause, $contentTypeIdentifier, @@ -53,14 +34,7 @@ protected function getSortFieldName( ); } - /** - * Check if visitor is applicable to the $sortClause. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Field; } @@ -68,12 +42,7 @@ public function canVisit(SortClause $sortClause) /** * Map the $sortClause to a proper Solr representation. * - * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no sortable fields are - * found for the given sort clause target. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * - * @return string + * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no sortable fields are found for the given sort clause target. */ public function visit(SortClause $sortClause): string { diff --git a/src/lib/Query/Common/SortClauseVisitor/MapLocationDistance.php b/src/lib/Query/Common/SortClauseVisitor/MapLocationDistance.php index dc871476..c89fc138 100644 --- a/src/lib/Query/Common/SortClauseVisitor/MapLocationDistance.php +++ b/src/lib/Query/Common/SortClauseVisitor/MapLocationDistance.php @@ -17,46 +17,18 @@ */ class MapLocationDistance extends SortClauseVisitor { - /** - * Name of the field type's indexed field that criterion can handle. - * - * @var string - */ - protected $fieldName; - - /** - * Field name resolver. - */ - protected FieldNameResolver $fieldNameResolver; - - /** - * Create from field name resolver and field name. - * - * @param \Ibexa\Core\Search\Common\FieldNameResolver $fieldNameResolver - * @param string $fieldName - */ - public function __construct(FieldNameResolver $fieldNameResolver, $fieldName) - { - $this->fieldNameResolver = $fieldNameResolver; - $this->fieldName = $fieldName; + public function __construct( + protected readonly FieldNameResolver $fieldNameResolver, + protected string $fieldName + ) { } - /** - * Get sort field name. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * @param string $contentTypeIdentifier - * @param string $fieldDefinitionIdentifier - * @param string $name - * - * @return array - */ protected function getSortFieldName( SortClause $sortClause, - $contentTypeIdentifier, - $fieldDefinitionIdentifier, - $name = null - ) { + string $contentTypeIdentifier, + string $fieldDefinitionIdentifier, + ?string $name = null + ): ?string { return $this->fieldNameResolver->getSortFieldName( $sortClause, $contentTypeIdentifier, @@ -65,14 +37,7 @@ protected function getSortFieldName( ); } - /** - * Check if visitor is applicable to current sortClause. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\MapLocationDistance; } @@ -81,10 +46,6 @@ public function canVisit(SortClause $sortClause) * Map field value to a proper Solr representation. * * @throws \Ibexa\Core\Base\Exceptions\InvalidArgumentException If no sortable fields are found for the given sort clause target. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * - * @return string */ public function visit(SortClause $sortClause): string { diff --git a/src/lib/Query/Common/SortClauseVisitor/Random.php b/src/lib/Query/Common/SortClauseVisitor/Random.php index 17a0a353..968a7b91 100644 --- a/src/lib/Query/Common/SortClauseVisitor/Random.php +++ b/src/lib/Query/Common/SortClauseVisitor/Random.php @@ -17,22 +17,14 @@ class Random extends SortClauseVisitor { /** * Check if visitor is applicable to current sortClause. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * - * @return bool */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Random; } /** * Map field value to a proper Solr representation. - * - * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause $sortClause - * - * @return string */ public function visit(SortClause $sortClause): string { diff --git a/src/lib/Query/Common/SortClauseVisitor/SectionIdentifier.php b/src/lib/Query/Common/SortClauseVisitor/SectionIdentifier.php index 24f0d0d2..a54f4afa 100644 --- a/src/lib/Query/Common/SortClauseVisitor/SectionIdentifier.php +++ b/src/lib/Query/Common/SortClauseVisitor/SectionIdentifier.php @@ -15,21 +15,11 @@ */ class SectionIdentifier extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\SectionIdentifier; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'content_section_identifier_id' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Common/SortClauseVisitor/SectionName.php b/src/lib/Query/Common/SortClauseVisitor/SectionName.php index 42f19b84..628980e9 100644 --- a/src/lib/Query/Common/SortClauseVisitor/SectionName.php +++ b/src/lib/Query/Common/SortClauseVisitor/SectionName.php @@ -15,21 +15,11 @@ */ class SectionName extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\SectionName; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'content_section_name_s' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Content/CriterionVisitor/Ancestor.php b/src/lib/Query/Content/CriterionVisitor/Ancestor.php index 2bd81e57..a78b5ba2 100644 --- a/src/lib/Query/Content/CriterionVisitor/Ancestor.php +++ b/src/lib/Query/Content/CriterionVisitor/Ancestor.php @@ -17,25 +17,15 @@ */ class Ancestor extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof AncestorCriterion; } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $idSet = []; foreach ($criterion->value as $value) { @@ -48,9 +38,7 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito implode( ' OR ', array_map( - static function (string $value): string { - return 'location_id_mid:"' . $value . '"'; - }, + static fn (string $value): string => 'location_id_mid:"' . $value . '"', array_keys($idSet) ) ) . diff --git a/src/lib/Query/Content/CriterionVisitor/ContentName.php b/src/lib/Query/Content/CriterionVisitor/ContentName.php index 77e8518e..bee493c0 100644 --- a/src/lib/Query/Content/CriterionVisitor/ContentName.php +++ b/src/lib/Query/Content/CriterionVisitor/ContentName.php @@ -26,7 +26,7 @@ public function canVisit(CriterionInterface $criterion): bool /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentName $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { /** @var string $value */ $value = $criterion->value; diff --git a/src/lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php b/src/lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php index 3b077713..0e6fdf24 100644 --- a/src/lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php +++ b/src/lib/Query/Content/CriterionVisitor/Factory/ContentFullTextFactory.php @@ -21,11 +21,6 @@ */ final class ContentFullTextFactory extends FullTextFactoryAbstract { - /** - * Create FullText Criterion Visitor. - * - * @return \Ibexa\Contracts\Solr\Query\CriterionVisitor|\Ibexa\Solr\Query\Content\CriterionVisitor\FullText - */ public function createCriterionVisitor(): CriterionVisitor { return new FullText( diff --git a/src/lib/Query/Content/CriterionVisitor/Factory/FullTextFactory.php b/src/lib/Query/Content/CriterionVisitor/Factory/FullTextFactory.php index dd48fa4e..67ed4b73 100644 --- a/src/lib/Query/Content/CriterionVisitor/Factory/FullTextFactory.php +++ b/src/lib/Query/Content/CriterionVisitor/Factory/FullTextFactory.php @@ -22,48 +22,22 @@ * * @internal */ -final class FullTextFactory +final readonly class FullTextFactory { - /** - * Field map. - */ - private FieldNameResolver $fieldNameResolver; - - private Tokenizer $tokenizer; - - private Parser $parser; - - private ExtendedDisMax $generator; - - private IndexingDepthProvider $indexingDepthProvider; - /** * Create from content type handler and field registry. - * - * @param \Ibexa\Core\Search\Common\FieldNameResolver $fieldNameResolver - * @param \QueryTranslator\Languages\Galach\Tokenizer $tokenizer - * @param \QueryTranslator\Languages\Galach\Parser $parser - * @param \QueryTranslator\Languages\Galach\Generators\ExtendedDisMax $generator - * @param \Ibexa\Solr\FieldMapper\IndexingDepthProvider $indexingDepthProvider */ public function __construct( - FieldNameResolver $fieldNameResolver, - Tokenizer $tokenizer, - Parser $parser, - ExtendedDisMax $generator, - IndexingDepthProvider $indexingDepthProvider + private FieldNameResolver $fieldNameResolver, + private Tokenizer $tokenizer, + private Parser $parser, + private ExtendedDisMax $generator, + private IndexingDepthProvider $indexingDepthProvider ) { - $this->fieldNameResolver = $fieldNameResolver; - $this->tokenizer = $tokenizer; - $this->parser = $parser; - $this->generator = $generator; - $this->indexingDepthProvider = $indexingDepthProvider; } /** * Create FullText Criterion Visitor. - * - * @return \Ibexa\Solr\Query\Content\CriterionVisitor\FullText */ public function createCriterionVisitor(): FullText { diff --git a/src/lib/Query/Content/CriterionVisitor/FullText.php b/src/lib/Query/Content/CriterionVisitor/FullText.php index 9039db3f..e8cfd79f 100644 --- a/src/lib/Query/Content/CriterionVisitor/FullText.php +++ b/src/lib/Query/Content/CriterionVisitor/FullText.php @@ -21,59 +21,29 @@ */ class FullText extends CriterionVisitor { - /** - * Field map. - */ - protected FieldNameResolver $fieldNameResolver; - - protected Tokenizer $tokenizer; - - protected Parser $parser; - - protected ExtendedDisMax $generator; - - /** - * @var int - */ - protected $maxDepth; - /** * Create from content type handler and field registry. - * - * @param int $maxDepth */ public function __construct( - FieldNameResolver $fieldNameResolver, - Tokenizer $tokenizer, - Parser $parser, - ExtendedDisMax $generator, - $maxDepth = 0 + protected readonly FieldNameResolver $fieldNameResolver, + protected readonly Tokenizer $tokenizer, + protected readonly Parser $parser, + protected readonly ExtendedDisMax $generator, + protected readonly int $maxDepth = 0 ) { - $this->fieldNameResolver = $fieldNameResolver; - $this->tokenizer = $tokenizer; - $this->parser = $parser; - $this->generator = $generator; - $this->maxDepth = $maxDepth; } /** * Get field type information. * - * @param string $fieldDefinitionIdentifier - * - * @return array + * @return array */ - protected function getSearchFields(Criterion $criterion, $fieldDefinitionIdentifier) + protected function getSearchFields(Criterion $criterion, string $fieldDefinitionIdentifier): array { return $this->fieldNameResolver->getFieldTypes($criterion, $fieldDefinitionIdentifier); } - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof FullTextCriterion; } @@ -81,12 +51,9 @@ public function canVisit(CriterionInterface $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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { /** @var \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\FullText $criterion */ $tokenSequence = $this->tokenizer->tokenize($criterion->value); @@ -129,6 +96,6 @@ private function getQueryFields(Criterion $criterion): string */ private function getBoostFactorForRelatedContent(int $depth): float { - return 1.0 / pow(2.0, $depth); + return 1.0 / 2.0 ** $depth; } } diff --git a/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php b/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php index 733431b0..69af76b5 100644 --- a/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php +++ b/src/lib/Query/Content/CriterionVisitor/LocationIdIn.php @@ -17,11 +17,6 @@ */ class LocationIdIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -33,20 +28,15 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $id): string { - return 'location_id_mid:"' . $id . '"'; - }, + static fn (bool|float|int|string $id): string => 'location_id_mid:"' . $id . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php b/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php index 038c11b9..36fc4c44 100644 --- a/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php +++ b/src/lib/Query/Content/CriterionVisitor/LocationRemoteIdIn.php @@ -17,11 +17,6 @@ */ class LocationRemoteIdIn extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -33,20 +28,15 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $id): string { - return 'location_remote_id_mid:"' . $id . '"'; - }, + static fn (bool|float|int|string $id): string => 'location_remote_id_mid:"' . $id . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php b/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php index dc9da2b9..fcf4b1f3 100644 --- a/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php +++ b/src/lib/Query/Content/CriterionVisitor/ParentLocationIdIn.php @@ -17,11 +17,6 @@ */ class ParentLocationIdIn extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -33,20 +28,15 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $id): string { - return 'location_parent_id_mid:"' . $id . '"'; - }, + static fn (bool|float|int|string $id): string => 'location_parent_id_mid:"' . $id . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php b/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php index 1dbf7f43..4ab3bf32 100644 --- a/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php +++ b/src/lib/Query/Content/CriterionVisitor/SubtreeIn.php @@ -17,11 +17,6 @@ */ class SubtreeIn extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -33,20 +28,15 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function ($value): string { - return 'location_path_string_mid:' . str_replace('/', '\\/', $value) . '*'; - }, + static fn (string $value): string => 'location_path_string_mid:' . str_replace('/', '\\/', $value) . '*', $criterion->value ) ) . diff --git a/src/lib/Query/Content/CriterionVisitor/Visibility.php b/src/lib/Query/Content/CriterionVisitor/Visibility.php index d5901358..d5fe38f0 100644 --- a/src/lib/Query/Content/CriterionVisitor/Visibility.php +++ b/src/lib/Query/Content/CriterionVisitor/Visibility.php @@ -17,11 +17,6 @@ */ class Visibility extends CriterionVisitor { - /** - * CHeck if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Visibility && $criterion->operator === Operator::EQ; @@ -30,13 +25,9 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { 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 9b5d6391..c189c8ab 100644 --- a/src/lib/Query/Image/CriterionVisitor/AbstractImageRangeVisitor.php +++ b/src/lib/Query/Image/CriterionVisitor/AbstractImageRangeVisitor.php @@ -16,7 +16,7 @@ abstract class AbstractImageRangeVisitor extends AbstractImageVisitor /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageRangeCriterion $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + 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 ce9984ae..0d87bf40 100644 --- a/src/lib/Query/Image/CriterionVisitor/AbstractImageTermsVisitor.php +++ b/src/lib/Query/Image/CriterionVisitor/AbstractImageTermsVisitor.php @@ -16,7 +16,7 @@ abstract class AbstractImageTermsVisitor extends AbstractImageVisitor /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageRangeCriterion $criterion */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + 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 1b46dd9c..13134cf0 100644 --- a/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php +++ b/src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php @@ -16,16 +16,10 @@ abstract class AbstractImageVisitor extends CriterionVisitor { - private FieldNameResolver $fieldNameResolver; - - private Type $imageFieldType; - public function __construct( - FieldNameResolver $fieldNameResolver, - Type $imageFieldType + private readonly FieldNameResolver $fieldNameResolver, + private readonly Type $imageFieldType ) { - $this->fieldNameResolver = $fieldNameResolver; - $this->imageFieldType = $imageFieldType; } abstract protected function getSearchFieldName(): string; @@ -33,7 +27,7 @@ abstract protected function getSearchFieldName(): string; /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\Image\AbstractImageRangeCriterion $criterion * - * @return array + * @return list * * @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException */ @@ -48,7 +42,7 @@ protected function getSearchFieldNames(CriterionInterface $criterion): array ) ); - if (empty($searchFieldNames)) { + if ($searchFieldNames === []) { throw new InvalidArgumentException( '$criterion->target', "No searchable Fields found for the provided Criterion target '{$criterion->target}'." diff --git a/src/lib/Query/Image/CriterionVisitor/FileSize.php b/src/lib/Query/Image/CriterionVisitor/FileSize.php index a8d92432..f529f5a6 100644 --- a/src/lib/Query/Image/CriterionVisitor/FileSize.php +++ b/src/lib/Query/Image/CriterionVisitor/FileSize.php @@ -14,7 +14,7 @@ final class FileSize extends AbstractImageRangeVisitor { - private const SEARCH_FIELD_FILE_SIZE = 'file_size'; + private const string SEARCH_FIELD_FILE_SIZE = 'file_size'; public function canVisit(CriterionInterface $criterion): bool { diff --git a/src/lib/Query/Image/CriterionVisitor/Height.php b/src/lib/Query/Image/CriterionVisitor/Height.php index 683d1470..e6c48d0a 100644 --- a/src/lib/Query/Image/CriterionVisitor/Height.php +++ b/src/lib/Query/Image/CriterionVisitor/Height.php @@ -14,7 +14,7 @@ final class Height extends AbstractImageRangeVisitor { - private const SEARCH_FIELD_HEIGHT = 'height'; + private const string SEARCH_FIELD_HEIGHT = 'height'; public function canVisit(CriterionInterface $criterion): bool { diff --git a/src/lib/Query/Image/CriterionVisitor/MimeType.php b/src/lib/Query/Image/CriterionVisitor/MimeType.php index 2ff6b65d..0c480cd4 100644 --- a/src/lib/Query/Image/CriterionVisitor/MimeType.php +++ b/src/lib/Query/Image/CriterionVisitor/MimeType.php @@ -14,7 +14,7 @@ final class MimeType extends AbstractImageTermsVisitor { - private const SEARCH_FIELD_MIME_TYPE = 'mime_type'; + private const string SEARCH_FIELD_MIME_TYPE = 'mime_type'; public function canVisit(CriterionInterface $criterion): bool { diff --git a/src/lib/Query/Image/CriterionVisitor/Orientation.php b/src/lib/Query/Image/CriterionVisitor/Orientation.php index e090aece..4e938dc9 100644 --- a/src/lib/Query/Image/CriterionVisitor/Orientation.php +++ b/src/lib/Query/Image/CriterionVisitor/Orientation.php @@ -14,7 +14,7 @@ final class Orientation extends AbstractImageTermsVisitor { - private const SEARCH_FIELD_ORIENTATION = 'orientation'; + private const string SEARCH_FIELD_ORIENTATION = 'orientation'; public function canVisit(CriterionInterface $criterion): bool { diff --git a/src/lib/Query/Image/CriterionVisitor/Width.php b/src/lib/Query/Image/CriterionVisitor/Width.php index 90dae94f..c4ac83ac 100644 --- a/src/lib/Query/Image/CriterionVisitor/Width.php +++ b/src/lib/Query/Image/CriterionVisitor/Width.php @@ -14,7 +14,7 @@ final class Width extends AbstractImageRangeVisitor { - private const SEARCH_FIELD_WIDTH = 'width'; + private const string SEARCH_FIELD_WIDTH = 'width'; public function canVisit(CriterionInterface $criterion): bool { diff --git a/src/lib/Query/Location/CriterionVisitor/Ancestor.php b/src/lib/Query/Location/CriterionVisitor/Ancestor.php index 43efb838..f8cd039c 100644 --- a/src/lib/Query/Location/CriterionVisitor/Ancestor.php +++ b/src/lib/Query/Location/CriterionVisitor/Ancestor.php @@ -17,25 +17,15 @@ */ class Ancestor extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof AncestorCriterion; } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $idSet = []; foreach ($criterion->value as $value) { @@ -48,9 +38,7 @@ public function visit(CriterionInterface $criterion, CriterionVisitor $subVisito implode( ' OR ', array_map( - static function (string $value): string { - return 'location_id:"' . $value . '"'; - }, + static fn (string $value): string => 'location_id:"' . $value . '"', array_keys($idSet) ) ) . diff --git a/src/lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php b/src/lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php index dc1b87fd..f5f0e34a 100644 --- a/src/lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php +++ b/src/lib/Query/Location/CriterionVisitor/Factory/LocationFullTextFactory.php @@ -21,11 +21,6 @@ */ final class LocationFullTextFactory extends FullTextFactoryAbstract { - /** - * Create FullText Criterion Visitor. - * - * @return \Ibexa\Contracts\Solr\Query\CriterionVisitor|\Ibexa\Solr\Query\Location\CriterionVisitor\FullText - */ public function createCriterionVisitor(): CriterionVisitor { return new FullText( diff --git a/src/lib/Query/Location/CriterionVisitor/FullText.php b/src/lib/Query/Location/CriterionVisitor/FullText.php index 4059b96e..c468f92b 100644 --- a/src/lib/Query/Location/CriterionVisitor/FullText.php +++ b/src/lib/Query/Location/CriterionVisitor/FullText.php @@ -17,14 +17,8 @@ */ class FullText extends ContentFullText { - /** - * Map field value to a proper Solr representation. - * - * @param \Ibexa\Contracts\Solr\Query\CriterionVisitor $subVisitor - * - * @return string - */ - public function visit(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + #[\Override] + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $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 97568dc1..360e4744 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/DepthBetween.php @@ -17,11 +17,6 @@ */ class DepthBetween extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -38,15 +33,12 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $start = $criterion->value[0]; - $end = isset($criterion->value[1]) ? $criterion->value[1] : null; + $end = $criterion->value[1] ?? null; if ( ($criterion->operator === Operator::LT) || diff --git a/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php b/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php index 02127512..33fd95a6 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/DepthIn.php @@ -17,11 +17,6 @@ */ class DepthIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -35,12 +30,9 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $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 9916f65a..11151086 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/IsBookmarked.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/IsBookmarked.php @@ -16,13 +16,11 @@ final class IsBookmarked extends CriterionVisitor { - private const SEARCH_FIELD = 'location_bookmarked_user_ids_mid'; + private const string SEARCH_FIELD = 'location_bookmarked_user_ids_mid'; - private PermissionResolver $permissionResolver; - - public function __construct(PermissionResolver $permissionResolver) - { - $this->permissionResolver = $permissionResolver; + public function __construct( + private readonly PermissionResolver $permissionResolver + ) { } public function canVisit(CriterionInterface $criterion): bool @@ -36,7 +34,7 @@ public function canVisit(CriterionInterface $criterion): bool */ public function visit( CriterionInterface $criterion, - CriterionVisitor $subVisitor = null + ?CriterionVisitor $subVisitor = null ): string { if (!is_array($criterion->value)) { throw new LogicException(sprintf( diff --git a/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php b/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php index c74562be..c200a141 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/IsMainLocation.php @@ -16,25 +16,15 @@ */ class IsMainLocation extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ - public function canVisit(CriterionInterface $criterion) + public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Location\IsMainLocation; } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { 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 0e5fe49e..8232ebd6 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/PriorityBetween.php @@ -17,11 +17,6 @@ */ class PriorityBetween extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -36,17 +31,12 @@ public function canVisit(CriterionInterface $criterion): bool } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $start = $criterion->value[0]; - $end = isset($criterion->value[1]) ? $criterion->value[1] : null; + $end = $criterion->value[1] ?? null; if ( ($criterion->operator === Operator::LT) || diff --git a/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php b/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php index 2d8f31ef..77ad3cf7 100644 --- a/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php +++ b/src/lib/Query/Location/CriterionVisitor/Location/PriorityIn.php @@ -17,11 +17,6 @@ */ class PriorityIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -33,14 +28,9 @@ public function canVisit(CriterionInterface $criterion): bool } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { $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 e996ab68..1eb08d8d 100644 --- a/src/lib/Query/Location/CriterionVisitor/LocationIdIn.php +++ b/src/lib/Query/Location/CriterionVisitor/LocationIdIn.php @@ -17,11 +17,6 @@ */ class LocationIdIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -31,22 +26,15 @@ public function canVisit(CriterionInterface $criterion): bool } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'location_id:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'location_id:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php b/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php index 486c3259..56cae1b7 100644 --- a/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php +++ b/src/lib/Query/Location/CriterionVisitor/LocationRemoteIdIn.php @@ -17,11 +17,6 @@ */ class LocationRemoteIdIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -33,22 +28,15 @@ public function canVisit(CriterionInterface $criterion): bool } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'remote_id_id:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'remote_id_id:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php b/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php index bddb4b77..221531a0 100644 --- a/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php +++ b/src/lib/Query/Location/CriterionVisitor/ParentLocationIdIn.php @@ -17,11 +17,6 @@ */ class ParentLocationIdIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -33,22 +28,15 @@ public function canVisit(CriterionInterface $criterion): bool } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function (bool|float|int|string $value): string { - return 'parent_id_id:"' . $value . '"'; - }, + static fn (bool|float|int|string $value): string => 'parent_id_id:"' . $value . '"', $criterion->value ) ) . diff --git a/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php b/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php index d9797bec..2a918822 100644 --- a/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php +++ b/src/lib/Query/Location/CriterionVisitor/SubtreeIn.php @@ -17,11 +17,6 @@ */ class SubtreeIn extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return @@ -35,20 +30,15 @@ public function canVisit(CriterionInterface $criterion): bool /** * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return '(' . implode( ' OR ', array_map( - static function ($value): string { - return 'path_string_id:' . str_replace('/', '\\/', $value) . '*'; - }, + static fn (string $value): string => 'path_string_id:' . str_replace('/', '\\/', $value) . '*', $criterion->value ) ) . diff --git a/src/lib/Query/Location/CriterionVisitor/Visibility.php b/src/lib/Query/Location/CriterionVisitor/Visibility.php index 7984b7ac..fd73eca3 100644 --- a/src/lib/Query/Location/CriterionVisitor/Visibility.php +++ b/src/lib/Query/Location/CriterionVisitor/Visibility.php @@ -17,25 +17,15 @@ */ class Visibility extends CriterionVisitor { - /** - * Check if visitor is applicable to current criterion. - * - * @return bool - */ public function canVisit(CriterionInterface $criterion): bool { return $criterion instanceof Criterion\Visibility && $criterion->operator === Operator::EQ; } /** - * 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(CriterionInterface $criterion, CriterionVisitor $subVisitor = null): string + public function visit(CriterionInterface $criterion, ?CriterionVisitor $subVisitor = null): string { return 'invisible_b:' . ($criterion->value[0] === Criterion\Visibility::HIDDEN ? 'true' : 'false'); } diff --git a/src/lib/Query/Location/SortClauseVisitor/Location/Depth.php b/src/lib/Query/Location/SortClauseVisitor/Location/Depth.php index 29aae684..b0db7600 100644 --- a/src/lib/Query/Location/SortClauseVisitor/Location/Depth.php +++ b/src/lib/Query/Location/SortClauseVisitor/Location/Depth.php @@ -10,26 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Solr\Query\SortClauseVisitor; -/** - * Visits the sortClause tree into a Solr query. - */ class Depth extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Location\Depth; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'depth_i' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Location/SortClauseVisitor/Location/Id.php b/src/lib/Query/Location/SortClauseVisitor/Location/Id.php index e0b196b8..a0d8bd07 100644 --- a/src/lib/Query/Location/SortClauseVisitor/Location/Id.php +++ b/src/lib/Query/Location/SortClauseVisitor/Location/Id.php @@ -10,26 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Solr\Query\SortClauseVisitor; -/** - * Visits the sortClause tree into a Solr query. - */ class Id extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Location\Id; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'location_id_normalized_i' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Location/SortClauseVisitor/Location/IsMainLocation.php b/src/lib/Query/Location/SortClauseVisitor/Location/IsMainLocation.php index be19f908..d27833c1 100644 --- a/src/lib/Query/Location/SortClauseVisitor/Location/IsMainLocation.php +++ b/src/lib/Query/Location/SortClauseVisitor/Location/IsMainLocation.php @@ -10,26 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Solr\Query\SortClauseVisitor; -/** - * Visits the sortClause tree into a Solr query. - */ class IsMainLocation extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Location\IsMainLocation; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'is_main_location_b' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Location/SortClauseVisitor/Location/Path.php b/src/lib/Query/Location/SortClauseVisitor/Location/Path.php index 9a3606ed..7ad766c1 100644 --- a/src/lib/Query/Location/SortClauseVisitor/Location/Path.php +++ b/src/lib/Query/Location/SortClauseVisitor/Location/Path.php @@ -10,26 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Solr\Query\SortClauseVisitor; -/** - * Visits the sortClause tree into a Solr query. - */ class Path extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Location\Path; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'path_string_id' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Location/SortClauseVisitor/Location/Priority.php b/src/lib/Query/Location/SortClauseVisitor/Location/Priority.php index 60f5e4f4..0546496a 100644 --- a/src/lib/Query/Location/SortClauseVisitor/Location/Priority.php +++ b/src/lib/Query/Location/SortClauseVisitor/Location/Priority.php @@ -10,26 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Solr\Query\SortClauseVisitor; -/** - * Visits the sortClause tree into a Solr query. - */ class Priority extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Location\Priority; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'priority_i' . $this->getDirection($sortClause); diff --git a/src/lib/Query/Location/SortClauseVisitor/Location/Visibility.php b/src/lib/Query/Location/SortClauseVisitor/Location/Visibility.php index 2f0d938c..6222c355 100644 --- a/src/lib/Query/Location/SortClauseVisitor/Location/Visibility.php +++ b/src/lib/Query/Location/SortClauseVisitor/Location/Visibility.php @@ -10,26 +10,13 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\SortClause; use Ibexa\Contracts\Solr\Query\SortClauseVisitor; -/** - * Visits the sortClause tree into a Solr query. - */ class Visibility extends SortClauseVisitor { - /** - * Check if visitor is applicable to current sortClause. - * - * @return bool - */ - public function canVisit(SortClause $sortClause) + public function canVisit(SortClause $sortClause): bool { return $sortClause instanceof SortClause\Location\Visibility; } - /** - * Map field value to a proper Solr representation. - * - * @return string - */ public function visit(SortClause $sortClause): string { return 'invisible_b' . $this->getDirection($sortClause); diff --git a/src/lib/Query/QueryConverter.php b/src/lib/Query/QueryConverter.php index 4b887e6a..770029e4 100644 --- a/src/lib/Query/QueryConverter.php +++ b/src/lib/Query/QueryConverter.php @@ -17,12 +17,12 @@ abstract class QueryConverter /** * Map query to a proper Solr representation. * - * @phpstan-param array{languages: string[]} $languageSettings + * @phpstan-param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageSettings * - * @param array $languageSettings - a map of filters for the returned fields. + * @param array $languageSettings - a map of filters for the returned fields. * Currently supported: array("languages" => array(,..)). * - * @return array + * @return array */ - abstract public function convert(Query $query, array $languageSettings = []); + abstract public function convert(Query $query, array $languageSettings = []): array; } diff --git a/src/lib/ResultExtractor.php b/src/lib/ResultExtractor.php index d232e448..e23c1077 100644 --- a/src/lib/ResultExtractor.php +++ b/src/lib/ResultExtractor.php @@ -12,6 +12,7 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchHit; use Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult; use Ibexa\Contracts\Core\Repository\Values\Content\Search\SpellcheckResult; +use Ibexa\Contracts\Core\Repository\Values\ValueObject; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor; use Ibexa\Solr\Gateway\EndpointRegistry; use stdClass; @@ -22,24 +23,17 @@ */ abstract class ResultExtractor { - protected AggregationResultExtractor $aggregationResultExtractor; - - protected EndpointRegistry $endpointRegistry; - public function __construct( - AggregationResultExtractor $aggregationResultExtractor, - EndpointRegistry $endpointRegistry + protected AggregationResultExtractor $aggregationResultExtractor, + protected EndpointRegistry $endpointRegistry ) { - $this->aggregationResultExtractor = $aggregationResultExtractor; - $this->endpointRegistry = $endpointRegistry; } /** * Extracts search result from $data returned by Solr backend. * - * @param \stdClass $data * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation[] $aggregations - * @param array $languageFilter + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter * * @return \Ibexa\Contracts\Core\Repository\Values\Content\Search\SearchResult<\Ibexa\Contracts\Core\Repository\Values\ValueObject> */ @@ -61,7 +55,7 @@ public function extract( $result->spellcheck = $this->extractSpellcheck($data, $spellcheck); foreach ($data->response->docs as $doc) { - $result->searchHits[] = $this->extractSearchHit($doc, $languageFilter); + $result->searchHits[] = $this->extractSearchHit($doc); } return $result; @@ -69,35 +63,48 @@ public function extract( /** * Extracts value object from $hit returned by Solr backend. - * * Needs to be implemented by the concrete ResultExtractor. * - * @param mixed $hit - * - * @return \Ibexa\Contracts\Core\Repository\Values\ValueObject + * @param \stdClass{ + * document_type_id: string, + * content_id_id: int|string, + * content_name_s: string, + * content_type_id_id: int|string, + * content_section_id_id: int|string, + * content_version_no_i: int, + * content_owner_user_id_id: int|string, + * content_modification_date_dt: string, + * content_publication_date_dt: string, + * content_always_available_b: bool, + * content_remote_id_id: string, + * content_main_language_code_s: string, + * main_location_id?: int|string, + * location_id: int|string, + * priority_i: int, + * hidden_b: bool, + * invisible_b: bool, + * remote_id_id: string, + * parent_id_id: int|string, + * path_string_id: string, + * depth_i: int, + * sort_field_id: int|string, + * sort_order_id: int|string + * }&\stdClass $hit */ - abstract public function extractHit($hit); + abstract public function extractHit(stdClass $hit): ValueObject; /** * Returns language code of the Content's translation of the matched document. - * - * @param mixed $hit - * - * @return string */ - protected function getMatchedLanguageCode($hit) + protected function getMatchedLanguageCode(mixed $hit): string { return $hit->meta_indexed_language_code_s; } /** * Returns the identifier of the logical index (shard) of the matched document. - * - * @param mixed $hit - * - * @return string */ - protected function getIndexIdentifier($hit) + protected function getIndexIdentifier(stdClass $hit): string { // In single core setup, shard parameter is not set on request to avoid issues in environments that does not // know about own dns, which means it's not set here either @@ -110,6 +117,7 @@ protected function getIndexIdentifier($hit) /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation[] $aggregations + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter */ protected function extractAggregations( stdClass $data, @@ -132,7 +140,7 @@ protected function extractAggregations( return new AggregationResultCollection($aggregationsResults); } - protected function extractSearchHit(stdClass $doc, array $languageFilter): SearchHit + protected function extractSearchHit(stdClass $doc): SearchHit { return new SearchHit( [ diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php b/src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php index 96014a13..646516f3 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractor.php @@ -14,17 +14,14 @@ use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor; use stdClass; -final class DispatcherAggregationResultExtractor implements AggregationResultExtractor +final readonly class DispatcherAggregationResultExtractor implements AggregationResultExtractor { - /** @var \Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor[] */ - private iterable $extractors; - /** * @param \Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor[] $extractors */ - public function __construct(iterable $extractors) - { - $this->extractors = $extractors; + public function __construct( + private iterable $extractors + ) { } public function canVisit(Aggregation $aggregation, array $languageFilter): bool @@ -38,7 +35,7 @@ public function extract(Aggregation $aggregation, array $languageFilter, stdClas if ($extractor === null) { throw new NotImplementedException( - 'No result extractor available for aggregation: ' . get_class($aggregation) + 'No result extractor available for aggregation: ' . $aggregation::class ); } diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractor.php b/src/lib/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractor.php index aa75c4c0..f89531c3 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractor.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractor.php @@ -13,16 +13,12 @@ use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor; use stdClass; -final class NestedAggregationResultExtractor implements AggregationResultExtractor +final readonly class NestedAggregationResultExtractor implements AggregationResultExtractor { - private AggregationResultExtractor $innerResultExtractor; - - private string $nestedResultKey; - - public function __construct(AggregationResultExtractor $innerResultExtractor, string $nestedResultKey) - { - $this->innerResultExtractor = $innerResultExtractor; - $this->nestedResultKey = $nestedResultKey; + public function __construct( + private AggregationResultExtractor $innerResultExtractor, + private string $nestedResultKey + ) { } public function canVisit(Aggregation $aggregation, array $languageFilter): bool diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php b/src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php index c2366e04..ab46d34d 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractor.php @@ -20,20 +20,16 @@ /** * @phpstan-template TAggregation of \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\AbstractRangeAggregation */ -final class RangeAggregationResultExtractor implements AggregationResultExtractor +final readonly class RangeAggregationResultExtractor implements AggregationResultExtractor { - /** @phpstan-var class-string */ - private string $aggregationClass; - - private RangeAggregationKeyMapper $keyMapper; - /** * @phpstan-param class-string $aggregationClass */ - public function __construct(string $aggregationClass, RangeAggregationKeyMapper $keyMapper) - { - $this->aggregationClass = $aggregationClass; - $this->keyMapper = $keyMapper; + public function __construct( + /** @phpstan-var class-string */ + private string $aggregationClass, + private RangeAggregationKeyMapper $keyMapper + ) { } /** @@ -52,7 +48,7 @@ public function extract(Aggregation $aggregation, array $languageFilter, stdClas $entries = []; foreach ($data as $key => $bucket) { - if ($key === 'count' || strpos($key, '_') === false) { + if ($key === 'count' || !str_contains($key, '_')) { continue; } @@ -84,12 +80,7 @@ private function sort(AbstractRangeAggregation $aggregation, array &$entries): v { $order = $aggregation->getRanges(); - $comparator = static function ( - RangeAggregationResultEntry $a, - RangeAggregationResultEntry $b - ) use ($order): int { - return array_search($a->getKey(), $order) <=> array_search($b->getKey(), $order); - }; + $comparator = (static fn (RangeAggregationResultEntry $a, RangeAggregationResultEntry $b): int => array_search($a->getKey(), $order) <=> array_search($b->getKey(), $order)); usort($entries, $comparator); } diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractor.php b/src/lib/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractor.php index 9653e12b..67cd4b54 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractor.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractor.php @@ -14,13 +14,11 @@ use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor; use stdClass; -final class StatsAggregationResultExtractor implements AggregationResultExtractor +final readonly class StatsAggregationResultExtractor implements AggregationResultExtractor { - private string $aggregationClass; - - public function __construct(string $aggregationClass) - { - $this->aggregationClass = $aggregationClass; + public function __construct( + private string $aggregationClass + ) { } public function canVisit(Aggregation $aggregation, array $languageFilter): bool diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapper.php index a2f6ffa1..49f972db 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapper.php @@ -21,7 +21,7 @@ public function map(Aggregation $aggregation, array $languageFilter, array $keys { $results = []; foreach ($keys as $key) { - $properties = json_decode($key, true); + $properties = json_decode((string) $key, true); if ($properties !== false) { $results[$key] = new Author($properties); } diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapper.php index 66629e8f..8befcfc6 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapper.php @@ -12,19 +12,15 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class ContentTypeAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class ContentTypeAggregationKeyMapper implements TermAggregationKeyMapper { - private ContentTypeService $contentTypeService; - - public function __construct(ContentTypeService $contentTypeService) - { - $this->contentTypeService = $contentTypeService; + public function __construct( + private ContentTypeService $contentTypeService + ) { } /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\ContentTypeTermAggregation $aggregation - * @param array $languageFilter - * @param string[] $keys * * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType[] */ diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapper.php index d7df75df..9a49ad8b 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapper.php @@ -13,18 +13,15 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class ContentTypeGroupAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class ContentTypeGroupAggregationKeyMapper implements TermAggregationKeyMapper { - private ContentTypeService $contentTypeService; - - public function __construct(ContentTypeService $contentTypeService) - { - $this->contentTypeService = $contentTypeService; + public function __construct( + private ContentTypeService $contentTypeService + ) { } /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\ContentTypeGroupTermAggregation $aggregation - * @param string[] $keys * * @return \Ibexa\Contracts\Core\Repository\Values\ContentType\ContentTypeGroup[] */ @@ -35,7 +32,7 @@ public function map(Aggregation $aggregation, array $languageFilter, array $keys foreach ($keys as $key) { try { $result[$key] = $this->contentTypeService->loadContentTypeGroup((int)$key); - } catch (NotFoundException $e) { + } catch (NotFoundException) { // Skip missing content type groups } } diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php index 6c934918..fd7eb7ef 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapper.php @@ -12,16 +12,14 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\Field\CountryTermAggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class CountryAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class CountryAggregationKeyMapper implements TermAggregationKeyMapper { - private array $countriesInfo; - /** - * @param array $countriesInfo Array of countries data + * @param array $countriesInfo Array of countries data */ - public function __construct(array $countriesInfo) - { - $this->countriesInfo = $countriesInfo; + public function __construct( + private array $countriesInfo + ) { } /** @@ -45,18 +43,13 @@ private function mapKey(Aggregation $aggregation, int $key): ?string return null; } - switch ($aggregation->getType()) { - case CountryTermAggregation::TYPE_NAME: - return $countryInfo['Name']; - case CountryTermAggregation::TYPE_IDC: - return $countryInfo['IDC']; - case CountryTermAggregation::TYPE_ALPHA_2: - return $countryInfo['Alpha2']; - case CountryTermAggregation::TYPE_ALPHA_3: - return $countryInfo['Alpha3']; - default: - return null; - } + return match ($aggregation->getType()) { + CountryTermAggregation::TYPE_NAME => $countryInfo['Name'], + CountryTermAggregation::TYPE_IDC => $countryInfo['IDC'], + CountryTermAggregation::TYPE_ALPHA_2 => $countryInfo['Alpha2'], + CountryTermAggregation::TYPE_ALPHA_3 => $countryInfo['Alpha3'], + default => null, + }; } private function findCountryInfoByIDC(int $idc): ?array diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapper.php index 2398a294..164ad39e 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapper.php @@ -12,13 +12,11 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class LanguageAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class LanguageAggregationKeyMapper implements TermAggregationKeyMapper { - private LanguageService $languageService; - - public function __construct(LanguageService $languageService) - { - $this->languageService = $languageService; + public function __construct( + private LanguageService $languageService + ) { } public function map(Aggregation $aggregation, array $languageFilter, array $keys): array diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapper.php index 222ee111..0c2312f6 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapper.php @@ -12,13 +12,11 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class LocationAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class LocationAggregationKeyMapper implements TermAggregationKeyMapper { - private LocationService $locationService; - - public function __construct(LocationService $locationService) - { - $this->locationService = $locationService; + public function __construct( + private LocationService $locationService + ) { } public function map(Aggregation $aggregation, array $languageFilter, array $keys): array diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapper.php index 09231a9f..15147d2e 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapper.php @@ -13,13 +13,11 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class ObjectStateAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class ObjectStateAggregationKeyMapper implements TermAggregationKeyMapper { - private ObjectStateService $objectStateService; - - public function __construct(ObjectStateService $objectStateService) - { - $this->objectStateService = $objectStateService; + public function __construct( + private ObjectStateService $objectStateService + ) { } /** @@ -33,14 +31,14 @@ public function map(Aggregation $aggregation, array $languageFilter, array $keys $mapped = []; foreach ($keys as $key) { - list(, $stateIdentifier) = explode(':', $key, 2); + [, $stateIdentifier] = explode(':', (string) $key, 2); try { $mapped[$key] = $this->objectStateService->loadObjectStateByIdentifier( $objectStateGroup, $stateIdentifier ); - } catch (NotFoundException $e) { + } catch (NotFoundException) { // Skip non-existing object states } } diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapper.php index af4083fb..c5cedeff 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapper.php @@ -14,19 +14,15 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class SectionAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class SectionAggregationKeyMapper implements TermAggregationKeyMapper { - private SectionService $sectionService; - - public function __construct(SectionService $sectionService) - { - $this->sectionService = $sectionService; + public function __construct( + private SectionService $sectionService + ) { } /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\SectionTermAggregation $aggregation - * @param array $languageFilter - * @param string[] $keys * * @return \Ibexa\Contracts\Core\Repository\Values\Content\Section[] */ @@ -36,7 +32,7 @@ public function map(Aggregation $aggregation, array $languageFilter, array $keys foreach ($keys as $key) { try { $result[$key] = $this->sectionService->loadSection((int)$key); - } catch (NotFoundException | UnauthorizedException $e) { + } catch (NotFoundException | UnauthorizedException) { // Skip missing section } } diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php index 35cb0c5e..05128eb5 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapper.php @@ -11,13 +11,11 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; -final class SubtreeAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class SubtreeAggregationKeyMapper implements TermAggregationKeyMapper { - private TermAggregationKeyMapper $locationAggregationKeyMapper; - - public function __construct(TermAggregationKeyMapper $locationAggregationKeyMapper) - { - $this->locationAggregationKeyMapper = $locationAggregationKeyMapper; + public function __construct( + private TermAggregationKeyMapper $locationAggregationKeyMapper + ) { } /** @@ -26,13 +24,14 @@ public function __construct(TermAggregationKeyMapper $locationAggregationKeyMapp public function map(Aggregation $aggregation, array $languageFilter, array $keys): array { $ancestors = $this->getAncestors($aggregation->getPathString()); - $keys = array_filter($keys, static function ($key) use ($ancestors): bool { - return !in_array($key, $ancestors); - }); + $keys = array_filter($keys, static fn ($key): bool => !in_array($key, $ancestors)); return $this->locationAggregationKeyMapper->map($aggregation, $languageFilter, array_values($keys)); } + /** + * @return list + */ private function getAncestors(string $pathString): array { $ancestors = explode('/', trim($pathString, '/')); diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapper.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapper.php index bef6a1b1..e997f97e 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapper.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapper.php @@ -16,18 +16,15 @@ use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper; use InvalidArgumentException; -final class UserMetadataAggregationKeyMapper implements TermAggregationKeyMapper +final readonly class UserMetadataAggregationKeyMapper implements TermAggregationKeyMapper { - private UserService $userService; - - public function __construct(UserService $userService) - { - $this->userService = $userService; + public function __construct( + private UserService $userService + ) { } /** * @param \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation\UserMetadataTermAggregation $aggregation - * @param string[] $keys * * @return \Ibexa\Contracts\Core\Repository\Values\User\User[] */ @@ -39,7 +36,7 @@ public function map(Aggregation $aggregation, array $languageFilter, array $keys foreach ($keys as $key) { try { $results[$key] = $loader((int)$key); - } catch (NotFoundException | UnauthorizedException $e) { + } catch (NotFoundException | UnauthorizedException) { // Skip missing users / user groups } } @@ -50,20 +47,17 @@ public function map(Aggregation $aggregation, array $languageFilter, array $keys private function resolveKeyLoader(Aggregation $aggregation): callable { $type = $aggregation->getType(); - switch ($type) { - case UserMetadataTermAggregation::OWNER: - case UserMetadataTermAggregation::MODIFIER: - return [$this->userService, 'loadUser']; - case UserMetadataTermAggregation::GROUP: - return [$this->userService, 'loadUserGroup']; - } - throw new InvalidArgumentException(sprintf( - 'Expected one of: "%s". Received "%s"', - implode('", "', [ - UserMetadataTermAggregation::OWNER, UserMetadataTermAggregation::MODIFIER, UserMetadataTermAggregation::GROUP, - ]), - $type, - )); + return match ($type) { + UserMetadataTermAggregation::OWNER, UserMetadataTermAggregation::MODIFIER => $this->userService->loadUser(...), + UserMetadataTermAggregation::GROUP => $this->userService->loadUserGroup(...), + default => throw new InvalidArgumentException(sprintf( + 'Expected one of: "%s". Received "%s"', + implode('", "', [ + UserMetadataTermAggregation::OWNER, UserMetadataTermAggregation::MODIFIER, UserMetadataTermAggregation::GROUP, + ]), + $type, + )), + }; } } diff --git a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractor.php b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractor.php index 06ac70e4..5fe6d4b5 100644 --- a/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractor.php +++ b/src/lib/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractor.php @@ -17,20 +17,19 @@ use Ibexa\Solr\ResultExtractor\AggregationResultExtractor\TermAggregationKeyMapper\NullAggregationKeyMapper; use stdClass; -final class TermAggregationResultExtractor implements AggregationResultExtractor +final readonly class TermAggregationResultExtractor implements AggregationResultExtractor { private TermAggregationKeyMapper $keyMapper; - private string $aggregationClass; - - public function __construct(string $aggregationClass, TermAggregationKeyMapper $keyMapper = null) - { + public function __construct( + private string $aggregationClass, + TermAggregationKeyMapper $keyMapper = null + ) { if ($keyMapper === null) { $keyMapper = new NullAggregationKeyMapper(); } $this->keyMapper = $keyMapper; - $this->aggregationClass = $aggregationClass; } public function canVisit(Aggregation $aggregation, array $languageFilter): bool @@ -64,6 +63,9 @@ public function extract(Aggregation $aggregation, array $languageFilter, stdClas return new TermAggregationResult($aggregation->getName(), $entries); } + /** + * @return list + */ private function getKeys(stdClass $data): array { $keys = []; diff --git a/src/lib/ResultExtractor/LoadingResultExtractor.php b/src/lib/ResultExtractor/LoadingResultExtractor.php index cd013758..1bd2d47d 100644 --- a/src/lib/ResultExtractor/LoadingResultExtractor.php +++ b/src/lib/ResultExtractor/LoadingResultExtractor.php @@ -8,12 +8,13 @@ namespace Ibexa\Solr\ResultExtractor; use Ibexa\Contracts\Core\Persistence\Content\Handler; -use Ibexa\Contracts\Core\Persistence\Content\Handler as ContentHandler; use Ibexa\Contracts\Core\Persistence\Content\Location\Handler as LocationHandler; +use Ibexa\Contracts\Core\Repository\Values\ValueObject; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor; use Ibexa\Solr\Gateway\EndpointRegistry; use Ibexa\Solr\ResultExtractor; use RuntimeException; +use stdClass; /** * The Loading Result Extractor extracts the value object from the Solr search hit data @@ -21,38 +22,20 @@ */ class LoadingResultExtractor extends ResultExtractor { - /** - * Content handler. - */ - protected Handler $contentHandler; - - /** - * Location handler. - */ - protected LocationHandler $locationHandler; - public function __construct( - ContentHandler $contentHandler, - LocationHandler $locationHandler, - AggregationResultExtractor $aggregationResultExtractor, - EndpointRegistry $endpointRegistry + protected readonly Handler $contentHandler, + protected readonly LocationHandler $locationHandler, + protected AggregationResultExtractor $aggregationResultExtractor, + protected EndpointRegistry $endpointRegistry ) { - $this->contentHandler = $contentHandler; - $this->locationHandler = $locationHandler; - parent::__construct($aggregationResultExtractor, $endpointRegistry); } /** - * Extracts value object from $hit returned by Solr backend. - * - * @throws \RuntimeException If search $hit could not be handled - * - * @param mixed $hit - * - * @return \Ibexa\Contracts\Core\Repository\Values\ValueObject + * @throws \RuntimeException + * @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException */ - public function extractHit($hit) + public function extractHit(stdClass $hit): ValueObject { if ($hit->document_type_id === 'content') { return $this->contentHandler->loadContentInfo($hit->content_id_id); diff --git a/src/lib/ResultExtractor/NativeResultExtractor.php b/src/lib/ResultExtractor/NativeResultExtractor.php index 539d9466..47ee5fd7 100644 --- a/src/lib/ResultExtractor/NativeResultExtractor.php +++ b/src/lib/ResultExtractor/NativeResultExtractor.php @@ -11,6 +11,7 @@ use Ibexa\Contracts\Core\Persistence\Content\Location; use Ibexa\Solr\ResultExtractor; use RuntimeException; +use stdClass; /** * The Native Result Extractor extracts the value object from the data @@ -19,15 +20,9 @@ class NativeResultExtractor extends ResultExtractor { /** - * Extracts value object from $hit returned by Solr backend. - * - * @throws \RuntimeException If search $hit could not be handled - * - * @param mixed $hit - * - * @return \Ibexa\Contracts\Core\Repository\Values\ValueObject + * @throws \RuntimeException */ - public function extractHit($hit) + public function extractHit(stdClass $hit): ContentInfo|Location { if ($hit->document_type_id === 'content') { return $this->extractContentInfoFromHit($hit); @@ -41,11 +36,23 @@ public function extractHit($hit) } /** - * @param mixed $hit - * - * @return \Ibexa\Contracts\Core\Persistence\Content\ContentInfo + * @param object{ + * document_type_id: string, + * content_id_id: int|string, + * content_name_s: string, + * content_type_id_id: int|string, + * content_section_id_id: int|string, + * content_version_no_i: int, + * content_owner_user_id_id: int|string, + * content_modification_date_dt: string, + * content_publication_date_dt: string, + * content_always_available_b: bool, + * content_remote_id_id: string, + * content_main_language_code_s: string, + * main_location_id?: int|string + * }&\stdClass $hit */ - protected function extractContentInfoFromHit($hit): ContentInfo + protected function extractContentInfoFromHit(stdClass $hit): ContentInfo { $contentInfo = new ContentInfo( [ @@ -55,8 +62,8 @@ protected function extractContentInfoFromHit($hit): ContentInfo 'sectionId' => (int)$hit->content_section_id_id, 'currentVersionNo' => $hit->content_version_no_i, 'ownerId' => (int)$hit->content_owner_user_id_id, - 'modificationDate' => strtotime($hit->content_modification_date_dt), - 'publicationDate' => strtotime($hit->content_publication_date_dt), + 'modificationDate' => strtotime((string) $hit->content_modification_date_dt), + 'publicationDate' => strtotime((string) $hit->content_publication_date_dt), 'alwaysAvailable' => $hit->content_always_available_b, 'remoteId' => $hit->content_remote_id_id, 'mainLanguageCode' => $hit->content_main_language_code_s, @@ -72,11 +79,21 @@ protected function extractContentInfoFromHit($hit): ContentInfo } /** - * @param mixed $hit - * - * @return \Ibexa\Contracts\Core\Persistence\Content\Location + * @param object{ + * location_id: int|string, + * priority_i: int, + * hidden_b: bool, + * invisible_b: bool, + * remote_id_id: string, + * content_id_id: int|string, + * parent_id_id: int|string, + * path_string_id: string, + * depth_i: int, + * sort_field_id: int|string, + * sort_order_id: int|string + * }&\stdClass $hit */ - protected function extractLocationFromHit($hit): Location + protected function extractLocationFromHit(stdClass $hit): Location { return new Location( [ diff --git a/src/lib/Test/SolrTestContainerBuilder.php b/src/lib/Test/SolrTestContainerBuilder.php index 928e3f7b..bc2d48cf 100644 --- a/src/lib/Test/SolrTestContainerBuilder.php +++ b/src/lib/Test/SolrTestContainerBuilder.php @@ -20,7 +20,7 @@ */ final class SolrTestContainerBuilder { - public const CONFIGURATION_FILES_MAP = [ + public const array CONFIGURATION_FILES_MAP = [ SearchServiceTranslationLanguageFallbackTest::SETUP_DEDICATED => 'multicore_dedicated.yml', SearchServiceTranslationLanguageFallbackTest::SETUP_SHARED => 'multicore_shared.yml', SearchServiceTranslationLanguageFallbackTest::SETUP_SINGLE => 'single_core.yml', diff --git a/tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php b/tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php index 60996a32..a280a094 100644 --- a/tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php +++ b/tests/bundle/DependencyInjection/IbexaSolrExtensionExtensionTest.php @@ -17,11 +17,9 @@ */ class IbexaSolrExtensionExtensionTest extends AbstractExtensionTestCase { - /** - * @var \Ibexa\Bundle\Solr\DependencyInjection\IbexaSolrExtension - */ private IbexaSolrExtension $extension; + #[\Override] protected function setUp(): void { $this->extension = new IbexaSolrExtension(); @@ -40,6 +38,7 @@ protected function getContainerExtensions(): array /** * @return array */ + #[\Override] protected function getMinimalConfiguration(): array { return []; @@ -141,7 +140,6 @@ public function dataProviderForTestEndpoint(): array /** * @dataProvider dataProviderForTestEndpoint * - * @param string $endpointName * @param array $endpointValues * @param array $expectedArgument */ @@ -218,8 +216,6 @@ public function dataProviderForTestConnection(): array } /** - * @param array $configurationValues - * * @dataProvider dataProviderForTestConnection */ public function testConnectionLoad(array $configurationValues): void diff --git a/tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php b/tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php index 4a515c49..5a23546d 100644 --- a/tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php +++ b/tests/bundle/Gateway/UpdateSerializer/JsonUpdateSerializerTest.php @@ -22,7 +22,7 @@ */ class JsonUpdateSerializerTest extends TestCase { - public const FIELD_NAME_GENERATOR_MAP = [ + public const array FIELD_NAME_GENERATOR_MAP = [ 'ez_integer' => 'i', 'ez_minteger' => 'mi', 'ez_id' => 'id', @@ -37,7 +37,6 @@ class JsonUpdateSerializerTest extends TestCase 'ez_fulltext' => 'fulltext', ]; - /** @var \Ibexa\Solr\Gateway\UpdateSerializer\JsonUpdateSerializer */ private JsonUpdateSerializer $serializer; public function getDataForTestSerialize(): iterable diff --git a/tests/lib/Container/Compiler/AggregateCriterionVisitorPassTest.php b/tests/lib/Container/Compiler/AggregateCriterionVisitorPassTest.php index 43068f7f..ebf94b70 100644 --- a/tests/lib/Container/Compiler/AggregateCriterionVisitorPassTest.php +++ b/tests/lib/Container/Compiler/AggregateCriterionVisitorPassTest.php @@ -15,6 +15,7 @@ class AggregateCriterionVisitorPassTest extends AbstractCompilerPassTestCase { + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Container/Compiler/AggregateSortClauseVisitorPassTest.php b/tests/lib/Container/Compiler/AggregateSortClauseVisitorPassTest.php index 5c29f428..311d0992 100644 --- a/tests/lib/Container/Compiler/AggregateSortClauseVisitorPassTest.php +++ b/tests/lib/Container/Compiler/AggregateSortClauseVisitorPassTest.php @@ -15,6 +15,7 @@ class AggregateSortClauseVisitorPassTest extends AbstractCompilerPassTestCase { + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Container/Compiler/CoreFilterRegistryPassTest.php b/tests/lib/Container/Compiler/CoreFilterRegistryPassTest.php index 2db5312b..fbaf439c 100644 --- a/tests/lib/Container/Compiler/CoreFilterRegistryPassTest.php +++ b/tests/lib/Container/Compiler/CoreFilterRegistryPassTest.php @@ -16,6 +16,7 @@ class CoreFilterRegistryPassTest extends AbstractCompilerPassTestCase { + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Container/Compiler/GatewayRegistryPassTest.php b/tests/lib/Container/Compiler/GatewayRegistryPassTest.php index fdaba19f..3a2d2a1a 100644 --- a/tests/lib/Container/Compiler/GatewayRegistryPassTest.php +++ b/tests/lib/Container/Compiler/GatewayRegistryPassTest.php @@ -16,6 +16,7 @@ class GatewayRegistryPassTest extends AbstractCompilerPassTestCase { + #[\Override] protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/CoreFilter/CoreFilterRegistryTest.php b/tests/lib/CoreFilter/CoreFilterRegistryTest.php index 1a99ea37..2cbdc336 100644 --- a/tests/lib/CoreFilter/CoreFilterRegistryTest.php +++ b/tests/lib/CoreFilter/CoreFilterRegistryTest.php @@ -10,6 +10,7 @@ use Ibexa\Solr\CoreFilter; use Ibexa\Solr\CoreFilter\CoreFilterRegistry; use OutOfBoundsException; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class CoreFilterRegistryTest extends TestCase @@ -79,10 +80,7 @@ public function testGetCoreFilters(): void self::assertCount(1, $registry->getCoreFilters()); } - /** - * @return \Ibexa\Solr\CoreFilter|\PHPUnit\Framework\MockObject\MockObject - */ - private function getCoreFilterMock(): CoreFilter + private function getCoreFilterMock(): CoreFilter&MockObject { return $this->createMock(CoreFilter::class); } diff --git a/tests/lib/Gateway/GatewayRegistryTest.php b/tests/lib/Gateway/GatewayRegistryTest.php index 0ee87f69..89b7be51 100644 --- a/tests/lib/Gateway/GatewayRegistryTest.php +++ b/tests/lib/Gateway/GatewayRegistryTest.php @@ -10,6 +10,7 @@ use Ibexa\Solr\Gateway; use Ibexa\Solr\Gateway\GatewayRegistry; use OutOfBoundsException; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class GatewayRegistryTest extends TestCase @@ -81,10 +82,7 @@ public function testGetGateways(): void self::assertCount(1, $registry->getGateways()); } - /** - * @return \Ibexa\Solr\Gateway|\PHPUnit\Framework\MockObject\MockObject - */ - private function getGatewayMock(): Gateway + private function getGatewayMock(): Gateway&MockObject { return $this->createMock(Gateway::class); } diff --git a/tests/lib/Gateway/UpdateSerializerFactoryTest.php b/tests/lib/Gateway/UpdateSerializerFactoryTest.php index d5de1af5..0b83a3a9 100644 --- a/tests/lib/Gateway/UpdateSerializerFactoryTest.php +++ b/tests/lib/Gateway/UpdateSerializerFactoryTest.php @@ -18,8 +18,8 @@ */ final class UpdateSerializerFactoryTest extends TestCase { - private const FORMAT_FOO = 'foo'; - private const FORMAT_BAR = 'bar'; + private const string FORMAT_FOO = 'foo'; + private const string FORMAT_BAR = 'bar'; /** * @dataProvider getDataForTestGetSerializer @@ -52,6 +52,13 @@ public function testGetSerializerThrowsInvalidArgumentException(): void $factory->getSerializer(self::FORMAT_BAR); } + /** + * @return iterable, + * 1: \Ibexa\Solr\Gateway\UpdateSerializerInterface, + * 2: string + * }> + */ public function getDataForTestGetSerializer(): iterable { $fooSerializerMock = $this->createMock(UpdateSerializerInterface::class); diff --git a/tests/lib/Search/FieldMapper/BoostFactorProviderTest.php b/tests/lib/Search/FieldMapper/BoostFactorProviderTest.php index 937d1127..8ad022fc 100644 --- a/tests/lib/Search/FieldMapper/BoostFactorProviderTest.php +++ b/tests/lib/Search/FieldMapper/BoostFactorProviderTest.php @@ -115,9 +115,7 @@ public function providerForTestGetContentFieldBoostFactor(): array /** * @dataProvider providerForTestGetContentFieldBoostFactor * - * @param string $contentTypeIdentifier - * @param string $fieldDefinitionIdentifier - * @param float $expectedBoostFactor + * @param array{meta-fields: array>} $map */ public function testGetContentFieldBoostFactor( array $map, @@ -244,9 +242,7 @@ public function providerForTestGetContentMetaFieldBoostFactor(): array /** * @dataProvider providerForTestGetContentMetaFieldBoostFactor * - * @param string $contentTypeIdentifier - * @param string $fieldName - * @param float $expectedBoostFactor + * @param array{meta-fields: array>} $map */ public function testGetContentMetaFieldBoostFactor( array $map, @@ -264,12 +260,15 @@ public function testGetContentMetaFieldBoostFactor( self::assertEquals($expectedBoostFactor, $boostFactor); } + /** + * @param array{meta-fields: array>} $map + */ protected function getFieldBoostProvider(array $map): BoostFactorProvider { return new BoostFactorProvider($map); } - protected function getContentTypeStub($identifier): Type + protected function getContentTypeStub(string $identifier): Type { return new SPIContentType( [ @@ -278,7 +277,7 @@ protected function getContentTypeStub($identifier): Type ); } - protected function getFieldDefinitionStub($identifier): FieldDefinition + protected function getFieldDefinitionStub(string $identifier): FieldDefinition { return new SPIFieldDefinition( [ diff --git a/tests/lib/Search/Gateway/DistributionStrategy/CloudDistributionStrategyTest.php b/tests/lib/Search/Gateway/DistributionStrategy/CloudDistributionStrategyTest.php index 2a3cc24a..7faffc1a 100644 --- a/tests/lib/Search/Gateway/DistributionStrategy/CloudDistributionStrategyTest.php +++ b/tests/lib/Search/Gateway/DistributionStrategy/CloudDistributionStrategyTest.php @@ -17,14 +17,11 @@ class CloudDistributionStrategyTest extends TestCase { - /** @var \Ibexa\Solr\Gateway\DistributionStrategy\CloudDistributionStrategy */ private CloudDistributionStrategy $distributionStrategy; - /** @var \Ibexa\Solr\Gateway\EndpointResolver|\PHPUnit\Framework\MockObject\MockObject */ - private MockObject $endpointResolver; + private EndpointResolver&MockObject $endpointResolver; - /** @var \Ibexa\Solr\Gateway\EndpointRegistry|\PHPUnit\Framework\MockObject\MockObject */ - private MockObject $endpointRegistry; + private EndpointRegistry&MockObject $endpointRegistry; protected function setUp(): void { @@ -33,11 +30,9 @@ protected function setUp(): void $this->endpointRegistry = $this->createMock(EndpointRegistry::class); $this->endpointRegistry ->method('getEndpoint') - ->willReturnCallback(static function (string $name): Endpoint { - return new Endpoint([ - 'core' => 'collection_' . $name, - ]); - }); + ->willReturnCallback(static fn (string $name): Endpoint => new Endpoint([ + 'core' => 'collection_' . $name, + ])); $this->distributionStrategy = new CloudDistributionStrategy( $this->endpointRegistry, diff --git a/tests/lib/Search/Gateway/DistributionStrategy/StandaloneDistributionStrategyTest.php b/tests/lib/Search/Gateway/DistributionStrategy/StandaloneDistributionStrategyTest.php index 48c7bfc0..cc5cb22b 100644 --- a/tests/lib/Search/Gateway/DistributionStrategy/StandaloneDistributionStrategyTest.php +++ b/tests/lib/Search/Gateway/DistributionStrategy/StandaloneDistributionStrategyTest.php @@ -17,22 +17,17 @@ class StandaloneDistributionStrategyTest extends TestCase { - /** @var \Ibexa\Solr\Gateway\DistributionStrategy\StandaloneDistributionStrategy */ private StandaloneDistributionStrategy $distributionStrategy; - /** @var \Ibexa\Solr\Gateway\EndpointRegistry|\PHPUnit\Framework\MockObject\MockObject */ - private MockObject $endpointRegistry; - - /** @var \Ibexa\Solr\Gateway\EndpointResolver|\PHPUnit\Framework\MockObject\MockObject */ - private MockObject $endpointResolver; + private EndpointResolver&MockObject $endpointResolver; protected function setUp(): void { - $this->endpointRegistry = $this->createEndpointRegistry(); + $endpointRegistry = $this->createEndpointRegistry(); $this->endpointResolver = $this->createMock(EndpointResolver::class); $this->distributionStrategy = new StandaloneDistributionStrategy( - $this->endpointRegistry, + $endpointRegistry, $this->endpointResolver ); } @@ -80,7 +75,7 @@ public function testGetSearchParametersWithLanguageSettings(): void ], $this->distributionStrategy->getSearchParameters($parameters, $languagesSettings)); } - private function createEndpointRegistry(): MockObject + private function createEndpointRegistry(): EndpointRegistry&MockObject { $endpointRegistry = $this->createMock(EndpointRegistry::class); $endpointRegistry diff --git a/tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php b/tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php index 1ec690da..5a9636dc 100644 --- a/tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php +++ b/tests/lib/Search/Gateway/EndpointResolver/NativeEndpointResolverTest.php @@ -96,6 +96,19 @@ public function testGetMainLanguagesEndpointReturnsNull(): void self::assertNull($endpointResolver->getMainLanguagesEndpoint()); } + /** + * @return array, + * 1: string|null, + * 2: string|null, + * 3: array{ + * languages?: array, + * useAlwaysAvailable?: bool + * }, + * 4: array, + * 5?: bool + * }> + */ public function providerForTestGetSearchTargets(): array { return [ @@ -800,11 +813,7 @@ public function providerForTestGetSearchTargets(): array * @dataProvider providerForTestGetSearchTargets * * @param string[] $endpointMap - * @param string|null $defaultEndpoint - * @param string|null $mainLanguagesEndpoint - * @param array $languageSettings * @param string[] $expected - * @param bool $expectedIsMultiple */ public function testGetSearchTargets( array $endpointMap, @@ -831,7 +840,16 @@ public function testGetSearchTargets( } /** - * @return array{string[], string|null, string|null, array, string}[] + * @return array, + * 1: string|null, + * 2: string|null, + * 3: array{ + * languages?: array, + * useAlwaysAvailable?: bool + * }, + * 4: string + * }> */ public function providerForTestGetSearchTargetsThrowsRuntimeException(): array { @@ -920,10 +938,6 @@ public function providerForTestGetSearchTargetsThrowsRuntimeException(): array * @dataProvider providerForTestGetSearchTargetsThrowsRuntimeException * * @param string[] $endpointMap - * @param string|null $defaultEndpoint - * @param string|null $mainLanguagesEndpoint - * @param array $languageSettings - * @param string $message */ public function testGetSearchTargetsThrowsRuntimeException( array $endpointMap, @@ -1021,8 +1035,6 @@ public function providerForTestGetEndpoints(): array * @dataProvider providerForTestGetEndpoints * * @param string[] $endpointMap - * @param string|null $defaultEndpoint - * @param string|null $mainLanguagesEndpoint * @param string[] $expected */ public function testGetEndpoints( @@ -1056,11 +1068,17 @@ public function testGetEndpointsThrowsRuntimeException(): void $endpointResolver->getEndpoints(); } + /** + * @dataProvider providerForTestGetEndpoints + * + * @param list $entryEndpoints + * @param array $endpointMap + */ protected function getEndpointResolver( array $entryEndpoints = [], array $endpointMap = [], - $defaultEndpoint = null, - $mainLanguagesEndpoint = null + ?string $defaultEndpoint = null, + ?string $mainLanguagesEndpoint = null ): NativeEndpointResolver { return new NativeEndpointResolver( $entryEndpoints, diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/AbstractAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/AbstractAggregationVisitorTest.php index a6e859fc..8dfa7aab 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/AbstractAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/AbstractAggregationVisitorTest.php @@ -15,15 +15,13 @@ abstract class AbstractAggregationVisitorTest extends TestCase { - protected const EXAMPLE_LANGUAGE_FILTER = [ + protected const array EXAMPLE_LANGUAGE_FILTER = [ 'languages' => ['eng-GB'], ]; - /** @var \Ibexa\Contracts\Solr\Query\AggregationVisitor */ - protected $visitor; + protected AggregationVisitor $visitor; - /** @var \Ibexa\Contracts\Solr\Query\AggregationVisitor|\PHPUnit\Framework\MockObject\MockObject */ - protected MockObject $dispatcherVisitor; + protected AggregationVisitor&MockObject $dispatcherVisitor; protected function setUp(): void { @@ -34,7 +32,7 @@ protected function setUp(): void abstract protected function createVisitor(): AggregationVisitor; /** - * @param array{languages: string[]} $languageFilter + * @param array{languages?: string[], languageCode?: string, useAlwaysAvailable?: bool} $languageFilter * * @dataProvider dataProviderForCanVisit */ @@ -50,10 +48,10 @@ final public function testCanVisit( } /** - * @return iterable */ abstract public function dataProviderForCanVisit(): iterable; @@ -78,11 +76,7 @@ final public function testVisit( } /** - * @return iterable, - * }> + * @return iterable> */ abstract public function dataProviderForVisit(): iterable; diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitorTest.php index 0bc69506..e29a3832 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/DateMetadataRangeAggregationVisitorTest.php @@ -22,10 +22,17 @@ protected function createVisitor(): AggregationVisitor return new DateMetadataRangeAggregationVisitor(); } + /** + * @return iterable + */ public function dataProviderForCanVisit(): iterable { yield 'true' => [ - new DateMetadataRangeAggregation('foo', DateMetadataRangeAggregation::PUBLISHED, []), + new DateMetadataRangeAggregation('foo', DateMetadataRangeAggregation::PUBLISHED, []), self::EXAMPLE_LANGUAGE_FILTER, true, ]; @@ -37,6 +44,20 @@ public function dataProviderForCanVisit(): iterable ]; } + /** + * @return iterable + * } + * }> + */ public function dataProviderForVisit(): iterable { $ranges = [ diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/DispatcherAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/DispatcherAggregationVisitorTest.php index 6600f474..206a5a38 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/DispatcherAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/DispatcherAggregationVisitorTest.php @@ -16,11 +16,11 @@ final class DispatcherAggregationVisitorTest extends TestCase { - private const EXAMPLE_LANGUAGE_FILTER = [ + private const array EXAMPLE_LANGUAGE_FILTER = [ 'languages' => ['eng-GB'], ]; - private const EXAMPLE_VISITOR_RESULT = [ + private const array EXAMPLE_VISITOR_RESULT = [ 'type' => 'terms', 'field' => 'foo', 'limit' => 100, diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/ObjectStateGroupAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/ObjectStateGroupAggregationVisitorTest.php index bb2f2080..111ae9a2 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/ObjectStateGroupAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/ObjectStateGroupAggregationVisitorTest.php @@ -20,6 +20,13 @@ protected function createVisitor(): AggregationVisitor return new ObjectStateAggregationVisitor(); } + /** + * @return iterable + */ public function dataProviderForCanVisit(): iterable { yield 'true' => [ @@ -35,6 +42,19 @@ public function dataProviderForCanVisit(): iterable ]; } + /** + * @return iterable + */ public function dataProviderForVisit(): iterable { yield 'defaults' => [ diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/RangeAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/RangeAggregationVisitorTest.php index 5a6df767..4ba9aae3 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/RangeAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/RangeAggregationVisitorTest.php @@ -18,9 +18,9 @@ final class RangeAggregationVisitorTest extends AbstractAggregationVisitorTest { - /** @var \Ibexa\Contracts\Solr\Query\Common\AggregationVisitor\AggregationFieldResolver|\PHPUnit\Framework\MockObject\MockObject */ - private MockObject $aggregationFieldResolver; + private AggregationFieldResolver&MockObject $aggregationFieldResolver; + #[\Override] protected function setUp(): void { $this->aggregationFieldResolver = $this->createMock(AggregationFieldResolver::class); @@ -37,6 +37,13 @@ protected function createVisitor(): AggregationVisitor return new RangeAggregationVisitor(AbstractRangeAggregation::class, $this->aggregationFieldResolver); } + /** + * @return iterable + */ public function dataProviderForCanVisit(): iterable { yield 'true' => [ @@ -52,6 +59,20 @@ public function dataProviderForCanVisit(): iterable ]; } + /** + * @return iterable + * } + * }> + */ public function dataProviderForVisit(): iterable { $aggregation = $this->createMock(AbstractRangeAggregation::class); diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php index 1f1c628a..222f188e 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/StatsAggregationVisitorTest.php @@ -17,9 +17,9 @@ final class StatsAggregationVisitorTest extends AbstractAggregationVisitorTest { - /** @var \Ibexa\Contracts\Solr\Query\Common\AggregationVisitor\AggregationFieldResolver|\PHPUnit\Framework\MockObject\MockObject */ - private MockObject $aggregationFieldResolver; + private AggregationFieldResolver&MockObject $aggregationFieldResolver; + #[\Override] protected function setUp(): void { $this->aggregationFieldResolver = $this->createMock(AggregationFieldResolver::class); @@ -36,6 +36,13 @@ protected function createVisitor(): AggregationVisitor return new StatsAggregationVisitor(AbstractStatsAggregation::class, $this->aggregationFieldResolver); } + /** + * @return iterable + */ public function dataProviderForCanVisit(): iterable { yield 'true' => [ @@ -51,6 +58,22 @@ public function dataProviderForCanVisit(): iterable ]; } + /** + * @return iterable + */ public function dataProviderForVisit(): iterable { yield [ diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitorTest.php index 1ff31291..a1b721ee 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/SubtreeTermAggregationVisitorTest.php @@ -15,12 +15,19 @@ final class SubtreeTermAggregationVisitorTest extends AbstractAggregationVisitorTest { - private const EXAMPLE_AGGREGATION_NAME = 'custom_aggregation'; - private const EXAMPLE_PATH_STRING = '/1/2/'; + private const string EXAMPLE_AGGREGATION_NAME = 'custom_aggregation'; + private const string EXAMPLE_PATH_STRING = '/1/2/'; - private const EXAMPLE_PATH_STRING_FIELD_NAME = 'path_string_id'; - private const EXAMPLE_LOCATION_ID_FIELD_NAME = 'location_id_id'; + private const string EXAMPLE_PATH_STRING_FIELD_NAME = 'path_string_id'; + private const string EXAMPLE_LOCATION_ID_FIELD_NAME = 'location_id_id'; + /** + * @return iterable + */ public function dataProviderForCanVisit(): iterable { yield 'true' => [ @@ -39,6 +46,24 @@ public function dataProviderForCanVisit(): iterable ]; } + /** + * @return iterable + */ public function dataProviderForVisit(): iterable { yield [ diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/TermAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/TermAggregationVisitorTest.php index 486ffba5..be9a04b8 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/TermAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/TermAggregationVisitorTest.php @@ -19,6 +19,7 @@ final class TermAggregationVisitorTest extends AbstractAggregationVisitorTest { private AggregationFieldResolver&MockObject $aggregationFieldResolver; + #[\Override] protected function setUp(): void { $this->aggregationFieldResolver = $this->createMock(AggregationFieldResolver::class); @@ -35,6 +36,13 @@ protected function createVisitor(): AggregationVisitor return new TermAggregationVisitor(AbstractTermAggregation::class, $this->aggregationFieldResolver); } + /** + * @return iterable + */ public function dataProviderForCanVisit(): iterable { yield 'true' => [ @@ -50,6 +58,18 @@ public function dataProviderForCanVisit(): iterable ]; } + /** + * @return iterable>, + * 2: array{ + * type: string, + * field: string, + * limit: int, + * mincount: int + * } + * }> + */ public function dataProviderForVisit(): iterable { $aggregation = $this->createMock(AbstractTermAggregation::class); diff --git a/tests/lib/Search/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitorTest.php b/tests/lib/Search/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitorTest.php index 424262cd..b48034e4 100644 --- a/tests/lib/Search/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitorTest.php +++ b/tests/lib/Search/Query/Common/AggregationVisitor/UserMetadataTermAggregationVisitorTest.php @@ -20,6 +20,13 @@ protected function createVisitor(): AggregationVisitor return new UserMetadataTermAggregationVisitor(); } + /** + * @return iterable + */ public function dataProviderForCanVisit(): iterable { yield 'true' => [ @@ -35,6 +42,18 @@ public function dataProviderForCanVisit(): iterable ]; } + /** + * @return iterable + */ public function dataProviderForVisit(): iterable { yield UserMetadataTermAggregation::OWNER => [ diff --git a/tests/lib/Search/Query/Common/CriterionVisitor/IsUserEnabledTest.php b/tests/lib/Search/Query/Common/CriterionVisitor/IsUserEnabledTest.php index 378dd30f..d0d2215a 100644 --- a/tests/lib/Search/Query/Common/CriterionVisitor/IsUserEnabledTest.php +++ b/tests/lib/Search/Query/Common/CriterionVisitor/IsUserEnabledTest.php @@ -35,6 +35,12 @@ protected function getSupportedCriterion(): Criterion return new Criterion\IsUserEnabled(); } + /** + * @return iterable + */ protected function provideDataForTestVisit(): iterable { yield 'Query for enabled user' => [ diff --git a/tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php b/tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php index 90baba1b..8c65e0c6 100644 --- a/tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php +++ b/tests/lib/Search/Query/Content/CriterionVisitor/FullTextTest.php @@ -27,6 +27,9 @@ */ class FullTextTest extends TestCase { + /** + * @param array $fieldTypes + */ protected function getFullTextCriterionVisitor(array $fieldTypes = [], int $maxDepth = 0): FullText { $fieldNameResolver = $this->getMockBuilder(FieldNameResolver::class) @@ -55,9 +58,6 @@ protected function getFullTextCriterionVisitor(array $fieldTypes = [], int $maxD ); } - /** - * @return \QueryTranslator\Languages\Galach\Tokenizer - */ protected function getTokenizer(): Tokenizer { return new Tokenizer( @@ -65,17 +65,11 @@ protected function getTokenizer(): Tokenizer ); } - /** - * @return \QueryTranslator\Languages\Galach\Parser - */ protected function getParser(): Parser { return new Parser(); } - /** - * @return \QueryTranslator\Languages\Galach\Generators\ExtendedDisMax - */ protected function getGenerator(): ExtendedDisMax { return new ExtendedDisMax( diff --git a/tests/lib/Search/Query/Location/CriterionVisitor/Location/IsBookmarkedTest.php b/tests/lib/Search/Query/Location/CriterionVisitor/Location/IsBookmarkedTest.php index 8066f670..878e2721 100644 --- a/tests/lib/Search/Query/Location/CriterionVisitor/Location/IsBookmarkedTest.php +++ b/tests/lib/Search/Query/Location/CriterionVisitor/Location/IsBookmarkedTest.php @@ -14,18 +14,18 @@ use Ibexa\Core\Repository\Values\User\UserReference; use Ibexa\Solr\Query\Location\CriterionVisitor\Location\IsBookmarked; use Ibexa\Tests\Solr\Search\Query\BaseCriterionVisitorTestCase; +use PHPUnit\Framework\MockObject\MockObject; /** * @covers \Ibexa\Solr\Query\Location\CriterionVisitor\Location\IsBookmarked */ final class IsBookmarkedTest extends BaseCriterionVisitorTestCase { - private const USER_ID = 123; + private const int USER_ID = 123; private CriterionVisitor $visitor; - /** @var \Ibexa\Contracts\Core\Repository\PermissionResolver&\PHPUnit\Framework\MockObject\MockObject */ - private PermissionResolver $permissionResolver; + private PermissionResolver&MockObject $permissionResolver; protected function setUp(): void { @@ -36,6 +36,7 @@ protected function setUp(): void /** * @dataProvider provideDataForTestVisit */ + #[\Override] public function testVisit( string $expectedQuery, Criterion $criterion diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php index 7f6732fa..60899dba 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AbstractAggregationResultExtractorTest.php @@ -16,11 +16,10 @@ abstract class AbstractAggregationResultExtractorTest extends TestCase { - protected const EXAMPLE_AGGREGATION_NAME = 'custom_aggregation'; - protected const EXAMPLE_LANGUAGE_FILTER = []; + protected const string EXAMPLE_AGGREGATION_NAME = 'custom_aggregation'; + protected const array EXAMPLE_LANGUAGE_FILTER = []; - /** @var \Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor */ - protected $extractor; + protected AggregationResultExtractor $extractor; protected function setUp(): void { @@ -31,6 +30,8 @@ abstract protected function createExtractor(): AggregationResultExtractor; /** * @dataProvider dataProviderForTestCanVisit + * + * @param array{languages: string[]} $languageFilter */ public function testCanVisit( Aggregation $aggregation, @@ -47,6 +48,8 @@ abstract public function dataProviderForTestCanVisit(): iterable; /** * @dataProvider dataProviderForTestExtract + * + * @param array{languages: string[]} $languageFilter */ public function testExtract( Aggregation $aggregation, diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AggregationResultExtractorTestUtils.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AggregationResultExtractorTestUtils.php index 00e9b13a..8f900c95 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AggregationResultExtractorTestUtils.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/AggregationResultExtractorTestUtils.php @@ -10,7 +10,7 @@ final class AggregationResultExtractorTestUtils { - public const EXAMPLE_LANGUAGE_FILTER = [ + public const array EXAMPLE_LANGUAGE_FILTER = [ 'languageCode' => 'eng-GB', 'useAlwaysAvailable' => false, ]; diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractorTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractorTest.php index cbf2551b..aa43bd63 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractorTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/DispatcherAggregationResultExtractorTest.php @@ -18,16 +18,16 @@ final class DispatcherAggregationResultExtractorTest extends TestCase { - private const EXAMPLE_LANGUAGE_FILTER = []; + private const array EXAMPLE_LANGUAGE_FILTER = []; public function testSupportsReturnsTrue(): void { $aggregation = $this->createMock(Aggregation::class); $dispatcher = new DispatcherAggregationResultExtractor([ - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, true), - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), + $this->createExtractorMockWithCanVisit($aggregation, false), + $this->createExtractorMockWithCanVisit($aggregation, true), + $this->createExtractorMockWithCanVisit($aggregation, false), ]); self::assertTrue($dispatcher->canVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER)); @@ -38,9 +38,9 @@ public function testSupportsReturnsFalse(): void $aggregation = $this->createMock(Aggregation::class); $dispatcher = new DispatcherAggregationResultExtractor([ - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), + $this->createExtractorMockWithCanVisit($aggregation, false), + $this->createExtractorMockWithCanVisit($aggregation, false), + $this->createExtractorMockWithCanVisit($aggregation, false), ]); self::assertFalse($dispatcher->canVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER)); @@ -51,9 +51,9 @@ public function testExtract(): void $aggregation = $this->createMock(Aggregation::class); $data = new stdClass(); - $extractorA = $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false); - $extractorB = $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, true); - $extractorC = $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false); + $extractorA = $this->createExtractorMockWithCanVisit($aggregation, false); + $extractorB = $this->createExtractorMockWithCanVisit($aggregation, true); + $extractorC = $this->createExtractorMockWithCanVisit($aggregation, false); $dispatcher = new DispatcherAggregationResultExtractor([$extractorA, $extractorB, $extractorC]); @@ -78,9 +78,9 @@ public function testVisitThrowsNotImplementedException(): void $aggregation = $this->createMock(Aggregation::class); $dispatcher = new DispatcherAggregationResultExtractor([ - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), - $this->createExtractorMockWithCanVisit($aggregation, self::EXAMPLE_LANGUAGE_FILTER, false), + $this->createExtractorMockWithCanVisit($aggregation, false), + $this->createExtractorMockWithCanVisit($aggregation, false), + $this->createExtractorMockWithCanVisit($aggregation, false), ]); $dispatcher->extract($aggregation, self::EXAMPLE_LANGUAGE_FILTER, new stdClass()); @@ -88,11 +88,10 @@ public function testVisitThrowsNotImplementedException(): void private function createExtractorMockWithCanVisit( Aggregation $aggregation, - array $languageFilter, bool $supports ): AggregationResultExtractor { $extractor = $this->createMock(AggregationResultExtractor::class); - $extractor->method('canVisit')->with($aggregation, $languageFilter)->willReturn($supports); + $extractor->method('canVisit')->with($aggregation, self::EXAMPLE_LANGUAGE_FILTER)->willReturn($supports); return $extractor; } diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractorTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractorTest.php index 34d45ddc..c8f22ee9 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractorTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/NestedAggregationResultExtractorTest.php @@ -18,7 +18,7 @@ final class NestedAggregationResultExtractorTest extends TestCase { - private const EXAMPLE_NESTED_RESULT_KEY = 'foo'; + private const string EXAMPLE_NESTED_RESULT_KEY = 'foo'; private AggregationResultExtractor&MockObject $innerResultExtractor; diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/AbstractRangeAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/AbstractRangeAggregationKeyMapperTest.php index 5623bef9..304759eb 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/AbstractRangeAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/AbstractRangeAggregationKeyMapperTest.php @@ -10,16 +10,19 @@ use Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation; use Ibexa\Contracts\Solr\ResultExtractor\AggregationResultExtractor\RangeAggregationKeyMapper; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; abstract class AbstractRangeAggregationKeyMapperTest extends TestCase { - protected const EXAMPLE_LANGUAGE_FILTER = []; + protected const array EXAMPLE_LANGUAGE_FILTER = []; /** * @dataProvider dataProviderForTestMap + * + * @param array{} $languageFilter */ - final public function testMap(Aggregation $aggregation, array $languageFilter, string $key, $expectedResult): void + final public function testMap(Aggregation $aggregation, array $languageFilter, string $key, mixed $expectedResult): void { $mapper = $this->createRangeAggregationKeyMapper(); @@ -29,11 +32,19 @@ final public function testMap(Aggregation $aggregation, array $languageFilter, s ); } + /** + * @return iterable + */ abstract public function dataProviderForTestMap(): iterable; abstract protected function createRangeAggregationKeyMapper(): RangeAggregationKeyMapper; - protected function createAggregationMock(): Aggregation + protected function createAggregationMock(): Aggregation&MockObject { return $this->createMock(Aggregation::class); } diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/NullRangeAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/NullRangeAggregationKeyMapperTest.php index 8f80af89..24e117e5 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/NullRangeAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationKeyMapper/NullRangeAggregationKeyMapperTest.php @@ -13,6 +13,14 @@ final class NullRangeAggregationKeyMapperTest extends AbstractRangeAggregationKeyMapperTest { + /** + * @return iterable + */ public function dataProviderForTestMap(): iterable { yield 'null' => [ diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php index 1270a9d8..4282709f 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/RangeAggregationResultExtractorTest.php @@ -23,18 +23,13 @@ final class RangeAggregationResultExtractorTest extends AbstractAggregationResul { private RangeAggregationKeyMapper&MockObject $keyMapper; + #[\Override] protected function setUp(): void { $this->keyMapper = $this->createMock(RangeAggregationKeyMapper::class); $this->keyMapper ->method('map') - ->willReturnCallback(static function ( - Aggregation $aggregation, - array $languageFilter, - string $key - ): ?string { - return $key !== '*' ? $key : null; - }); + ->willReturnCallback(static fn (Aggregation $aggregation, array $languageFilter, string $key): ?string => $key !== '*' ? $key : null); $this->extractor = $this->createExtractor(); } @@ -44,6 +39,13 @@ protected function createExtractor(): AggregationResultExtractor return new RangeAggregationResultExtractor(AbstractRangeAggregation::class, $this->keyMapper); } + /** + * @return iterable + */ public function dataProviderForTestCanVisit(): iterable { yield 'true' => [ @@ -59,6 +61,14 @@ public function dataProviderForTestCanVisit(): iterable ]; } + /** + * @return iterable + */ public function dataProviderForTestExtract(): iterable { $aggregation = $this->createMock(AbstractRangeAggregation::class); diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractorTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractorTest.php index 6973ba67..14d360f2 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractorTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/StatsAggregationResultExtractorTest.php @@ -22,6 +22,13 @@ protected function createExtractor(): AggregationResultExtractor return new StatsAggregationResultExtractor(AbstractStatsAggregation::class); } + /** + * @return iterable + */ public function dataProviderForTestCanVisit(): iterable { yield 'true' => [ @@ -37,6 +44,14 @@ public function dataProviderForTestCanVisit(): iterable ]; } + /** + * @return iterable + */ public function dataProviderForTestExtract(): iterable { $aggregation = $this->createMock(AbstractStatsAggregation::class); diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php index 91c11e1c..32081cc6 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/AuthorAggregationKeyMapperTest.php @@ -19,6 +19,10 @@ final class AuthorAggregationKeyMapperTest extends TestCase { /** * @dataProvider dataProviderForTestMap + * + * @param array{languages: string[]} $languageFilter + * @param list $keys + * @param array $expectedResult */ public function testMap( Aggregation $aggregation, @@ -38,6 +42,14 @@ public function testMap( ); } + /** + * @return iterable, + * 2: list, + * 3: array + * }> + */ public function dataProviderForTestMap(): iterable { $input = [ diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php index b7b1529b..656380af 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeAggregationKeyMapperTest.php @@ -18,7 +18,7 @@ final class ContentTypeAggregationKeyMapperTest extends TestCase { - private const EXAMPLE_CONTENT_TYPE_IDS = [1, 2, 3]; + private const array EXAMPLE_CONTENT_TYPE_IDS = [1, 2, 3]; private ContentTypeService&MockObject $contentTypeService; @@ -51,6 +51,11 @@ public function testMap(): void ); } + /** + * @param list $ids + * + * @return list<\Ibexa\Contracts\Core\Repository\Values\ContentType\ContentType> + */ private function createContentTypesList(iterable $ids): array { $contentTypes = []; diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapperTest.php index 33f70837..3d889c2f 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ContentTypeGroupAggregationKeyMapperTest.php @@ -51,6 +51,9 @@ private function createContentTypeGroupWithIds(int $id): ContentTypeGroup return $contentTypeGroup; } + /** + * @return array + */ private function createExpectedLanguages(): array { $expectedContentTypesGroups = []; diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php index bd613e93..4c51a375 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/CountryAggregationKeyMapperTest.php @@ -16,12 +16,12 @@ final class CountryAggregationKeyMapperTest extends TestCase { - private const EXAMPLE_RAW_KEYS = [93, 94, 55]; + private const array EXAMPLE_RAW_KEYS = [93, 94, 55]; /** * Example country info entries from "ibexa.field_type.country.data" parameter. */ - private const EXAMPLE_COUNTRIES_INFO = [ + private const array EXAMPLE_COUNTRIES_INFO = [ 'AF' => [ 'Name' => 'Afghanistan', 'Alpha2' => 'AF', @@ -44,6 +44,10 @@ final class CountryAggregationKeyMapperTest extends TestCase /** * @dataProvider dataProviderForTestMap + * + * @param array{languages: string[]} $languageFilter + * @param list $keys + * @param array $expectedResult */ public function testMap( Aggregation $aggregation, @@ -63,6 +67,14 @@ public function testMap( ); } + /** + * @return iterable, + * 3: array + * }> + */ public function dataProviderForTestMap(): iterable { yield 'default' => [ diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapperTest.php index 99c798f9..8a52a444 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LanguageAggregationKeyMapperTest.php @@ -18,7 +18,7 @@ final class LanguageAggregationKeyMapperTest extends TestCase { - private const EXAMPLE_LANGUAGE_CODES = []; + private const array EXAMPLE_LANGUAGE_CODES = []; private LanguageService&MockObject $languageService; @@ -52,6 +52,11 @@ public function testMap(): void ); } + /** + * @param iterable $languageCodes + * + * @return list + */ private function configureLanguageServiceMock(iterable $languageCodes): array { $languages = []; diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapperTest.php index fbaf0ec7..361cd1bb 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/LocationAggregationKeyMapperTest.php @@ -18,7 +18,7 @@ final class LocationAggregationKeyMapperTest extends TestCase { - private const EXAMPLE_LOCATION_IDS = ['2', '54', '47']; + private const array EXAMPLE_LOCATION_IDS = ['2', '54', '47']; private LocationService&MockObject $locationService; @@ -32,7 +32,7 @@ protected function setUp(): void public function testMap(): void { - $expectedLocations = $this->createExpectedLocations(self::EXAMPLE_LOCATION_IDS); + $expectedLocations = $this->createExpectedLocations(); $this->locationService ->method('loadLocationList') @@ -52,10 +52,13 @@ public function testMap(): void ); } - private function createExpectedLocations(iterable $locationIds): array + /** + * @return array + */ + private function createExpectedLocations(): array { $locations = []; - foreach ($locationIds as $locationId) { + foreach (self::EXAMPLE_LOCATION_IDS as $locationId) { $locationId = (int)$locationId; $location = $this->createMock(Location::class); diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapperTest.php index d0ab137b..12e44ef7 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/ObjectStateAggregationKeyMapperTest.php @@ -47,6 +47,11 @@ public function testMap(): void ); } + /** + * @param iterable $objectStateIdentifiers + * + * @return array<\Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState> + */ private function configureObjectStateService( string $objectStateGroupIdentifier, iterable $objectStateIdentifiers @@ -69,7 +74,7 @@ private function configureObjectStateService( $this->objectStateService ->method('loadObjectStateByIdentifier') ->willReturnCallback( - static function ($group, $identifier, $options) use ($objectStateGroup, $map) { + static function ($group, $identifier, $options) use ($objectStateGroup, $map): \Ibexa\Contracts\Core\Repository\Values\ObjectState\ObjectState&\PHPUnit\Framework\MockObject\MockObject { if ($group === $objectStateGroup && isset($map[$identifier]) && $options === []) { return $map[$identifier]; } diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php index 63415977..9edbc475 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SectionAggregationKeyMapperTest.php @@ -45,6 +45,11 @@ public function testMap(): void ); } + /** + * @param iterable $sectionIds + * + * @return array + */ private function configureSectionServiceMock(iterable $sectionIds): array { $sections = []; @@ -54,7 +59,7 @@ private function configureSectionServiceMock(iterable $sectionIds): array $this->sectionService ->method('loadSection') - ->willReturnCallback(static function ($id) use ($sections) { + ->willReturnCallback(static function ($id) use ($sections): \Ibexa\Contracts\Core\Repository\Values\Content\Section&\PHPUnit\Framework\MockObject\MockObject { if (isset($sections[$id])) { return $sections[$id]; } diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapperTest.php index 33688b9b..3d117eff 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/SubtreeAggregationKeyMapperTest.php @@ -18,7 +18,7 @@ final class SubtreeAggregationKeyMapperTest extends TestCase { - private const EXAMPLE_PATH_STRING = '/1/2/54/'; + private const string EXAMPLE_PATH_STRING = '/1/2/54/'; private TermAggregationKeyMapper&MockObject $locationAggregationKeyMapper; @@ -53,6 +53,11 @@ public function testMap(): void ); } + /** + * @param iterable $locationIds + * + * @return array + */ private function createExpectedLocations(iterable $locationIds): array { $locations = []; diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapperTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapperTest.php index 84da3dc3..542237dc 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapperTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationKeyMapper/UserMetadataAggregationKeyMapperTest.php @@ -90,7 +90,7 @@ private function createExpectedResultForUserKey(iterable $userIds): array $this->userService ->method('loadUser') - ->willReturnCallback(static fn ($userId) => $users[$userId] ?? throw new InvalidArgumentException('userId', "Unexpected user ID: $userId")); + ->willReturnCallback(static fn ($userId): \PHPUnit\Framework\MockObject\MockObject => $users[$userId] ?? throw new InvalidArgumentException('userId', "Unexpected user ID: $userId")); return $users; } @@ -110,7 +110,7 @@ private function createExpectedResultForUserGroupKey(iterable $userGroupIds): ar $this->userService ->expects(self::any()) ->method('loadUserGroup') - ->willReturnCallback(static fn ($userGroupId) => $userGroups[$userGroupId] ?? throw new InvalidArgumentException('userGroupId', "Unexpected user group ID: $userGroupId")); + ->willReturnCallback(static fn ($userGroupId): \PHPUnit\Framework\MockObject\MockObject => $userGroups[$userGroupId] ?? throw new InvalidArgumentException('userGroupId', "Unexpected user group ID: $userGroupId")); return $userGroups; } diff --git a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractorTest.php b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractorTest.php index 5f90ca67..a2907c71 100644 --- a/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractorTest.php +++ b/tests/lib/Search/ResultExtractor/AggregationResultExtractor/TermAggregationResultExtractorTest.php @@ -22,18 +22,13 @@ final class TermAggregationResultExtractorTest extends AbstractAggregationResult { private TermAggregationKeyMapper&MockObject $keyMapper; + #[\Override] protected function setUp(): void { $this->keyMapper = $this->createMock(TermAggregationKeyMapper::class); $this->keyMapper ->method('map') - ->willReturnCallback(static function ( - Aggregation $aggregation, - array $languageFilter, - array $keys - ): array { - return array_combine($keys, array_map('strtoupper', $keys)); - }); + ->willReturnCallback(static fn (Aggregation $aggregation, array $languageFilter, array $keys): array => array_combine($keys, array_map('strtoupper', $keys))); $this->extractor = $this->createExtractor(); } @@ -46,6 +41,13 @@ protected function createExtractor(): AggregationResultExtractor ); } + /** + * @return iterable + */ public function dataProviderForTestCanVisit(): iterable { yield 'true' => [ @@ -61,6 +63,14 @@ public function dataProviderForTestCanVisit(): iterable ]; } + /** + * @return iterable + */ public function dataProviderForTestExtract(): iterable { $aggregation = $this->createMock(AbstractTermAggregation::class); diff --git a/tests/lib/SetupFactory/LegacySetupFactory.php b/tests/lib/SetupFactory/LegacySetupFactory.php index 5aee92b4..6494879e 100644 --- a/tests/lib/SetupFactory/LegacySetupFactory.php +++ b/tests/lib/SetupFactory/LegacySetupFactory.php @@ -31,9 +31,9 @@ */ class LegacySetupFactory extends CoreLegacySetupFactory { - public const CONFIGURATION_FILES_MAP = SolrTestContainerBuilder::CONFIGURATION_FILES_MAP; + public const array CONFIGURATION_FILES_MAP = SolrTestContainerBuilder::CONFIGURATION_FILES_MAP; - private SolrTestContainerBuilder $containerBuilder; + private readonly SolrTestContainerBuilder $containerBuilder; public function __construct() { @@ -44,12 +44,9 @@ public function __construct() /** * Returns a configured repository for testing. - * - * @param bool $initializeFromScratch - * - * @return \Ibexa\Contracts\Core\Repository\Repository */ - public function getRepository($initializeFromScratch = true): Repository + #[\Override] + public function getRepository(bool $initializeFromScratch = true): Repository { // Load repository first so all initialization steps are done $repository = parent::getRepository($initializeFromScratch); @@ -64,6 +61,7 @@ public function getRepository($initializeFromScratch = true): Repository /** * @throws \Exception */ + #[\Override] protected function externalBuildContainer(ContainerBuilder $containerBuilder): void { parent::externalBuildContainer($containerBuilder);