From a3d8f57ef44c485b28d9b8cdba2599a29c50472f Mon Sep 17 00:00:00 2001 From: Yurun Date: Thu, 23 Jul 2026 21:38:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(compiler):=20=E4=BF=AE=E5=A4=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E7=A9=BA=E9=97=B4=E5=B0=BE=E9=83=A8=E6=9C=89=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E5=AF=BC=E8=87=B4=E7=BC=96=E8=AF=91=E4=B8=8D=E9=80=9A?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Preprocessor.php | 2 ++ src/Translator.php | 2 ++ .../namespace/namespace-ending-comment.phpt | 22 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/compiler/namespace/namespace-ending-comment.phpt diff --git a/src/Preprocessor.php b/src/Preprocessor.php index 2d311e00..9e0d5d11 100644 --- a/src/Preprocessor.php +++ b/src/Preprocessor.php @@ -321,6 +321,8 @@ class Preprocessor extends CompilerBase case 'Stmt_Interface': $this->parseInterface($v2); break; + case 'Stmt_Nop': + break; default: $this->foundStrayCode($v2); break; diff --git a/src/Translator.php b/src/Translator.php index 14916aec..402568ea 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -2514,6 +2514,8 @@ CODE; case 'Stmt_Interface': $this->validateInterfaceOverrideAttributes($v2); break; + case 'Stmt_Nop': + break; default: abort($v2); break; diff --git a/tests/compiler/namespace/namespace-ending-comment.phpt b/tests/compiler/namespace/namespace-ending-comment.phpt new file mode 100644 index 00000000..fa0f3da0 --- /dev/null +++ b/tests/compiler/namespace/namespace-ending-comment.phpt @@ -0,0 +1,22 @@ +--TEST-- +A namespace block ending with a comment must not be treated as stray code +--FILE-- + +--EXPECT-- +string(4) "done"