[Serializer] Take unnamed variadic parameters into account when denormalizing#53361
[Serializer] Take unnamed variadic parameters into account when denormalizing#53361nicolas-grekas merged 1 commit intosymfony:5.4from
Conversation
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
|
This was caused by #53115, sorry about that. IMO, the best solution would be to avoid using named arguments when the function is variadic: index 1a7c314b84..27224f5b3d 100644
--- a/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
+++ b/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
@@ -372,7 +372,7 @@ abstract class AbstractNormalizer implements NormalizerInterface, DenormalizerIn
$variadicParameters[$parameterKey] = $this->denormalizeParameter($reflectionClass, $constructorParameter, $paramName, $parameterData, $context, $format);
}
- $params = array_merge($params, $variadicParameters);
+ $params = array_merge(array_values($params), $variadicParameters);
$unsetKeys[] = $key;
}
} elseif ($allowed && !$ignored && (isset($data[$key]) || \array_key_exists($key, $data))) { |
|
No worries! This gave me the chance to contribute for the first time :) |
|
I don't understand where the code standard errors are coming from. The patch provided changes things that have been there since 2018? |
Don't worry about it, most are false positives. Just revert the coding standard changes on lines you didn't modify. |
src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
Outdated
Show resolved
Hide resolved
8000
src/Symfony/Component/Serializer/Tests/Fixtures/DummyWithWithVariadicParameterConstructor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Tests/Fixtures/DummyWithWithVariadicParameterConstructor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Tests/Fixtures/DummyWithWithVariadicParameterConstructor.php
Outdated
Show resolved
Hide resolved
|
@thijsBreker It would be good to remove WIP from the title. |
…malizing We shouldn't break when a constructor has variadic parameters without named keys in the array.
|
Thank you @thijsBreker. |
We shouldn't break when a constructor has variadic parameters without named keys in the array.