Skip to content

Commit af1e136

Browse files
committed
MetadataAwareNameConverter: Do not assume that property names are strings
1 parent 75b1157 commit af1e136

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function denormalize($propertyName, string $class = null, string $format
6969
return self::$denormalizeCache[$class][$propertyName] ?? $this->denormalizeFallback($propertyName, $class, $format, $context);
7070
}
7171

72-
private function getCacheValueForNormalization(string $propertyName, string $class): ?string
72+
private function getCacheValueForNormalization($propertyName, string $class)
7373
{
7474
if (!$this->metadataFactory->hasMetadataFor($class)) {
7575
return null;
@@ -83,12 +83,12 @@ private function getCacheValueForNormalization(string $propertyName, string $cla
8383
return $attributesMetadata[$propertyName]->getSerializedName() ?? null;
8484
}
8585

86-
private function normalizeFallback(string $propertyName, string $class = null, string $format = null, array $context = []): string
86+
private function normalizeFallback($propertyName, string $class = null, string $format = null, array $context = [])
8787
{
8888
return $this->fallbackNameConverter ? $this->fallbackNameConverter->normalize($propertyName, $class, $format, $context) : $propertyName;
8989
}
9090

91-
private function getCacheValueForDenormalization(string $propertyName, string $class): ?string
91+
private function getCacheValueForDenormalization($propertyName, string $class)
9292
{
9393
if (!isset(self::$attributesMetadataCache[$class])) {
9494
self::$attributesMetadataCache[$class] = $this->getCacheValueForAttributesMetadata($class);
@@ -97,7 +97,7 @@ private function getCacheValueForDenormalization(string $propertyName, string $c
9797
return self::$attributesMetadataCache[$class][$propertyName] ?? null;
9898
}
9999

100-
private function denormalizeFallback(string $propertyName, string $class = null, string $format = null, array $context = []): string
100+
private function denormalizeFallback($propertyName, string $class = null, string $format = null, array $context = [])
101101
{
102102
return $this->fallbackNameConverter ? $this->fallbackNameConverter->denormalize($propertyName, $class, $format, $context) : $propertyName;
103103
}

src/Symfony/Component/Serializer/Tests/NameConverter/MetadataAwareNameConverterTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function attributeProvider()
102102
['foo', 'baz'],
103103
['bar', 'qux'],
104104
['quux', 'quux'],
105+
[0, 0],
105106
];
106107
}
107108

@@ -111,6 +112,7 @@ public function fallbackAttributeProvider()
111112
['foo', 'baz'],
112113
['bar', 'qux'],
113114
['quux', 'QUUX'],
115+
[0, 0],
114116
];
115117
}
116118
}

0 commit comments

Comments
 (0)