Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1887261

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 15bb452 + ee087a1 commit 1887261

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/Symfony/Component/Serializer/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)