Skip to content

Commit

Permalink
Merge branch '4.4' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Steveb-p committed Mar 28, 2023
2 parents e82f7c2 + 530453c commit 4f07b02
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 226 deletions.
227 changes: 6 additions & 221 deletions phpstan-baseline.neon

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ services:
calls:
- setLogger: [ '@logger' ]
tags:
- { name: http_client.client }
- { name: monolog.logger, channel: ibexa.solr }

Ibexa\Solr\Gateway\HttpClient\Stream:
Expand Down
4 changes: 4 additions & 0 deletions src/contracts/Query/AggregationVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ interface AggregationVisitor
{
/**
* Check if visitor is applicable to current aggreagtion.
*
* @param array{languages: string[]} $languageFilter
*/
public function canVisit(Aggregation $aggregation, array $languageFilter): bool;

/**
* @param array{languages: string[]} $languageFilter
*
* @return string[]
*/
public function visit(
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Gateway/Native.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ public function __construct(
/**
* 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: <code>array("languages" => array(<language1>,..))</code>.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

final class DispatcherAggregationVisitor implements AggregationVisitor
{
/** @var \Ibexa\Contracts\Solr\Query\AggregationVisitor[] */
/** @var iterable<\Ibexa\Contracts\Solr\Query\AggregationVisitor> */
private $visitors;

/**
* @var \Ibexa\Contracts\Solr\Query\AggregationVisitor[]
* @param iterable<\Ibexa\Contracts\Solr\Query\AggregationVisitor> $visitors
*/
public function __construct(iterable $visitors)
{
Expand Down Expand Up @@ -46,6 +46,9 @@ public function visit(
return $visitor->visit($this, $aggregation, $languageFilter);
}

/**
* @param array{languages: string[]} $languageFilter
*/
private function findVisitor(Aggregation $aggregation, array $languageFilter): ?AggregationVisitor
{
foreach ($this->visitors as $visitor) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/Query/QueryConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ abstract class QueryConverter
/**
* Map query to a proper Solr representation.
*
* @phpstan-param array{languages: string[]} $languageSettings
*
* @param array $languageSettings - a map of filters for the returned fields.
* Currently supported: <code>array("languages" => array(<language1>,..))</code>.
*
Expand Down
1 change: 0 additions & 1 deletion src/lib/Resources/config/container/solr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,3 @@ services:
tags:
- {name: ibexa.search.engine.indexer, alias: solr}
lazy: true

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
abstract class AbstractAggregationVisitorTest extends TestCase
{
protected const EXAMPLE_LANGUAGE_FILTER = [
'languageCode' => 'eng-gb',
'languages' => ['eng-GB'],
];

/** @var \Ibexa\Contracts\Solr\Query\AggregationVisitor */
Expand All @@ -33,6 +33,8 @@ protected function setUp(): void
abstract protected function createVisitor(): AggregationVisitor;

/**
* @param array{languages: string[]} $languageFilter
*
* @dataProvider dataProviderForCanVisit
*/
final public function testCanVisit(
Expand All @@ -46,9 +48,19 @@ final public function testCanVisit(
);
}

/**
* @return iterable<array{
* \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation,
* array{languages: string[]},
* bool,
* }>
*/
abstract public function dataProviderForCanVisit(): iterable;

/**
* @param array{languages: string[]} $languageFilter
* @param array<mixed> $expectedResult
*
* @dataProvider dataProviderForVisit
*/
final public function testVisit(
Expand All @@ -64,8 +76,19 @@ final public function testVisit(
);
}

/**
* @return iterable<array{
* \Ibexa\Contracts\Core\Repository\Values\Content\Query\Aggregation,
* array{languages: string[]},
* array<mixed>,
* }>
*/
abstract public function dataProviderForVisit(): iterable;

/**
* @param array{languages: string[]} $languageFilter
* @param array<mixed> $expectedResult
*/
protected function configureMocksForTestVisit(
Aggregation $aggregation,
array $languageFilter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
final class DispatcherAggregationVisitorTest extends TestCase
{
private const EXAMPLE_LANGUAGE_FILTER = [
'languageCode' => 'eng-gb',
'languages' => ['eng-GB'],
];

private const EXAMPLE_VISITOR_RESULT = [
Expand Down Expand Up @@ -74,6 +74,11 @@ public function testVisit(): void
);
}

/**
* @param array{languages: string[]} $languageFilter
*
* @return \PHPUnit\Framework\MockObject\MockObject&\Ibexa\Contracts\Solr\Query\AggregationVisitor
*/
private function createVisitorMock(
Aggregation $aggregation,
array $languageFilter,
Expand Down

0 comments on commit 4f07b02

Please sign in to comment.