/** * @param \Reflector $reflection * @param string $type * If we are not reflecting the class itself, specify "Method", "Property", etc. * * @return array */ public static function getCodeDocs($reflection, $type = NULL) { $docs = self::parseDocBlock($reflection->getDocComment()); // Recurse into parent functions if (isset($docs['inheritDoc'])) { unset($docs['inheritDoc']); $newReflection = NULL; try { if ($type) { $name = $reflection->getName(); $reflectionClass = $reflection->getDeclaringClass()->getParentClass(); if ($reflectionClass) { $getItem = "get{$type}"; $newReflection = $reflectionClass->{$getItem}($name); } } else { $newReflection = $reflection->getParentClass(); } } catch (\ReflectionException $e) { } if ($newReflection) { // Mix in $additionalDocs = self::getCodeDocs($newReflection, $type); if (!empty($docs['comment']) && !empty($additionalDocs['comment'])) { $docs['comment'] .= "\n\n" . $additionalDocs['comment']; } $docs += $additionalDocs; } } return $docs; }
/** * * @return array */ public function heritedMethods() { if (!$this->reflector instanceof Reflection\ReflectionClass) { return array(); } $parent = $this->reflector->getParentClass(); if (empty($parent)) { return array(); } $methods = array(); $this->getParentMethods($parent, $methods); return $methods; }
function annotateParent(\Reflector $refl) { $parent = $refl->getParentClass(); if ($parent) { return array('parent' => $parent->name); } else { return array(); } }