From bfada6104203ecac7f4acc400084babad0e6a180 Mon Sep 17 00:00:00 2001 From: rango Date: Mon, 13 Jul 2026 16:23:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(generator):=20=E6=B7=BB=E5=8A=A0=E5=AF=B9C?= =?UTF-8?q?=E6=A0=87=E5=87=86=E5=BA=93=E5=AE=8F=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在保留关键字列表中添加 stdin、stdout 和 stderr - 为这些标准库宏添加变量名转义测试用例 - 确保这些宏不会被意外修改或冲突 --- phpunit/src/Generator/UtilsTest.php | 7 +++++++ src/Metadata/Constants.php | 3 +++ 2 files changed, 10 insertions(+) diff --git a/phpunit/src/Generator/UtilsTest.php b/phpunit/src/Generator/UtilsTest.php index b94a0468..bcab4f74 100644 --- a/phpunit/src/Generator/UtilsTest.php +++ b/phpunit/src/Generator/UtilsTest.php @@ -186,6 +186,13 @@ class UtilsTest extends TestCase $this->assertStringStartsWith('_php__var__', $result); } + public function testEscapeVarNameStdioMacros(): void + { + foreach (['stdin', 'stdout', 'stderr'] as $name) { + $this->assertEquals('_php__var__' . $name, $this->invokeMethod('escapeVarName', $name)); + } + } + public function testUnescapeVarName(): void { $this->assertEquals('foo', $this->invokeMethod('unescapeVarName', '_php__var__foo')); diff --git a/src/Metadata/Constants.php b/src/Metadata/Constants.php index 019fc076..6c61b97f 100644 --- a/src/Metadata/Constants.php +++ b/src/Metadata/Constants.php @@ -109,6 +109,9 @@ class Constants 'while', 'xor', 'xor_eq', + 'stdin', // C stdio macros + 'stdout', + 'stderr', 'pipe', 'errno', // Linux error code 'this_', // phpx keywords