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

N'affiche pas les accesseurs.

No related merge requests found
Showing with 25 additions and 1 deletion
+25 -1
...@@ -28,7 +28,7 @@ class MethodDecorator implements DecoratorInterface ...@@ -28,7 +28,7 @@ class MethodDecorator implements DecoratorInterface
foreach($class->getMethods() as $method) { foreach($class->getMethods() as $method) {
/* @var $method ReflectionMethod */ /* @var $method ReflectionMethod */
if ($method->getDeclaringClass() != $class) { if ($method->getDeclaringClass() != $class || $this->isAccessor($method, $class)) {
continue; continue;
} }
...@@ -44,4 +44,28 @@ class MethodDecorator implements DecoratorInterface ...@@ -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();
}
} }
Supports Markdown
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