diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index d5a6776e..b779bbd7 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -86,9 +86,9 @@ class Annotation extends Component */ public function runtime(string $dir, string|array $outPath = []) { - if (!empty($outPath) && !is_array($outPath)) { - $outPath = [$outPath]; - } +// if (!empty($outPath) && !is_array($outPath)) { +// $outPath = [$outPath]; +// } $this->_loader->loadByDirectory($dir, $outPath); } diff --git a/Annotation/Loader.php b/Annotation/Loader.php index 1b0d29ca..18d690e1 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -227,21 +227,23 @@ class Loader extends BaseObject * @param string|array $outPath * @throws Exception */ - public function loadByDirectory(string $path, string|array $outPath = []) + public function loadByDirectory(string $path, string|array $outPath = '') { try { - $path = '/' . trim($path, '/'); - if (!isset($this->_directory[$path])) { - return; - } - foreach ($this->_directory as $key => $_path) { - $key = '/' . trim($path, '/'); - if (!str_starts_with($key, $path)) { - continue; - } -// if (!empty($outPath) && in_array($key, $outPath)) continue; - $this->execute($_path); - } +// $path = '/' . trim($path, '/'); +// if (!isset($this->_directory[$path])) { +// return; +// } +// foreach ($this->_directory as $key => $_path) { +// $key = '/' . trim($path, '/'); +// if (!str_starts_with($key, $path)) { +// continue; +// } +//// if (!empty($outPath) && in_array($key, $outPath)) continue; +// $this->execute($_path); +// } + + $this->each($path, $outPath); } catch (Throwable $exception) { $this->addError($exception, 'throwable'); } @@ -272,24 +274,24 @@ class Loader extends BaseObject */ public function appendFileToDirectory(string $filePath, string $className) { - $array = explode('/', $filePath); - array_pop($array); - - $directory = '/' . implode('/', $array); - - $this->_directory[$directory][] = $className; - -// $directory = $this->splitDirectory($filePath); -// array_pop($directory); +// $array = explode('/', $filePath); +// array_pop($array); // -// $tree = null; -// foreach ($directory as $value) { -// $tree = $this->getTree($tree, $value); -// } +// $directory = '/' . implode('/', $array); // -// if ($tree instanceof FileTree) { -// $tree->addFile($className, $filePath); -// } +// $this->_directory[$directory][] = $className; + + $directory = $this->splitDirectory($filePath); + array_pop($directory); + + $tree = null; + foreach ($directory as $value) { + $tree = $this->getTree($tree, $value); + } + + if ($tree instanceof FileTree) { + $tree->addFile($className, $filePath); + } }