8000 fixing that PropertyNormalizer supports parent properties · symfony/symfony@a879e4f · GitHub
[go: up one dir, main page]

Skip to content

Commit a879e4f

Browse files
committed
fixing that PropertyNormalizer supports parent properties
1 parent 1b6597d commit a879e4f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,13 @@ private function supports($class)
6060
$class = new \ReflectionClass($class);
6161

6262
// We look for at least one non-static property
63-
foreach ($class->getProperties() as $property) {
64-
if (!$property->isStatic()) {
65-
return true;
63+
do {
64+
foreach ($class->getProperties() as $property) {
65+
if (!$property->isStatic()) {
66+
return true;
67+
}
6668
}
67-
}
69+
} while ($class = $class->getParentClass());
6870

6971
return false;
7072
}

src/Symfony/Component/Serializer/Tests/Normalizer/PropertyNormalizerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,11 @@ public function testMaxDepth()
441441

442442
$this->assertEquals($expected, $result);
443443
}
444+
445+
public function testInheritedPropertiesSupport()
446+
{
447+
$this->assertTrue($this->normalizer->supportsNormalization(new PropertyChildDummy()));
448+
}
444449
}
445450

446451
class PropertyDummy
@@ -509,3 +514,12 @@ class StaticPropertyDummy
509514
{
510515
private static $property = 'value';
511516
}
517+
518+
class PropertyParentDummy
519+
{
520+
private $foo = 'bar';
521+
}
522+
523+
class PropertyChildDummy extends PropertyParentDummy
524+
{
525+
}

0 commit comments

Comments
 (0)
0