This commit is contained in:
2021-04-09 09:51:17 +08:00
parent 59c4981913
commit e4e11aaadd
2 changed files with 305 additions and 300 deletions
+8 -4
View File
@@ -7,11 +7,8 @@ namespace Annotation;
use Attribute; use Attribute;
use DirectoryIterator; use DirectoryIterator;
use Exception; use Exception;
use ReflectionClass;
use ReflectionMethod; use ReflectionMethod;
use ReflectionProperty;
use Snowflake\Abstracts\BaseObject; use Snowflake\Abstracts\BaseObject;
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
use Throwable; use Throwable;
@@ -208,6 +205,7 @@ class Loader extends BaseObject
/** /**
* @param string $path * @param string $path
* @param string|null $outPath
* @throws Exception * @throws Exception
*/ */
public function loadByDirectory(string $path, ?string $outPath = null) public function loadByDirectory(string $path, ?string $outPath = null)
@@ -244,6 +242,8 @@ class Loader extends BaseObject
*/ */
public function appendFileToDirectory(string $filePath, string $className) public function appendFileToDirectory(string $filePath, string $className)
{ {
$filePath = str_replace(APP_PATH, '', $filePath);
$directory = $this->splitDirectory($filePath); $directory = $this->splitDirectory($filePath);
array_pop($directory); array_pop($directory);
@@ -259,16 +259,20 @@ class Loader extends BaseObject
/** /**
* @param string $filePath * @param string $filePath
* @param string|null $output
* @return $this * @return $this
*/ */
private function each(string $filePath, ?string $output): static private function each(string $filePath, ?string $output): static
{ {
$tree = null; $tree = null;
$filePath = str_replace(APP_PATH, '', $filePath);
$directory = $this->splitDirectory($filePath); $directory = $this->splitDirectory($filePath);
if (!empty($output)) { if (!empty($output)) {
$output = DIRECTORY_SEPARATOR . trim($output, '/'); $output = DIRECTORY_SEPARATOR . trim($output, '/');
} }
$output = str_replace(APP_PATH, '', $output);
$out_path = ''; $out_path = '';
foreach ($directory as $key => $value) { foreach ($directory as $key => $value) {
@@ -290,7 +294,7 @@ class Loader extends BaseObject
* @param string $filePath * @param string $filePath
* @return false|string[] * @return false|string[]
*/ */
private function splitDirectory(string $filePath) private function splitDirectory(string $filePath): array|bool
{ {
$DIRECTORY = explode(DIRECTORY_SEPARATOR, $filePath); $DIRECTORY = explode(DIRECTORY_SEPARATOR, $filePath);
return array_filter($DIRECTORY, function ($value) { return array_filter($DIRECTORY, function ($value) {
+1
View File
@@ -21,6 +21,7 @@ class Runtime extends Command
/** /**
* @param Input $dtl * @param Input $dtl
* @throws \Exception
*/ */
public function onHandler(Input $dtl) public function onHandler(Input $dtl)
{ {