Skip to content

Commit c85bf74

Browse files
committed
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.
2 parents 306fb42 + bc74b7b commit c85bf74

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Normalizer/ObjectNormalizer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ protected function extractAttributes($object, $format = null, array $context = a
5757
}
5858

5959
$name = $reflMethod->name;
60+
$attributeName = null;
6061

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

69-
if ($this->isAllowedAttribute($object, $attributeName)) {
70+
if (null !== $attributeName && $this->isAllowedAttribute($object, $attributeName)) {
7071
$attributes[$attributeName] = true;
7172
}
7273
}

0 commit comments

Comments
 (0)