Skip to content

Commit

Permalink
bug #18072 [serializer][ObjectNormalizer] fixed Undefined attributeNa…
Browse files Browse the repository at this point in the history
…me. (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.
  • Loading branch information
fabpot committed Mar 10, 2016
2 parents 15bb452 + ee087a1 commit 1887261
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -57,6 +57,7 @@ protected function extractAttributes($object, $format = null, array $context = a
}

$name = $reflMethod->name;
$attributeName = null;

if (0 === strpos($name, 'get') || 0 === strpos($name, 'has')) {
// getters and hassers
Expand All @@ -66,7 +67,7 @@ protected function extractAttributes($object, $format = null, array $context = a
$attributeName = lcfirst(substr($name, 2));
}

if ($this->isAllowedAttribute($object, $attributeName)) {
if (null !== $attributeName && $this->isAllowedAttribute($object, $attributeName)) {
$attributes[$attributeName] = true;
}
}
Expand Down

0 comments on commit 1887261

Please sign in to comment.