Skip to content

Commit

Permalink
BUGFIX: Ensure the schema denormalizer passes the arguments by name a…
Browse files Browse the repository at this point in the history
…nd not by position.
  • Loading branch information
mficzel committed Jun 19, 2024
1 parent 37761e9 commit 1b50e50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Classes/Domain/Schema/SchemaDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ private static function convertValueObject(array|int|float|string|bool $value, s
$parameterReflections = $reflection->getConstructor()->getParameters();
$convertedArguments = [];
if (is_array($value)) {
foreach ($parameterReflections as $name => $reflectionParameter) {
foreach ($parameterReflections as $reflectionParameter) {
$name = $reflectionParameter->getName();
$type = $reflectionParameter->getType();
if ($reflectionParameter->isDefaultValueAvailable() && !array_key_exists($reflectionParameter->getName(), $value)) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Domain/Schema/SchemaNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function denormalizeObjectsWithOptionalParametersDataProvider(): \
];
yield 'PostalAddress with missing parameter in between' => [
Fixtures\PostalAddress::class,
['streetAddress' => 'Dämonenweg 23', 'addressRegion' => 'Hölle', 'postOfficeBoxNumber' => 666],
['streetAddress' => 'Dämonenweg 23', 'addressRegion' => 'Hölle', 'postOfficeBoxNumber' => '666'],
new Fixtures\PostalAddress(streetAddress: 'Dämonenweg 23', addressRegion: 'Hölle', postOfficeBoxNumber: '666')
];
}
Expand Down

0 comments on commit 1b50e50

Please sign in to comment.