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 DirectoryIterator;
use Exception;
use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;
use Snowflake\Abstracts\BaseObject;
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake;
use Throwable;
@@ -208,6 +205,7 @@ class Loader extends BaseObject
/**
* @param string $path
* @param string|null $outPath
* @throws Exception
*/
public function loadByDirectory(string $path, ?string $outPath = null)
@@ -244,6 +242,8 @@ class Loader extends BaseObject
*/
public function appendFileToDirectory(string $filePath, string $className)
{
$filePath = str_replace(APP_PATH, '', $filePath);
$directory = $this->splitDirectory($filePath);
array_pop($directory);
@@ -259,16 +259,20 @@ class Loader extends BaseObject
/**
* @param string $filePath
* @param string|null $output
* @return $this
*/
private function each(string $filePath, ?string $output): static
{
$tree = null;
$filePath = str_replace(APP_PATH, '', $filePath);
$directory = $this->splitDirectory($filePath);
if (!empty($output)) {
$output = DIRECTORY_SEPARATOR . trim($output, '/');
}
$output = str_replace(APP_PATH, '', $output);
$out_path = '';
foreach ($directory as $key => $value) {
@@ -290,7 +294,7 @@ class Loader extends BaseObject
* @param string $filePath
* @return false|string[]
*/
private function splitDirectory(string $filePath)
private function splitDirectory(string $filePath): array|bool
{
$DIRECTORY = explode(DIRECTORY_SEPARATOR, $filePath);
return array_filter($DIRECTORY, function ($value) {
+1
View File
@@ -21,6 +21,7 @@ class Runtime extends Command
/**
* @param Input $dtl
* @throws \Exception
*/
public function onHandler(Input $dtl)
{