Skip to content

Commit 3ed8637

Browse files
committed
Handle possible propertyName of type int
1 parent 75c54d9 commit 3ed8637

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/JsonMapper.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use function array_key_exists;
3131
use function in_array;
3232
use function is_array;
33+
use function is_object;
3334

3435
/**
3536
* JsonMapper.
@@ -202,7 +203,7 @@ public function map($json, ?string $className = null, ?string $collectionClassNa
202203

203204
// Process all children
204205

205-
/** @var string $propertyName */
206+
/** @var string|int $propertyName */
206207
foreach ($json as $propertyName => $propertyValue) {
207208
// Replaces the property name with another one
208209
if ($this->isReplacePropertyAnnotation($className)) {
@@ -219,7 +220,9 @@ public function map($json, ?string $className = null, ?string $collectionClassNa
219220
}
220221
}
221222

222-
if ($this->nameConverter instanceof PropertyNameConverterInterface) {
223+
if (is_string($propertyName)
224+
&& ($this->nameConverter instanceof PropertyNameConverterInterface)
225+
) {
223226
$propertyName = $this->nameConverter->convert($propertyName);
224227
}
225228

0 commit comments

Comments
 (0)