Skip to content

Commit f875bdb

Browse files
committed
[Serializer] Re-add AdvancedNameConverterInterface as deprecated
1 parent 180f389 commit f875bdb

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* Gives access to the class, the format and the context in the property name converters.
1616
*
1717
* @author Kévin Dunglas <dunglas@gmail.com>
18+
*
19+
* @deprecated since Symfony 7.1, use NameConverterInterface instead
1820
*/
1921
interface AdvancedNameConverterInterface extends NameConverterInterface
2022
{

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

+3-7
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* @author Kévin Dunglas <dunglas@gmail.com>
2020
* @author Aurélien Pillevesse <aurelienpillevesse@hotmail.fr>
2121
*/
22-
class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
22+
class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface, AdvancedNameConverterInterface
2323
{
2424
/**
2525
* Require all properties to be written in snake_case.
@@ -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,12 +55,8 @@ 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
{
60-
$class = 1 < \func_num_args() ? func_get_arg(1) : null;
61-
$format = 2 < \func_num_args() ? func_get_arg(2) : null;
62-
$context = 3 < \func_num_args() ? func_get_arg(3) : [];
63-
6460
if (($context[self::REQUIRE_SNAKE_CASE_PROPERTIES] ?? false) && $propertyName !== $this->normalize($propertyName, $class, $format, $context)) {
6561
throw new UnexpectedPropertyException($propertyName);
6662
}

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

+1-1
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 NameConverterInterface
21+
final class MetadataAwareNameConverter implements NameConverterInterface, AdvancedNameConverterInterface
2222
{
2323
/**
2424
* @var array<string, array<string, string|null>>

0 commit comments

Comments
 (0)