fixing that PropertyNormalizer supports parent properties
This commit is contained in:
parent
1b6597d19c
commit
a879e4f34b
@ -60,11 +60,13 @@ class PropertyNormalizer extends AbstractObjectNormalizer
|
||||
$class = new \ReflectionClass($class);
|
||||
|
||||
// We look for at least one non-static property
|
||||
foreach ($class->getProperties() as $property) {
|
||||
if (!$property->isStatic()) {
|
||||
return true;
|
||||
do {
|
||||
foreach ($class->getProperties() as $property) {
|
||||
if (!$property->isStatic()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while ($class = $class->getParentClass());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -441,6 +441,11 @@ class PropertyNormalizerTest extends TestCase
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testInheritedPropertiesSupport()
|
||||
{
|
||||
$this->assertTrue($this->normalizer->supportsNormalization(new PropertyChildDummy()));
|
||||
}
|
||||
}
|
||||
|
||||
class PropertyDummy
|
||||
@ -509,3 +514,12 @@ class StaticPropertyDummy
|
||||
{
|
||||
private static $property = 'value';
|
||||
}
|
||||
|
||||
class PropertyParentDummy
|
||||
{
|
||||
private $foo = 'bar';
|
||||
}
|
||||
|
||||
class PropertyChildDummy extends PropertyParentDummy
|
||||
{
|
||||
}
|
||||
|
Reference in New Issue
Block a user