Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/bundle/ApiLoader/IndexingDepthProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,9 @@ class IndexingDepthProviderFactory implements ContainerAwareInterface

private RepositoryConfigurationProviderInterface $repositoryConfigurationProvider;

/**
* @var string
*/
private $defaultConnection;
private string $defaultConnection;

/**
* @var string
*/
private $indexingDepthProviderClass;
private string $indexingDepthProviderClass;

public function __construct(
RepositoryConfigurationProviderInterface $repositoryConfigurationProvider,
Expand Down
18 changes: 6 additions & 12 deletions src/bundle/ApiLoader/SolrEngineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,17 @@ class SolrEngineFactory
/** @var string */
private $searchEngineClass;

/** @var \Ibexa\Solr\Gateway\GatewayRegistry */
private $gatewayRegistry;
private GatewayRegistry $gatewayRegistry;

/** @var \Ibexa\Solr\CoreFilter\CoreFilterRegistry */
private $coreFilterRegistry;
private CoreFilterRegistry $coreFilterRegistry;

/** @var \Ibexa\Contracts\Core\Persistence\Content\Handler */
private $contentHandler;
private Handler $contentHandler;

/** @var \Ibexa\Contracts\Solr\DocumentMapper */
private $documentMapper;
private DocumentMapper $documentMapper;

/** @var \Ibexa\Solr\ResultExtractor */
private $contentResultExtractor;
private ResultExtractor $contentResultExtractor;

/** @var \Ibexa\Solr\ResultExtractor */
private $locationResultExtractor;
private ResultExtractor $locationResultExtractor;

public function __construct(
RepositoryConfigurationProviderInterface $repositoryConfigurationProvider,
Expand Down
14 changes: 7 additions & 7 deletions src/bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ protected function addConnectionsSection(ArrayNodeDefinition $node)
->prototype('array')
->beforeNormalization()
->ifTrue(
static function ($v) {
static function ($v): bool {
return
!empty($v['mapping']) && !\is_array($v['mapping'])
;
}
)
->then(
static function ($v) {
static function (array $v) {
// If single endpoint is set for Content mapping, use it as default
// mapping for Content index
$v['mapping'] = [
Expand All @@ -136,7 +136,7 @@ static function ($v) {
->end()
->beforeNormalization()
->ifTrue(
static function ($v) {
static function ($v): bool {
return
empty($v['entry_endpoints']) &&
(
Expand All @@ -149,7 +149,7 @@ static function ($v) {
)
->then(
// If entry endpoints are not provided use mapping endpoints
static function ($v) {
static function (array $v) {
$endpointSet = [];

if (!empty($v['mapping']['translations'])) {
Expand Down Expand Up @@ -318,7 +318,7 @@ static function ($v) {
->useAttributeAsKey('content_type_identifier')
->beforeNormalization()
->always(
static function (array $v) {
static function (array $v): array {
$valuesMapped = [];
foreach ($v as $key => $value) {
if (\is_array($value)) {
Expand Down Expand Up @@ -354,7 +354,7 @@ static function (array $v) {
->useAttributeAsKey('content_type_identifier')
->beforeNormalization()
->always(
static function (array $v) {
static function (array $v): array {
$valuesMapped = [];
foreach ($v as $key => $value) {
if (\is_array($value)) {
Expand All @@ -373,7 +373,7 @@ static function (array $v) {
->useAttributeAsKey('meta_field_name')
->validate()
->ifTrue(
function (array $v) {
function (array $v): bool {
foreach (array_keys($v) as $key) {
if (!\in_array($key, $this->metaFieldNames, true)) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/Query/CriterionVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected function escapeExpressions($string, $allowWildcard = false)

return preg_replace_callback(
'/([' . $reservedCharacters . '])/',
static function ($matches) {
static function ($matches): string {
return '\\' . $matches[0];
},
$string
Expand Down
2 changes: 1 addition & 1 deletion src/lib/CoreFilter/CoreFilterRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
final class CoreFilterRegistry
{
/** @var \Ibexa\Solr\CoreFilter[] */
private $coreFilters;
private array $coreFilters;

/**
* @param \Ibexa\Solr\CoreFilter[] $coreFilters
Expand Down
8 changes: 3 additions & 5 deletions src/lib/CoreFilter/NativeCoreFilter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in src/lib/CoreFilter/NativeCoreFilter.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Ignored error pattern #^Method Ibexa\\Solr\\CoreFilter\\NativeCoreFilter\:\:apply\(\) has no return type specified\.$# (missingType.return) in path /home/runner/work/solr/solr/src/lib/CoreFilter/NativeCoreFilter.php was not matched in reported errors.

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand Down Expand Up @@ -77,10 +77,8 @@

/**
* Indicates presence of main languages index.
*
* @var bool
*/
private $hasMainLanguagesEndpoint;
private bool $hasMainLanguagesEndpoint;

public function __construct(EndpointResolver $endpointResolver)
{
Expand All @@ -89,7 +87,7 @@
);
}

public function apply(Query $query, array $languageSettings, $documentTypeIdentifier)
public function apply(Query $query, array $languageSettings, $documentTypeIdentifier): void
{
$languages = (
empty($languageSettings['languages']) ?
Expand Down Expand Up @@ -267,7 +265,7 @@
*
* @return string[]
*/
private function getExcludedLanguageCodes(array $languageCodes, $selectedLanguageCode = null)
private function getExcludedLanguageCodes(array $languageCodes, $selectedLanguageCode = null): array
{
$excludedLanguageCodes = [];

Expand Down
40 changes: 12 additions & 28 deletions src/lib/DocumentMapper/NativeDocumentMapper.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in src/lib/DocumentMapper/NativeDocumentMapper.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Ignored error pattern #^Parameter \#2 \$languageCode of method Ibexa\\Solr\\DocumentMapper\\NativeDocumentMapper\:\:getBlockTranslationFields\(\) expects string, int\|string given\.$# (argument.type) in path /home/runner/work/solr/solr/src/lib/DocumentMapper/NativeDocumentMapper.php was not matched in reported errors.

Check failure on line 1 in src/lib/DocumentMapper/NativeDocumentMapper.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Ignored error pattern #^Parameter \#2 \$languageCode of method Ibexa\\Solr\\DocumentMapper\\NativeDocumentMapper\:\:getContentTranslationFields\(\) expects string, int\|string given\.$# (argument.type) in path /home/runner/work/solr/solr/src/lib/DocumentMapper/NativeDocumentMapper.php was not matched in reported errors.

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand All @@ -9,6 +9,7 @@

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;
Expand All @@ -21,37 +22,20 @@
*/
class NativeDocumentMapper implements DocumentMapper
{
/**
* @var \Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper
*/
private $blockFieldMapper;
private ContentFieldMapper $blockFieldMapper;

/**
* @var \Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper
*/
private $blockTranslationFieldMapper;
private ContentTranslationFieldMapper $blockTranslationFieldMapper;

/**
* @var \Ibexa\Contracts\Solr\FieldMapper\ContentFieldMapper
*/
private $contentFieldMapper;
private ContentFieldMapper $contentFieldMapper;

/**
* @var \Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper
*/
private $contentTranslationFieldMapper;
private ContentTranslationFieldMapper $contentTranslationFieldMapper;

/**
* @var \Ibexa\Contracts\Solr\FieldMapper\LocationFieldMapper
*/
private $locationFieldMapper;
private LocationFieldMapper $locationFieldMapper;

/**
* Location handler.
*
* @var \Ibexa\Contracts\Core\Persistence\Content\Location\Handler
*/
protected $locationHandler;
protected Handler $locationHandler;

/**
* Creates a new document mapper.
Expand All @@ -77,7 +61,7 @@
*
* @return \Ibexa\Contracts\Core\Search\Document[]
*/
public function mapContentBlock(Content $content)
public function mapContentBlock(Content $content): array
{
$contentInfo = $content->versionInfo->contentInfo;
$locations = $this->locationHandler->loadLocationsByContent($contentInfo->id);
Expand Down Expand Up @@ -155,7 +139,7 @@
*
* @return string
*/
public function generateContentDocumentId($contentId, $languageCode = null)
public function generateContentDocumentId($contentId, $languageCode = null): string
{
return strtolower("content{$contentId}lang{$languageCode}");
}
Expand All @@ -175,7 +159,7 @@
*
* @return string
*/
public function generateLocationDocumentId($locationId, $languageCode = null)
public function generateLocationDocumentId($locationId, $languageCode = null): string
{
return strtolower("location{$locationId}lang{$languageCode}");
}
Expand Down Expand Up @@ -205,12 +189,12 @@
*
* @return \Ibexa\Contracts\Core\Search\Field[]
*/
private function getBlockTranslationFields(Content $content, $languageCode)
private function getBlockTranslationFields(Content $content, int|string $languageCode)
{
$fields = [];

if ($this->blockTranslationFieldMapper->accept($content, $languageCode)) {

Check failure on line 196 in src/lib/DocumentMapper/NativeDocumentMapper.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Parameter #2 $languageCode of method Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper::accept() expects string, int|string given.
$fields = $this->blockTranslationFieldMapper->mapFields($content, $languageCode);

Check failure on line 197 in src/lib/DocumentMapper/NativeDocumentMapper.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Parameter #2 $languageCode of method Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper::mapFields() expects string, int|string given.
}

return $fields;
Expand Down Expand Up @@ -241,12 +225,12 @@
*
* @return \Ibexa\Contracts\Core\Search\Field[]
*/
private function getContentTranslationFields(Content $content, $languageCode)
private function getContentTranslationFields(Content $content, int|string $languageCode)
{
$fields = [];

if ($this->contentTranslationFieldMapper->accept($content, $languageCode)) {

Check failure on line 232 in src/lib/DocumentMapper/NativeDocumentMapper.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Parameter #2 $languageCode of method Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper::accept() expects string, int|string given.
$fields = $this->contentTranslationFieldMapper->mapFields($content, $languageCode);

Check failure on line 233 in src/lib/DocumentMapper/NativeDocumentMapper.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Parameter #2 $languageCode of method Ibexa\Contracts\Solr\FieldMapper\ContentTranslationFieldMapper::mapFields() expects string, int|string given.
}

return $fields;
Expand Down
20 changes: 5 additions & 15 deletions src/lib/FieldMapper/BoostFactorProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,18 @@ class BoostFactorProvider
{
/**
* Internal map key used to access Content field boost factors.
*
* @var string
*/
private static $keyContentFields = 'content-fields';
private static string $keyContentFields = 'content-fields';

/**
* Internal map key used to access meta field boost factors.
*
* @var string
*/
private static $keyMetaFields = 'meta-fields';
private static string $keyMetaFields = 'meta-fields';

/**
* Internal map wildcard type key.
*
* @var string
*/
private static $keyAny = '*';
private static string $keyAny = '*';

/**
* Internal map of field boost factors.
Expand Down Expand Up @@ -69,17 +63,13 @@ class BoostFactorProvider
* ],
* ];
* ```
*
* @var array
*/
private $map;
private array $map;

/**
* Boost factor to be used if no mapping is found.
*
* @var float
*/
private $defaultBoostFactor = 1.0;
private float $defaultBoostFactor = 1.0;

public function __construct(array $map = [])
{
Expand Down
9 changes: 6 additions & 3 deletions src/lib/FieldMapper/ContentFieldMapper/Aggregate.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in src/lib/FieldMapper/ContentFieldMapper/Aggregate.php

View workflow job for this annotation

GitHub Actions / Unit tests (8.3)

Ignored error pattern #^Method Ibexa\\Solr\\FieldMapper\\ContentFieldMapper\\Aggregate\:\:addMapper\(\) has no return type specified\.$# (missingType.return) in path /home/runner/work/solr/solr/src/lib/FieldMapper/ContentFieldMapper/Aggregate.php was not matched in reported errors.

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
Expand Down Expand Up @@ -36,17 +36,20 @@
/**
* Adds given $mapper to the internal array as the next one in priority.
*/
public function addMapper(ContentFieldMapper $mapper)
public function addMapper(ContentFieldMapper $mapper): void
{
$this->mappers[] = $mapper;
}

public function accept(Content $content)
public function accept(Content $content): bool
{
return true;
}

public function mapFields(Content $content)
/**
* @return mixed[]
*/
public function mapFields(Content $content): array
{
$fields = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Ibexa\Solr\FieldMapper\ContentFieldMapper;

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;
Expand All @@ -22,25 +23,13 @@
*/
class BlockDocumentsBaseContentFields extends ContentFieldMapper
{
/**
* @var \Ibexa\Contracts\Core\Persistence\Content\Location\Handler
*/
protected $locationHandler;
protected Handler $locationHandler;

/**
* @var \Ibexa\Contracts\Core\Persistence\Content\Type\Handler
*/
protected $contentTypeHandler;
protected ContentTypeHandler $contentTypeHandler;

/**
* @var \Ibexa\Contracts\Core\Persistence\Content\ObjectState\Handler
*/
protected $objectStateHandler;
protected ObjectStateHandler $objectStateHandler;

/**
* @var \Ibexa\Contracts\Core\Persistence\Content\Section\Handler
*/
protected $sectionHandler;
protected SectionHandler $sectionHandler;

public function __construct(
LocationHandler $locationHandler,
Expand All @@ -54,12 +43,12 @@ public function __construct(
$this->sectionHandler = $sectionHandler;
}

public function accept(Content $content)
public function accept(Content $content): bool
{
return true;
}

public function mapFields(Content $content)
public function mapFields(Content $content): array
{
$versionInfo = $content->versionInfo;
$contentInfo = $content->versionInfo->contentInfo;
Expand Down Expand Up @@ -203,7 +192,7 @@ public function mapFields(Content $content)
*
* @return array
*/
protected function getObjectStateIds($contentId)
protected function getObjectStateIds($contentId): array
{
$objectStateIds = [];

Expand Down
Loading
Loading