Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ private function isGetMethod(\ReflectionMethod $method)
!$method->isStatic() &&
(
((0 === strpos($method->name, 'get') && 3 < $methodLength) ||
(0 === strpos($method->name, 'is') && 2 < $methodLength)) &&
(0 === strpos($method->name, 'is') && 2 < $methodLength) ||
(0 === strpos($method->name, 'has') && 3 < $methodLength)) &&
0 === $method->getNumberOfRequiredParameters()
)
;
Expand Down Expand Up @@ -133,6 +134,11 @@ protected function getAttributeValue($object, $attribute, $format = null, array
if (is_callable(array($object, $isser))) {
return $object->$isser();
}

$haser = 'has'.$ucfirsted;
if (is_callable(array($object, $haser))) {
return $object->$haser();
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,23 @@ public function testPrivateSetter()
$this->assertEquals('bar', $obj->getFoo());
}

public function testHasGetterDenormalize()
{
$obj = $this->normalizer->denormalize(array('foo' => true), ObjectWithHasGetterDummy::class);
$this->assertTrue($obj->hasFoo());
}

public function testHasGetterNormalize()
{
$obj = new ObjectWithHasGetterDummy();
$obj->setFoo(true);

$this->assertEquals(
array('foo' => true),
$this->normalizer->normalize($obj, 'any')
);
}

public function testMaxDepth()
{
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
Expand Down Expand Up @@ -807,3 +824,18 @@ public static function setFoo($foo)
self::$foo = $foo;
}
}

class ObjectWithHasGetterDummy
{
private $foo;

public function setFoo($foo)
{
$this->foo = $foo;
}

public function hasFoo()
{
return $this->foo;
}
}