From 38425b4d7e35be49b15c95a9153dfd3d2aa82194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 19 Apr 2021 15:20:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Annotation/Annotation.php | 4 +--- Annotation/Loader.php | 2 +- HttpServer/Events/OnWorkerStart.php | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index 5d7807aa..be3b3b85 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -86,9 +86,7 @@ class Annotation extends Component */ public function runtime(string $dir, string|array $outPath = null) { - if ($outPath === null) { - $outPath = []; - } else if (!empty($outPath) && !is_array($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 586d7eb4..b9149e44 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -238,7 +238,7 @@ class Loader extends BaseObject if (!str_contains($key, $path)) { continue; } - if (in_array($key, $outPath)) continue; + if (!empty($outPath) && in_array($key, $outPath)) continue; $this->execute($_path); } } catch (Throwable $exception) { diff --git a/HttpServer/Events/OnWorkerStart.php b/HttpServer/Events/OnWorkerStart.php index 607ea641..380a9c29 100644 --- a/HttpServer/Events/OnWorkerStart.php +++ b/HttpServer/Events/OnWorkerStart.php @@ -90,8 +90,9 @@ class OnWorkerStart extends Callback name($server->worker_pid, 'Worker#' . $server->worker_id); $time = microtime(true); - $annotation->runtime(directory('app')); + $annotation->runtime(CONTROLLER_PATH); $this->debug('use time.' . microtime(true) - $time); + $annotation->runtime(directory('app'), CONTROLLER_PATH); Snowflake::setWorkerId($server->worker_pid); putenv('environmental=' . Snowflake::WORKER);