Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Remove AdvancedNameConverterInterface #60870

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

Merged
Merged
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
16 changes: 16 additions & 0 deletions UPGRADE-8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,22 @@ Serializer
----------

* Remove `AbstractNormalizerContextBuilder::withDefaultContructorArguments()`, use `withDefaultConstructorArguments()` instead
* Change signature of `NameConverterInterface::normalize()` and `NameConverterInterface::denormalize()` methods:

Before:

```php
public function normalize(string $propertyName): string;
public function denormalize(string $propertyName): string;
```

After:

```php
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
```
* Remove `AdvancedNameConverterInterface`, use `NameConverterInterface` instead

TwigBridge
----------
Expand Down
16 changes: 16 additions & 0 deletions src/Symfony/Component/Serializer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ CHANGELOG
---

* Remove `AbstractNormalizerContextBuilder::withDefaultContructorArguments()`, use `withDefaultConstructorArguments()` instead
* Change signature of `NameConverterInterface::normalize()` and `NameConverterInterface::denormalize()` methods:

Before:

```php
public function normalize(string $propertyName): string;
public function denormalize(string $propertyName): string;
```

After:

```php
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
```
* Remove `AdvancedNameConverterInterface`, use `NameConverterInterface` instead

7.3
---
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(
* @param string|null $format
* @param array<string, mixed> $context
*/
public function normalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
{
if (null === $this->attributes || \in_array($propertyName, $this->attributes, true)) {
return strtolower(preg_replace('/[A-Z]/', '_\\0', lcfirst($propertyName)));
Expand All @@ -55,7 +55,7 @@ public function normalize(string $propertyName/* , ?string $class = null, ?strin
* @param string|null $format
* @param array<string, mixed> $context
*/
public function denormalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
{
$class = 1 < \func_num_args() ? func_get_arg(1) : null;
$format = 2 < \func_num_args() ? func_get_arg(2) : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* @author Fabien Bourigault <[email protected]>
*/
final class MetadataAwareNameConverter implements AdvancedNameConverterInterface
final class MetadataAwareNameConverter implements NameConverterInterface
{
/**
* @var array<string, array<string, string|null>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface NameConverterInterface
* @param string|null $format
* @param array<string, mixed> $context
*/
public function normalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string;
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;

/**
* Converts a property name to its denormalized value.
Expand All @@ -34,5 +34,5 @@ public function normalize(string $propertyName/* , ?string $class = null, ?strin
* @param string|null $format
* @param array<string, mixed> $context
*/
public function denormalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string;
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
Expand Down Expand Up @@ -779,9 +779,9 @@ public function testDenormalizeFalsePseudoType()
$this->assertFalse($object->canBeFalseOrString);
}

public function testAdvancedNameConverter()
public function testNameConverterProperties()
{
$nameConverter = new class implements AdvancedNameConverterInterface {
$nameConverter = new class implements NameConverterInterface {
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
{
return \sprintf('%s-%s-%s-%s', $propertyName, $class, $format, $context['foo']);
Expand Down
Loading