From c02297ab9170074906167d637334e8fe367235f1 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Sun, 17 Jan 2021 20:51:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=E6=94=AF=E6=8C=81app=20comm?= =?UTF-8?q?ands=20=E8=87=AA=E5=8A=A8=E8=BD=BD=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchConsole.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extend/catcher/CatchConsole.php b/extend/catcher/CatchConsole.php index 42c0815..18decf3 100644 --- a/extend/catcher/CatchConsole.php +++ b/extend/catcher/CatchConsole.php @@ -71,11 +71,19 @@ class CatchConsole $psr4 = (new Composer())->psr4Autoload(); - $rootNamespace = substr($this->namespace, 0, strpos($this->namespace, '\\') + 1); + if (strpos($this->namespace, '\\') === false) { + $rootNamespace = $this->namespace . '\\'; + } else { + $rootNamespace = substr($this->namespace, 0, strpos($this->namespace, '\\') + 1); + } - return root_path(). $psr4[$rootNamespace] . DIRECTORY_SEPARATOR . + $path = root_path(). $psr4[$rootNamespace] . DIRECTORY_SEPARATOR; - str_replace('\\', DIRECTORY_SEPARATOR, substr($this->namespace, strpos($this->namespace, '\\') + 1)); + if (strpos($this->namespace, '\\') !== false) { + $path .= str_replace('\\', DIRECTORY_SEPARATOR, substr($this->namespace, strpos($this->namespace, '\\') + 1)); + } + + return rtrim($path, '/'); } /**