Skip to content

Commit ba5e1d6

Browse files
feature #60870 [Serializer] Remove AdvancedNameConverterInterface (mttsch)
This PR was merged into the 8.0 branch. Discussion ---------- [Serializer] Remove `AdvancedNameConverterInterface` | Q | A | ------------- | --- | Branch? | 8.0 | Bug fix? | no | New feature? | no | Deprecations? | yes | Issues | | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Commits ------- e9a9acd [Serializer] Remove AdvancedNameConverterInterface
2 parents 60318a9 + e9a9acd commit ba5e1d6

File tree

7 files changed

+40
-34
lines changed

7 files changed

+40
-34
lines changed

UPGRADE-8.0.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,22 @@ Serializer
325325
----------
326326

327327
* Remove `AbstractNormalizerContextBuilder::withDefaultContructorArguments()`, use `withDefaultConstructorArguments()` instead
328+
* Change signature of `NameConverterInterface::normalize()` and `NameConverterInterface::denormalize()` methods:
329+
330+
Before:
331+
332+
```php
333+
public function normalize(string $propertyName): string;
334+
public function denormalize(string $propertyName): string;
335+
```
336+
337+
After:
338+
339+
```php
340+
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
341+
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
342+
```
343+
* Remove `AdvancedNameConverterInterface`, use `NameConverterInterface` instead
328344

329345
TwigBridge
330346
----------

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ CHANGELOG
55
---
66

77
* Remove `AbstractNormalizerContextBuilder::withDefaultContructorArguments()`, use `withDefaultConstructorArguments()` instead
8+
* Change signature of `NameConverterInterface::normalize()` and `NameConverterInterface::denormalize()` methods:
9+
10+
Before:
11+
12+
```php
13+
public function normalize(string $propertyName): string;
14+
public function denormalize(string $propertyName): string;
15+
```
16+
17+
After:
18+
19+
```php
20+
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
21+
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
22+
```
23+
* Remove `AdvancedNameConverterInterface`, use `NameConverterInterface` instead
824

925
7.3
1026
---

src/Symfony/Component/Serializer/NameConverter/AdvancedNameConverterInterface.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/Symfony/Component/Serializer/NameConverter/CamelCaseToSnakeCaseNameConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function __construct(
4141
* @param string|null $format
4242
* @param array<string, mixed> $context
4343
*/
44-
public function normalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string
44+
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
4545
{
4646
if (null === $this->attributes || \in_array($propertyName, $this->attributes, true)) {
4747
return strtolower(preg_replace('/[A-Z]/', '_\\0', lcfirst($propertyName)));
@@ -55,7 +55,7 @@ public function normalize(string $propertyName/* , ?string $class = null, ?strin
5555
* @param string|null $format
5656
* @param array<string, mixed> $context
5757
*/
58-
public function denormalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string
58+
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
5959
{
6060
$class = 1 < \func_num_args() ? func_get_arg(1) : null;
6161
$format = 2 < \func_num_args() ? func_get_arg(2) : null;

src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
2020
*/
21-
final class MetadataAwareNameConverter implements AdvancedNameConverterInterface
21+
final class MetadataAwareNameConverter implements NameConverterInterface
2222
{
2323
/**
2424
* @var array<string, array<string, string|null>>

src/Symfony/Component/Serializer/NameConverter/NameConverterInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface NameConverterInterface
2525
* @param string|null $format
2626
* @param array<string, mixed> $context
2727
*/
28-
public function normalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string;
28+
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
2929

3030
/**
3131
* Converts a property name to its denormalized value.
@@ -34,5 +34,5 @@ public function normalize(string $propertyName/* , ?string $class = null, ?strin
3434
* @param string|null $format
3535
* @param array<string, mixed> $context
3636
*/
37-
public function denormalize(string $propertyName/* , ?string $class = null, ?string $format = null, array $context = [] */): string;
37+
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string;
3838
}

src/Symfony/Component/Serializer/Tests/Normalizer/ObjectNormalizerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
2929
use Symfony\Component\Serializer\Mapping\Loader\AttributeLoader;
3030
use Symfony\Component\Serializer\Mapping\Loader\YamlFileLoader;
31-
use Symfony\Component\Serializer\NameConverter\AdvancedNameConverterInterface;
3231
use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter;
3332
use Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter;
33+
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
3434
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
3535
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
3636
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
@@ -779,9 +779,9 @@ public function testDenormalizeFalsePseudoType()
779779
$this->assertFalse($object->canBeFalseOrString);
780780
}
781781

782-
public function testAdvancedNameConverter()
782+
public function testNameConverterProperties()
783783
{
784-
$nameConverter = new class implements AdvancedNameConverterInterface {
784+
$nameConverter = new class implements NameConverterInterface {
785785
public function normalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
786786
{
787787
return \sprintf('%s-%s-%s-%s', $propertyName, $class, $format, $context['foo']);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy