Skip to content

Commit

Permalink
Handle possible propertyName of type int
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsunday committed Aug 2, 2024
1 parent 75c54d9 commit 3ed8637
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/JsonMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use function array_key_exists;
use function in_array;
use function is_array;
use function is_object;

/**
* JsonMapper.
Expand Down Expand Up @@ -202,7 +203,7 @@ public function map($json, ?string $className = null, ?string $collectionClassNa

// Process all children

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

if ($this->nameConverter instanceof PropertyNameConverterInterface) {
if (is_string($propertyName)
&& ($this->nameConverter instanceof PropertyNameConverterInterface)
) {
$propertyName = $this->nameConverter->convert($propertyName);
}

Expand Down

0 comments on commit 3ed8637

Please sign in to comment.