public static function buildFromReflection(\ReflectionClass $reflection) { $class = new self($reflection->getShortName()); $class->setNamespace($reflection->getNamespaceName()); $reflectionParentClass = $reflection->getParentClass(); if ($reflectionParentClass) { $class->setParentClassName($reflectionParentClass->getName()); } $class->setAbstract($reflection->isAbstract()); if ($interfaces = $reflection->getInterfaceNames()) { if ($reflectionParentClass) { $parentInterfaces = $reflection->getParentClass()->getInterfaceNames(); $interfaces = array_diff($interfaces, $parentInterfaces); } $class->setInterfaces($interfaces); } foreach ($reflection->getMethods() as $reflectionMethod) { if ($reflectionMethod->getDeclaringClass() == $reflection) { $method = MethodBlock::buildFromReflection($reflectionMethod); $class->addMethod($method); } } foreach ($reflection->getProperties() as $reflectionProperty) { if ($reflectionProperty->getDeclaringClass() == $reflection) { $property = PropertyBlock::buildFromReflection($reflectionProperty); $class->addProperty($property); } } foreach ($reflection->getConstants() as $name => $value) { if (!$reflection->getParentClass()->hasConstant($name)) { $class->addConstant(new ConstantBlock($name, $value)); } } return $class; }