Skip to content

Commit 3e04cbe

Browse files
committed
remove symfony dependency
1 parent ea032b3 commit 3e04cbe

21 files changed

+59
-197
lines changed

.github/workflows/test-application.yaml

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,30 +73,13 @@ jobs:
7373
run: vendor/bin/phpstan analyse
7474

7575
unit-test:
76-
name: 'Run unit tests with php ${{ matrix.php-version }} with symfony ${{ matrix.symfony-version}}'
76+
name: 'Run unit tests with php ${{ matrix.php-version }}'
7777
runs-on: ubuntu-latest
7878

7979
strategy:
8080
fail-fast: false
8181
matrix:
82-
include:
83-
- php-version: '8.0'
84-
symfony-version: '5.4.*'
85-
86-
- php-version: '8.1'
87-
symfony-version: '5.4.*'
88-
89-
- php-version: '8.1'
90-
symfony-version: '6.0.*'
91-
92-
- php-version: '8.1'
93-
symfony-version: '6.1.*'
94-
95-
- php-version: '8.1'
96-
symfony-version: '6.2.*'
97-
98-
- php-version: '8.2'
99-
symfony-version: '6.2.*'
82+
php-version: [ '8.0', '8.1', '8.2' ]
10083

10184
steps:
10285
- name: Checkout project
@@ -124,7 +107,6 @@ jobs:
124107
- name: Install dependencies
125108
run: |
126109
composer validate --strict
127-
composer require --no-update symfony/serializer:${{ matrix.symfony-version }}
128110
composer install --no-interaction --prefer-dist
129111
130112
- name: Run tests

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
This is a fork of the [ongr/elasticsearch-dsl](https://github.com/ongr-io/elasticsearchbundle).
44
With some basic changes to support wider range of Symfony Versions.
55

6-
| Version | Supported OpenSearch Version | Supported Symfony Version |
7-
|---------|------------------------------|------------------------------------|
8-
| `1.x` | `^1.2`, `^2.0` | `5.4.*`, `6.0.*`, `6.1.*`, `6.2.*` |
6+
| Version | Supported OpenSearch Version |
7+
|---------|------------------------------|
8+
| `1.x` | `^1.2`, `^2.0` |
99

1010
## Documentation
1111

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
],
2121
"require": {
2222
"php": "8.0.* || 8.1.* || 8.2.*",
23-
"symfony/serializer": "5.4.* || 6.0.* || 6.1.* || 6.2.*",
2423
"opensearch-project/opensearch-php": "^1.0 || ^2.0"
2524
},
2625
"require-dev": {
27-
"phpunit/phpunit": "^9.5",
28-
"phpstan/phpstan": "1.8.11",
29-
"phpstan/phpstan-phpunit": "1.1.3",
26+
"phpunit/phpunit": "^9.6",
27+
"phpstan/phpstan": "1.10.21",
28+
"phpstan/phpstan-phpunit": "1.3.13",
3029
"rector/rector": "^0.14.5",
31-
"symplify/easy-coding-standard": "^11.1"
30+
"symplify/easy-coding-standard": "^11.5.0"
3231
},
3332
"autoload": {
3433
"psr-4": {

src/Search.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
use OpenSearchDSL\SearchEndpoint\SearchEndpointInterface;
2727
use OpenSearchDSL\SearchEndpoint\SortEndpoint;
2828
use OpenSearchDSL\SearchEndpoint\SuggestEndpoint;
29-
use OpenSearchDSL\Serializer\Normalizer\CustomReferencedNormalizer;
3029
use OpenSearchDSL\Serializer\OrderedSerializer;
3130
use stdClass;
32-
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
3331

3432
/**
3533
* Search object that can be executed by a manager.
@@ -156,12 +154,7 @@ public function __wakeup()
156154
private function initializeSerializer(): void
157155
{
158156
if (self::$serializer === null) {
159-
self::$serializer = new OrderedSerializer(
160-
[
161-
new CustomReferencedNormalizer(),
162-
new CustomNormalizer(),
163-
]
164-
);
157+
self::$serializer = new OrderedSerializer();
165158
}
166159
}
167160

src/SearchEndpoint/AggregationsEndpoint.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace OpenSearchDSL\SearchEndpoint;
1313

1414
use OpenSearchDSL\Aggregation\AbstractAggregation;
15-
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
1615

1716
/**
1817
* Search aggregations dsl endpoint.
@@ -24,11 +23,8 @@ class AggregationsEndpoint extends AbstractSearchEndpoint
2423
*/
2524
public const NAME = 'aggregations';
2625

27-
public function normalize(
28-
NormalizerInterface $normalizer,
29-
$format = null,
30-
array $context = []
31-
): array|string|int|float|bool {
26+
public function normalize(): ?array
27+
{
3228
$output = [];
3329
if ($this->getAll() !== []) {
3430
/** @var AbstractAggregation $aggregation */

src/SearchEndpoint/HighlightEndpoint.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use OpenSearchDSL\BuilderInterface;
1515
use OverflowException;
16-
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
1716

1817
/**
1918
* Search highlight dsl endpoint.
@@ -32,16 +31,13 @@ class HighlightEndpoint extends AbstractSearchEndpoint
3231
*/
3332
private ?string $key = null;
3433

35-
public function normalize(
36-
NormalizerInterface $normalizer,
37-
$format = null,
38-
array $context = []
39-
): array|string|int|float|bool {
34+
public function normalize(): ?array
35+
{
4036
if ($this->highlight !== null) {
4137
return $this->highlight->toArray();
4238
}
4339

44-
return false;
40+
return null;
4541
}
4642

4743
public function add(BuilderInterface $builder, ?string $key = null): string

src/SearchEndpoint/InnerHitsEndpoint.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace OpenSearchDSL\SearchEndpoint;
1313

1414
use OpenSearchDSL\InnerHit\NestedInnerHit;
15-
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
1615

1716
/**
1817
* Search inner hits dsl endpoint.
@@ -24,11 +23,8 @@ class InnerHitsEndpoint extends AbstractSearchEndpoint
2423
*/
2524
public const NAME = 'inner_hits';
2625

27-
public function normalize(
28-
NormalizerInterface $normalizer,
29-
$format = null,
30-
array $context = []
31-
): array|string|int|float|bool {
26+
public function normalize(): ?array
27+
{
3228
$output = [];
3329
if ($this->getAll() !== []) {
3430
/** @var NestedInnerHit $innerHit */

src/SearchEndpoint/PostFilterEndpoint.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace OpenSearchDSL\SearchEndpoint;
1313

14-
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
15-
1614
/**
1715
* Search post filter dsl endpoint.
1816
*/
@@ -23,16 +21,9 @@ class PostFilterEndpoint extends QueryEndpoint
2321
*/
2422
public const NAME = 'post_filter';
2523

26-
public function normalize(
27-
NormalizerInterface $normalizer,
28-
$format = null,
29-
array $context = []
30-
): array|string|int|float|bool {
31-
if ($this->getBool() === null) {
32-
return false;
33-
}
34-
35-
return $this->getBool()->toArray();
24+
public function normalize(): ?array
25+
{
26+
return $this->getBool()?->toArray();
3627
}
3728

3829
public function getOrder(): int

src/SearchEndpoint/QueryEndpoint.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use OpenSearchDSL\BuilderInterface;
1515
use OpenSearchDSL\Query\Compound\BoolQuery;
1616
use OpenSearchDSL\Serializer\Normalizer\OrderedNormalizerInterface;
17-
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
1817

1918
/**
2019
* Search query dsl endpoint.
@@ -30,23 +29,16 @@ class QueryEndpoint extends AbstractSearchEndpoint implements OrderedNormalizerI
3029

3130
private bool $filtersSet = false;
3231

33-
public function normalize(
34-
NormalizerInterface $normalizer,
35-
string $format = null,
36-
array $context = []
37-
): array|string|int|float|bool {
32+
public function normalize(): ?array
33+
{
3834
if (! $this->filtersSet && $this->hasReference('filter_query')) {
3935
/** @var BuilderInterface $filter */
4036
$filter = $this->getReference('filter_query');
4137
$this->addToBool($filter, BoolQuery::FILTER);
4238
$this->filtersSet = true;
4339
}
4440

45-
if ($this->bool === null) {
46-
return false;
47-
}
48-
49-
return $this->bool->toArray();
41+
return $this->bool?->toArray();
5042
}
5143

5244
public function add(BuilderInterface $builder, ?string $key = null): string

src/SearchEndpoint/SearchEndpointInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313

1414
use OpenSearchDSL\BuilderInterface;
1515
use OpenSearchDSL\Query\Compound\BoolQuery;
16-
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
1716

1817
/**
1918
* Interface used to define search endpoint.
2019
*/
21-
interface SearchEndpointInterface extends NormalizableInterface
20+
interface SearchEndpointInterface
2221
{
2322
/**
2423
* Adds builder to search endpoint.

0 commit comments

Comments
 (0)