bug #18072 [serializer][ObjectNormalizer] fixed Undefined attributeName. (aitboudad)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[serializer][ObjectNormalizer] fixed Undefined attributeName.

| Q             | A
| ------------- | ---
| Branch        | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | ~
| License       | MIT
| Doc PR        | ~

Commits
-------

ee087a1 [serializer][ObjectNormalizer] fixed Undefined attributeName.
This commit is contained in:
Fabien Potencier 2016-03-10 16:30:15 +01:00
commit 188726199b

View File

@ -57,6 +57,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer
}
$name = $reflMethod->name;
$attributeName = null;
if (0 === strpos($name, 'get') || 0 === strpos($name, 'has')) {
// getters and hassers
@ -66,7 +67,7 @@ class ObjectNormalizer extends AbstractObjectNormalizer
$attributeName = lcfirst(substr($name, 2));
}
if ($this->isAllowedAttribute($object, $attributeName)) {
if (null !== $attributeName && $this->isAllowedAttribute($object, $attributeName)) {
$attributes[$attributeName] = true;
}
}