Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #336 add symfony/serializer 6 support #367

Open
wants to merge 10 commits into
base: 7.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": "^7.4 || ^8.0",
"symfony/serializer": "^5.0",
"symfony/serializer": "^5.0 || ^6.0",
"elasticsearch/elasticsearch": "^7.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/AggregationsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class AggregationsEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Union return types are from php 8 and in composer we declare that php 7.4 is supported.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's time to remove 7.4 as it's no longer supported :(

https://www.php.net/supported-versions.php

Or we can return nothing in this function

{
$output = [];
if (count($this->getAll()) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/SearchEndpoint/HighlightEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class HighlightEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
{
if ($this->highlight) {
return $this->highlight->toArray();
}

return null;
GinoPane marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/InnerHitsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class InnerHitsEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
{
$output = [];
if (count($this->getAll()) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/SearchEndpoint/PostFilterEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class PostFilterEndpoint extends QueryEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
{
if (!$this->getBool()) {
return null;
return false;
}

return $this->getBool()->toArray();
Expand Down
4 changes: 2 additions & 2 deletions src/SearchEndpoint/QueryEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class QueryEndpoint extends AbstractSearchEndpoint implements OrderedNormalizerI
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
{
if (!$this->filtersSet && $this->hasReference('filter_query')) {
/** @var BuilderInterface $filter */
Expand All @@ -49,7 +49,7 @@ public function normalize(NormalizerInterface $normalizer, string $format = null
}

if (!$this->bool) {
return null;
return false;
}

return $this->bool->toArray();
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/SortEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SortEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
{
$output = [];

Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/SuggestEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SuggestEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = []): array|string|int|float|bool
{
$output = [];
if (count($this->getAll()) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/Serializer/Normalizer/CustomReferencedNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CustomReferencedNormalizer extends CustomNormalizer
/**
* {@inheritdoc}
*/
public function normalize($object, string $format = null, array $context = [])
public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
$object->setReferences($this->references);
$data = parent::normalize($object, $format, $context);
Expand All @@ -38,7 +38,7 @@ public function normalize($object, string $format = null, array $context = [])
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
public function supportsNormalization(mixed $data, string $format = null): bool
{
return $data instanceof AbstractNormalizable;
}
Expand Down
5 changes: 3 additions & 2 deletions src/Serializer/OrderedSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OrderedSerializer extends Serializer
/**
* {@inheritdoc}
*/
public function normalize($data, $format = null, array $context = [])
public function normalize(mixed $data, string $format = null, array $context = []): array|string|int|float|bool|\ArrayObject|null
{
return parent::normalize(
is_array($data) ? $this->order($data) : $data,
Expand All @@ -34,7 +34,7 @@ public function normalize($data, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
public function denormalize($data, $type, $format = null, array $context = [])
public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
{
return parent::denormalize(
is_array($data) ? $this->order($data) : $data,
Expand Down Expand Up @@ -86,3 +86,4 @@ function ($value) {
);
}
}