Skip to content

Commit

Permalink
fixing that PropertyNormalizer supports parent properties
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-hertel committed Nov 20, 2017
1 parent 1b6597d commit a879e4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Expand Up @@ -60,11 +60,13 @@ private function supports($class)
$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;
}
Expand Down
Expand Up @@ -441,6 +441,11 @@ public function testMaxDepth()

$this->assertEquals($expected, $result);
}

public function testInheritedPropertiesSupport()
{
$this->assertTrue($this->normalizer->supportsNormalization(new PropertyChildDummy()));
}
}

class PropertyDummy
Expand Down Expand Up @@ -509,3 +514,12 @@ class StaticPropertyDummy
{
private static $property = 'value';
}

class PropertyParentDummy
{
private $foo = 'bar';
}

class PropertyChildDummy extends PropertyParentDummy
{
}

0 comments on commit a879e4f

Please sign in to comment.