Skip to content

Commit

Permalink
bug #30749 [Serializer] Added check of constuctor modifiers to Abstra…
Browse files Browse the repository at this point in the history
…ctNormalizer (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
  • Loading branch information
fabpot committed Mar 30, 2019
2 parents 2b73460 + eb0e14c commit cc6bfea
Showing 1 changed file with 4 additions and 0 deletions.
Expand Up @@ -333,6 +333,10 @@ protected function instantiateObject(array &$data, $class, array &$context, \Ref

$constructor = $this->getConstructor($data, $class, $context, $reflectionClass, $allowedAttributes);
if ($constructor) {
if (true !== $constructor->isPublic()) {
return $reflectionClass->newInstanceWithoutConstructor();
}

$constructorParameters = $constructor->getParameters();

$params = [];
Expand Down

0 comments on commit cc6bfea

Please sign in to comment.