Commit c89ed3ec authored by Guillaume Perréal's avatar Guillaume Perréal

N'affiche pas les accesseurs.

parent f7cf7bc6
......@@ -28,7 +28,7 @@ class MethodDecorator implements DecoratorInterface
foreach($class->getMethods() as $method) {
/* @var $method ReflectionMethod */
if ($method->getDeclaringClass() != $class) {
if ($method->getDeclaringClass() != $class || $this->isAccessor($method, $class)) {
continue;
}
......@@ -44,4 +44,28 @@ class MethodDecorator implements DecoratorInterface
);
}
}
/**
* @param ReflectionMethod $method
* @param ReflectionClass $class
* @return boolean
*/
protected function isAccessor(ReflectionMethod $method, ReflectionClass $class)
{
if (!$method->isPublic() || $method->isAbstract() || $method->getDeclaringClass()->isInterface()) {
return false;
}
if ($method->getNumberOfParameters() === 0 && preg_match('/(?:get|is)(\w+)/', $method->getName(), $groups)) {
$name = lcfirst($groups[1]);
} elseif ($method->getNumberOfParameters() === 1 && preg_match('/(?:set|add|remove)(\w+)/', $method->getName(), $groups)) {
$name = lcfirst($groups[1]);
} else {
return false;
}
if (!$class->hasProperty($name)) {
return false;
}
$property = $class->getProperty($name);
return $property->isStatic() == $method->isStatic();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment