Build the class hierarchy tree which is placed at the top of the page.

@param RootDoc rootDoc The root doc
@param ClassDoc class Class to generate tree for
@param int depth Depth of recursion
@return mixed[]
499774
public function _buildTree(&$rootDoc, &$class, $depth = NULL)
    {
        if ($depth === NULL) {
            $start = TRUE;
            $depth = 0;
        } else {
            $start = FALSE;
        }
        $output = '';
        $undefinedClass = FALSE;
        if ($class->superclass()) {
            $superclass =& $rootDoc->classNamed($class->superclass());
            if ($superclass) {
                $result = $this->_buildTree($rootDoc, $superclass, $depth);
                $output .= $result[0];
                $depth = ++$result[1];
            } else {
                $output .= $class->superclass().'<br>';
                $output .= str_repeat('   ', $depth).' └─';
                $depth++;
                $undefinedClass = TRUE;
            }
        }
        if ($depth > 0 && !$undefinedClass) {
            $output .= str_repeat('   ', $depth).' └─';
        }
        if ($start) {
            $output .= '<strong>'.$class->name().'</strong><br />';
        } else {
            $output .= '<a href="'.str_repeat('../', $this->_depth).$class->asPath().'">'.$class->name().'</a><br>';
        }

        return array($output, $depth);
    }
1242481
private static function getDocsFiles(string $projectRootDirectory): array
    {
        $files = [];
        $dir   = $projectRootDirectory . '/docs';
        if (!is_dir($dir)) {
            return $files;
        }
        $directory = new \RecursiveDirectoryIterator($dir);
        $recursive = new \RecursiveIteratorIterator($directory);
        $regex     = new \RegexIterator(
            $recursive,
            '/^.+\.md/i',
            \RecursiveRegexIterator::GET_MATCH
        );
        foreach ($regex as $file) {
            if ('' !== $file[0]) {
                $files[] = $file[0];
            }
        }

        return $files;
    }
1360235
private static Method[] getAllDeclaredMethods(Class<?> classHierarchy)
    {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        Collection<MethodMap.MethodInfo> methodInfos = MethodMap.getAllDeclaredMethods(classHierarchy);
        Method[] methods = new Method[methodInfos.size()];
        int index = 0;

        for (MethodMap.MethodInfo methodInfo : methodInfos)
        {
            Method method = methodInfo.getMethod();
            if (isTraceOn && tc.isDebugEnabled())
                Tr.debug(tc, "adding method " + method);
            methods[index++] = method;
        }

        return methods;
    }
232734
private function buildDirectories(SimpleXMLElement $phpDocumentor): array
    {
        if ((array) $phpDocumentor->files === []) {
            return $this->directories;
        }

        if ((string) $phpDocumentor->files->directory === '') {
            return $this->directories;
        }

        return (array) $phpDocumentor->files->directory;
    }
317641
public function getFirstDescendantNode(...$classNames) {
        foreach ($this->getDescendantNodes() as $descendant) {
            foreach ($classNames as $className) {
                if ($descendant instanceof $className) {
                    return $descendant;
                }
            }
        }
        return null;
    }
839286
protected function coalesceDescendants($class)
    {
        // Reset descendents to immediate children initially
        $lowerClass = strtolower($class);
        if (empty($this->children[$lowerClass])) {
            return [];
        }

        // Coalasce children into descendent list
        $this->descendants[$lowerClass] = $this->children[$lowerClass];
        foreach ($this->children[$lowerClass] as $childClass) {
            // Merge all nested descendants
            $this->descendants[$lowerClass] = array_merge(
                $this->descendants[$lowerClass],
                $this->coalesceDescendants($childClass)
            );
        }
        return $this->descendants[$lowerClass];
    }
14363
public function descendants($includeSelf = false, $depth = null)
    {
        $this->filter([
            'lft__gte' => $this->getModel()->lft,
            'rgt__lte' => $this->getModel()->rgt,
            'root' => $this->getModel()->root,
        ])->order(['lft']);

        if (false === $includeSelf) {
            $this->exclude([
                'pk' => $this->getModel()->pk,
            ]);
        }

        if (null !== $depth) {
            $this->filter([
                'level__lte' => $this->getModel()->level + $depth,
            ]);
        }

        return $this;
    }
920133
public static function getDocumentRoot() {
    if(null === self::$docRoot) {
      self::$docRoot = System::realPath($_SERVER['DOCUMENT_ROOT']);
      if(!self::$docRoot) {
        self::$docRoot = System::realPath(getcwd());
      }
    }
    return self::$docRoot;
  }
891784
public function getParentsList()
    {
        /** @var static $root */
        $root  = static::root();
        $items = [
            ['id' => '1', 'title' => 'Item Root'],
        ];
        $nodes = $root->descendants();
        if ($this->exists) {
            $nodes->where('navigation_id', $this->navigation_id)->where('id', '<>', $this->id);
        }

        foreach ($nodes->get() as $node) {
            foreach ($node->getDescendantsAndSelf()->toHierarchy() as $menu) {
                $this->appendMenu($menu, $items);
            }
        }

        return array_pluck($items, 'title', 'id');
    }
