Skip to content

Commit 576126a

Browse files
committed
Ensure property is accessible before checking initialization
1 parent c5a380e commit 576126a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/Serializer/Normalizer/PropertyNormalizer.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,14 @@ protected function extractAttributes($object, $format = null, array $context = [
103103

104104
do {
105105
foreach ($reflectionObject->getProperties() as $property) {
106-
if ($checkPropertyInitialization && !$property->isInitialized($object)) {
107-
continue;
106+
if ($checkPropertyInitialization) {
107+
if (!$property->isPublic()) {
108+
$property->setAccessible(true);
109+
}
110+
111+
if (!$property->isInitialized($object)) {
112+
continue;
113+
}
108114
}
109115

110116
if (!$this->isAllowedAttribute($reflectionObject->getName(), $property->name, $format, $context)) {

0 commit comments

Comments
 (0)