19
19
* @author Kévin Dunglas <dunglas@gmail.com>
20
20
* @author Aurélien Pillevesse <aurelienpillevesse@hotmail.fr>
21
21
*/
22
- class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface
22
+ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface, AdvancedNameConverterInterface
23
23
{
24
24
/**
25
25
* Require all properties to be written in snake_case.
@@ -41,7 +41,7 @@ public function __construct(
41
41
* @param string|null $format
42
42
* @param array<string, mixed> $context
43
43
*/
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
45
45
{
46
46
if (null === $ this ->attributes || \in_array ($ propertyName , $ this ->attributes , true )) {
47
47
return strtolower (preg_replace ('/[A-Z]/ ' , '_ \\0 ' , lcfirst ($ propertyName )));
@@ -55,12 +55,8 @@ public function normalize(string $propertyName/* , ?string $class = null, ?strin
55
55
* @param string|null $format
56
56
* @param array<string, mixed> $context
57
57
*/
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
59
59
{
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
-
64
60
if (($ context [self ::REQUIRE_SNAKE_CASE_PROPERTIES ] ?? false ) && $ propertyName !== $ this ->normalize ($ propertyName , $ class , $ format , $ context )) {
65
61
throw new UnexpectedPropertyException ($ propertyName );
66
62
}
0 commit comments