Skip to content

Commit f783a7c

Browse files
Merge branch '6.2' into 6.3
* 6.2: [PhpUnitBridge] Kill the last concurrent process when it stales for more than 60s [Intl] fix test [Intl] Use VarExporter::export() in PhpBundleWriter Use triggering class to generate baseline for deprecation messages from DebugClassLoader [Security] Fix false-string handling in RememberMeAuthenticator [CssSelector] Tests on Xpath translator will always pass [Serializer] Fix Normalizer not utilizing converted name for index variadic param [DepdencyInjection] Fix costly logic when checking errored definitions Fix merge fix children cond [DoctrineBridge] Load refreshed user proxy [DependencyInjection] Don't ignore attributes on the actual decorator [FrameworkBundle] Prevent `cache:clear` to lose files on subsequent runs
2 parents 17e9a03 + d8a80c9 commit f783a7c

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

Normalizer/AbstractNormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ protected function instantiateObject(array &$data, string $class, array &$contex
350350
$ignored = !$this->isAllowedAttribute($class, $paramName, $format, $context);
351351
if ($constructorParameter->isVariadic()) {
352352
if ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) {
353-
if (!\is_array($data[$paramName])) {
353+
if (!\is_array($data[$key])) {
354354
throw new RuntimeException(sprintf('Cannot create an instance of "%s" from serialized data because the variadic parameter "%s" can only accept an array.', $class, $constructorParameter->name));
355355
}
356356

357357
$variadicParameters = [];
358-
foreach ($data[$paramName] as $parameterKey => $parameterData) {
358+
foreach ($data[$key] as $parameterKey => $parameterData) {
359359
$variadicParameters[$parameterKey] = $this->denormalizeParameter($reflectionClass, $constructorParameter, $paramName, $parameterData, $attributeContext, $format);
360360
}
361361

Tests/Normalizer/AbstractNormalizerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory;
2222
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
2323
use Symfony\Component\Serializer\Mapping\Loader\LoaderChain;
24+
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
2425
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
2526
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
2627
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
@@ -178,6 +179,7 @@ public function testObjectWithNullableNonOptionalConstructorArgumentWithoutInput
178179

179180
/**
180181
* @dataProvider getNormalizer
182+
* @dataProvider getNormalizerWithCustomNameConverter
181183
*/
182184
public function testObjectWithVariadicConstructorTypedArguments(AbstractNormalizer $normalizer)
183185
{
@@ -251,6 +253,25 @@ public static function getNormalizer()
251253
yield [new ObjectNormalizer(null, null, null, $extractor)];
252254
}
253255

256+
public static function getNormalizerWithCustomNameConverter()
257+
{
258+
$extractor = new PhpDocExtractor();
259+
$nameConverter = new class() implements NameConverterInterface {
260+
public function normalize(string $propertyName): string
261+
{
262+
return ucfirst($propertyName);
263+
}
264+
265+
public function denormalize(string $propertyName): string
266+
{
267+
return lcfirst($propertyName);
268+
}
269+
};
270+
271+
yield [new PropertyNormalizer(null, $nameConverter, $extractor)];
272+
yield [new ObjectNormalizer(null, $nameConverter, null, $extractor)];
273+
}
274+
254275
public function testIgnore()
255276
{
256277
$classMetadata = new ClassMetadata(IgnoreDummy::class);

0 commit comments

Comments
 (0)