diff --git a/Annotation/Loader.php b/Annotation/Loader.php index e6f48d25..7792175e 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -279,13 +279,11 @@ class Loader extends BaseObject if (empty($value)) { continue; } - if ($tree === null) { - $tree = $this->files->getChild($value); - } else { - $tree = $tree->getChild($value); - } + $tree = $this->getTree($tree, $value); + } + if ($tree instanceof FileTree) { + $tree->addFile($className); } - $tree->addFile($className); } @@ -302,11 +300,7 @@ class Loader extends BaseObject if (empty($value)) { continue; } - if ($tree === null) { - $tree = $this->files->getChild($value); - } else { - $tree = $tree->getChild($value); - } + $tree = $this->getTree($tree, $value); } if ($tree instanceof FileTree) { $this->eachNode($tree->getChildes()); @@ -316,6 +310,22 @@ class Loader extends BaseObject } + /** + * @param $tree + * @param $value + * @return FileTree + */ + private function getTree($tree, $value): FileTree + { + if ($tree === null) { + $tree = $this->files->getChild($value); + } else { + $tree = $tree->getChild($value); + } + return $tree; + } + + /** * @param FileTree[] $nodes */