Skip to content

Commit cc6bfea

Browse files
committed
bug #30749 [Serializer] Added check of constuctor modifiers to AbstractNormalizer (NekaKawaii)
This PR was submitted for the 4.2 branch but it was merged into the 3.4 branch instead (closes #30749). Discussion ---------- [Serializer] Added check of constuctor modifiers to AbstractNormalizer | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30748 | License | MIT If constructor is not public, instantiate target object without constructor to prevent errors like `Access to non-public constructor of class Target` Commits ------- eb0e14c [Serializer] Added check of constuctor modifiers to AbstractNormalizer
2 parents 2b73460 + eb0e14c commit cc6bfea

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php

+4
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref
333333

334334
$constructor = $this->getConstructor($data, $class, $context, $reflectionClass, $allowedAttributes);
335335
if ($constructor) {
336+
if (true !== $constructor->isPublic()) {
337+
return $reflectionClass->newInstanceWithoutConstructor();
338+
}
339+
336340
$constructorParameters = $constructor->getParameters();
337341

338342
$params = [];

0 commit comments

Comments
 (0)