From 67ace98bb64911637e519c4d9599ff79cea9a2f7 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 4 Feb 2026 11:29:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E5=B0=86=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=B1=BB=E7=A7=BB=E5=8A=A8=E5=88=B0Exception=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E7=A9=BA=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将RedoException重命名为Redo并移至PhpAot\Php\Exception命名空间 - 将SkipException重命名为Skip并移至PhpAot\Php\Exception命名空间 - 将SyntaxError移至PhpAot\Php\Exception命名空间 - 将Unsupported移至PhpAot\Php\Exception命名空间 - 更新所有相关文件中的use语句和异常引用 - 移除不再使用的PrettyPrinter导入 --- bin/compiler.php | 4 ++-- src/Php/CompilerBase.php | 11 ++++++----- src/Php/{RedoException.php => Exception/Redo.php} | 4 ++-- src/Php/Exception/Skip.php | 8 ++++++++ src/Php/{ => Exception}/SyntaxError.php | 2 +- src/Php/{ => Exception}/Unsupported.php | 2 +- src/Php/Preprocessor.php | 1 + src/Php/SkipException.php | 8 -------- src/Php/Translator.php | 3 ++- src/functions.php | 2 +- 10 files changed, 24 insertions(+), 21 deletions(-) rename src/Php/{RedoException.php => Exception/Redo.php} (66%) create mode 100644 src/Php/Exception/Skip.php rename src/Php/{ => Exception}/SyntaxError.php (85%) rename src/Php/{ => Exception}/Unsupported.php (85%) delete mode 100644 src/Php/SkipException.php diff --git a/bin/compiler.php b/bin/compiler.php index 9c9c3b17..52c7580d 100755 --- a/bin/compiler.php +++ b/bin/compiler.php @@ -2,10 +2,10 @@ redoAfterDeclare[$name])) { unset($this->redoAfterDeclare[$name]); $this->climate->cyan('Received redo request, retrying...'); - throw new RedoException(); + throw new Redo(); } } @@ -675,7 +676,7 @@ class CompilerBase extends \PhpAot\Core\Translator $this->indentLevel++; try { $stmts = $this->parseStmts($v->stmts); - } catch (SkipException $e) { + } catch (Skip $e) { $stmts = ''; } $this->indentLevel--; @@ -1254,7 +1255,7 @@ class CompilerBase extends \PhpAot\Core\Translator $this->functionDef->returnType = $type; // 返回值变更,需要重新解析 $this->climate->cyan('Return type changed, retrying...'); - throw new RedoException(); + throw new Redo(); } protected function detectVarType($var): string @@ -1741,7 +1742,7 @@ class CompilerBase extends \PhpAot\Core\Translator and $this->functionDeclInFile[$name] === $this->file and !$this->isNativeFunction($name)) { $this->redoAfterDeclare[$name] = true; - throw new SkipException(); + throw new Skip(); } if ($this->isNativeFunction($name)) { return $name; diff --git a/src/Php/RedoException.php b/src/Php/Exception/Redo.php similarity index 66% rename from src/Php/RedoException.php rename to src/Php/Exception/Redo.php index a978c969..422f7a11 100644 --- a/src/Php/RedoException.php +++ b/src/Php/Exception/Redo.php @@ -6,8 +6,8 @@ * @contact service@swoole.com */ -namespace PhpAot\Php; +namespace PhpAot\Php\Exception; -class RedoException extends \RuntimeException +class Redo extends \RuntimeException { } diff --git a/src/Php/Exception/Skip.php b/src/Php/Exception/Skip.php new file mode 100644 index 00000000..40077f38 --- /dev/null +++ b/src/Php/Exception/Skip.php @@ -0,0 +1,8 @@ +phpSrcFiles[] = $file; return $cppFile; - } catch (RedoException $e) { + } catch (Redo $e) { continue; } } diff --git a/src/functions.php b/src/functions.php index e43c6a00..7d2f371d 100644 --- a/src/functions.php +++ b/src/functions.php @@ -1,7 +1,7 @@