255551
public void buildClassDoc(XMLNode node, Content contentTree) throws Exception {
         String key;
         if (isInterface) {
             key =  "doclet.Interface";
         } else if (isEnum) {
             key = "doclet.Enum";
         } else {
             key =  "doclet.Class";
         }
         contentTree = writer.getHeader(configuration.getText(key) + " " +
                 classDoc.name());
         Content classContentTree = writer.getClassContentHeader();
         buildChildren(node, classContentTree);
         writer.addClassContentTree(contentTree, classContentTree);
         writer.addFooter(contentTree);
         writer.printDocument(contentTree);
         writer.close();
         copyDocFiles();
     }
1079471
public ClassDoc[] allClasses(PackageDoc pkgDoc) {
        return pkgDoc.isIncluded() ?
              pkgDoc.allClasses() :
              getArray(allClasses, utils.getPackageName(pkgDoc));
    }
189040
private function findClasses()
    {
        $classes       = array();
        $namespaceName = $this->getName();
        // classes can be only top-level nodes in the namespace, so we can scan them directly
        foreach ($this->namespaceNode->stmts as $namespaceLevelNode) {
            if ($namespaceLevelNode instanceof ClassLike) {
                $classShortName = $namespaceLevelNode->name->toString();
                $className = $namespaceName ? $namespaceName .'\\' . $classShortName : $classShortName;

                $namespaceLevelNode->setAttribute('fileName', $this->fileName);
                $classes[$className] = new ReflectionClass($className, $namespaceLevelNode);
            }
        }

        return $classes;
    }
683923
protected function listCalcDepth($pageUid, array $rootLineRaw, $depth = null)
    {
        if ($depth === null) {
            $depth = 1;
        }

        if (empty($rootLineRaw[$pageUid])) {
            // found root page
            return $depth;
        }

        // we must be at least in the first depth
        ++$depth;

        $pagePid = $rootLineRaw[$pageUid];

        if (!empty($pagePid)) {
            // recursive
            $depth = $this->listCalcDepth($pagePid, $rootLineRaw, $depth);
        }

        return $depth;
    }
975656
private static List<Class<?>> getClassHierarchy(Class<?> clazz) {
		List<Class<?>> hierarchy = new ArrayList<Class<?>>( 4 );

		for ( Class<?> current = clazz; current != null; current = current.getSuperclass() ) {
			hierarchy.add( current );
		}

		return hierarchy;
	}
940312
public Content getSummaryTableTree(ClassDoc classDoc, List<Content> tableContents) {
        return writer.getSummaryTableTree(this, classDoc, tableContents, showTabs());
    }
519856
public function getDescendants($depth = null)
    {
        if(!$this->hasChildren())
        {
            return array();
        }

        if($this->descendants === null)
        {
            $qb = $this->getManager()->getConfiguration()->getBaseQueryBuilder();
            $alias = $this->getManager()->getConfiguration()->getQueryBuilderAlias();

            $qb->andWhere("$alias.".$this->getLeftFieldName()." > :lft1")
                ->setParameter('lft1', $this->getLeftValue())
                ->andWhere("$alias.".$this->getRightFieldName()." < :rgt1")
                ->setParameter('rgt1', $this->getRightValue())
                ->orderBy("$alias.".$this->getLeftFieldName(), "ASC");
            if($this->hasManyRoots())
            {
                $qb->andWhere("$alias.".$this->getRootFieldName()." = :root")
                    ->setParameter('root', $this->getRootValue());
            }

            // TODO: Add depth support or self join support?
			$q = $qb->getQuery();
			if ($this->getManager()->getConfiguration()->isQueryHintSet()){
				$q = $this->getManager()->addHintToQuery($q);
			}
            $results = $q->getResult();

            $this->descendants = array();
            foreach($results as $result)
            {
                $this->descendants[] = $this->getManager()->wrapNode($result);
            }
        }

        if($depth !== null)
        {
            // TODO: Don't rebuild filtered array everytime?
            return $this->getManager()->filterNodeDepth($this->descendants, $depth);
        }

        return $this->descendants;
    }
805440
public function getFields()
    {
        $hierarchy = [];
        foreach ($this->def->getTarget()->getFields() as $field) {
            $hierarchy = array_merge_recursive(
                $hierarchy,
                $this->createFieldHierarchyRecursive($field, $field->getName())
            );
        }

        $fields = [];

        /*******
         * CONDITIONAL GENERATED FIELD AREA
         *
         * so simplify things, you can put fields here that should be conditionally created by Graviton.
         * @TODO refactor into a FieldBuilder* type of thing where different builders can add fields conditionally.
         */

        // Versioning field, for version control.
        if ($this->def->getService() && $this->def->getService()->getVersioning()) {
            $definition = new Schema\Field();
            $constraint = new Constraint();
            $constraint->setName('versioning');
            $definition->setName(VersionServiceConstraint::FIELD_NAME)->setTitle('Version')->setType('int')
                       ->setConstraints([$constraint])
                       ->setDescription('Document version. You need to send current version if you want to update.');
            $fields['version'] = $this->processSimpleField('version',  $definition);
        }

        /*******
         * add fields as defined in the definition file.
         */

        foreach ($hierarchy as $name => $definition) {
            $fields[$name] = $this->processFieldHierarchyRecursive($name, $definition);
        }

        return $fields;
    }