diff --git a/src/ZM/Event/EventDispatcher.php b/src/ZM/Event/EventDispatcher.php index 6be94696..30392351 100644 --- a/src/ZM/Event/EventDispatcher.php +++ b/src/ZM/Event/EventDispatcher.php @@ -9,6 +9,7 @@ use Closure; use Doctrine\Common\Annotations\AnnotationException; use Error; use Exception; +use Throwable; use ZM\Config\ZMConfig; use ZM\Console\Console; use ZM\Exception\InterruptException; @@ -110,7 +111,7 @@ class EventDispatcher /** * @param mixed ...$params - * @throws Exception + * @throws Throwable */ public function dispatchEvents(...$params) { @@ -137,7 +138,7 @@ class EventDispatcher } catch (InterruptException $e) { $this->store = $e->return_var; $this->status = self::STATUS_INTERRUPTED; - } catch (Exception|Error $e) { + } catch (Throwable $e) { $this->status = self::STATUS_EXCEPTION; throw $e; } diff --git a/src/ZM/Utils/Terminal.php b/src/ZM/Utils/Terminal.php index 92fd41fc..fd000a46 100644 --- a/src/ZM/Utils/Terminal.php +++ b/src/ZM/Utils/Terminal.php @@ -7,10 +7,10 @@ declare(strict_types=1); namespace ZM\Utils; use Doctrine\Common\Annotations\AnnotationReader; -use Error; use Exception; use ReflectionClass; use Swoole\Process; +use Throwable; use ZM\Annotation\Command\TerminalCommand; use ZM\ConnectionManager\ManagerGM; use ZM\Console\Console; @@ -22,8 +22,7 @@ class Terminal public static $default_commands = false; /** - * @throws Exception - * @throws Error + * @throws Throwable * @return bool * @noinspection PhpMissingReturnTypeInspection * @noinspection PhpUnused diff --git a/tests/ZM/Utils/TerminalTest.php b/tests/ZM/Utils/TerminalTest.php new file mode 100644 index 00000000..5d847ac1 --- /dev/null +++ b/tests/ZM/Utils/TerminalTest.php @@ -0,0 +1,33 @@ +assertStringContainsString('Initializing Terminal', $this->getActualOutput()); + } + + /** + * @throws Throwable + */ + public function testExecuteCommand() + { + Console::setLevel(2); + Terminal::executeCommand('echo zhamao-framework'); + $this->assertStringContainsString('zhamao-framework', $this->getActualOutput()); + } +}