8000 update · symfony/symfony@1373073 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1373073

Browse files
update
1 parent 344f6f5 commit 1373073

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ public function normalize(string $propertyName, ?string $class = null, ?string $
4747

4848
public function denormalize(string $propertyName, ?string $class = null, ?string $format = null, array $context = []): string
4949
{
50+
if (($context[self::REQUIRE_SNAKE_CASE_PROPERTIES] ?? false) && $propertyName !== $this->normalize($propertyName, $class, $format, $context)) {
51+
throw new NotNormalizableValueException('Could not denormalize property, snake case format accepted only.');
52+
}
53+
5054
$camelCasedName = preg_replace_callback('/(^|_|\.)+(.)/', fn ($match) => ('.' === $match[1] ? '_' : '').strtoupper($match[2]), $propertyName);
5155

5256
if ($this->lowerCamelCase) {
5357
$camelCasedName = lcfirst($camelCasedName);
5458
}
5559

5660
if (null === $this->attributes || \in_array($camelCasedName, $this->attributes, true)) {
57-
if (($context[self::REQUIRE_SNAKE_CASE_PROPERTIES] ?? false) && $propertyName !== $this->normalize($propertyName, $class, $format, $context)) {
58-
throw new NotNormalizableValueException('Could not denormalize property, snake case format accepted only.');
59-
}
60-
6161
return $camelCasedName;
6262
}
6363

0 commit comments

Comments
 (0)
0