From 66ed6728b89ff6868ee01b2fb3fef858161d80b4 Mon Sep 17 00:00:00 2001 From: Yurun Date: Tue, 16 Jun 2026 19:48:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix(tests):=20=E4=BF=AE=E5=A4=8D=20Windows?= =?UTF-8?q?=20=E5=AE=89=E8=A3=85=E9=A1=B9=E7=9B=AE=E5=8F=8A=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 4 +++- run-tests.php | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index ff16a7ae..17c643f3 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "require": { "php": ">=8.2 <8.6", - "ext-pcntl": "*", "nikic/php-parser": "5.6.1", "league/climate": "^3.10", "marcj/topsort": "^2.0", @@ -22,5 +21,8 @@ "cs-fix": "php-cs-fixer fix $1", "analyse": "phpstan analyse --memory-limit 512M -l 5 -c phpstan.neon", "rector": "rector process --clear-cache" + }, + "suggest": { + "ext-pcntl": "Required for process control features." } } diff --git a/run-tests.php b/run-tests.php index acae634a..8755bc52 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2461,7 +2461,7 @@ $message return 'FAILED'; } $args = substr($args, strlen(' -- ')); - $cmd = './' . $bin_file . ' ' . $args . $cmdRedirect; + $cmd = (IS_WINDOWS ? '.\\' : './') . $bin_file . ' ' . $args . $cmdRedirect; } else { $content = file_get_contents($test_file); if (preg_match('/function main\(\)/', $content)) { @@ -2667,7 +2667,7 @@ COMMAND $cmd $file = substr($test_file, 0, strlen($test_file) - 4); @unlink($file . '.cc'); @unlink($file . '.cc.o'); - @unlink('./' . $bin_file); + @unlink($bin_file); } } @unlink($tmp_post); @@ -4249,6 +4249,9 @@ function compile_php_file(string $file): string throw new CompilationFailureException('Invalid PHP file'); } $binary_file = str_replace('-', '_', basename($file, '.php')); + if (IS_WINDOWS) { + $binary_file .= '.exe'; + } if (!str_contains($data, 'function main()')) { file_put_contents($file, "&1', $output, $exitCode); + $cmd = $compiler_path; + // On Windows, .php files need to be run through the PHP interpreter + if (IS_WINDOWS && str_ends_with($cmd, '.php')) { + $cmd = escapeshellarg(PHP_BINARY) . ' ' . $cmd; + } + exec($cmd . ' ' . escapeshellarg($file) . ' 2>&1', $output, $exitCode); clearstatcache(true, $binary_file); if ($exitCode !== 0 || !file_exists($binary_file)) { -- 2.34.1 From ebf4c9d1cb998aae15e64b0b65161d07d134a091 Mon Sep 17 00:00:00 2001 From: Yurun Date: Tue, 16 Jun 2026 19:51:18 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=200LL=20?= =?UTF-8?q?=E5=AD=97=E9=9D=A2=E9=87=8F=E5=9C=A8=20Windows=E5=92=8C=20MacOS?= =?UTF-8?q?=20=E7=9A=84=E5=85=BC=E5=AE=B9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Php/CompilerBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index d9c416af..6edaf650 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1168,7 +1168,7 @@ class CompilerBase extends \PhpAot\Core\Translator $key = $this->parseIdentifier($expr); if (str_starts_with($key, self::LITERAL_STRINGS)) { $key = "{$key}.str()"; - } elseif ($key === '0L') { + } elseif ($key === '0L' || $key === '0LL') { // 0 在 C++ 中是一个特殊的值,存在二义性,既是空指针,也是整数,这会导致产生 ambiguous 错误 // 必须转为 php::zero 常量,保证作为 key 时正确匹配到 IntKeyMap $key = self::VALUE_ZERO; -- 2.34.1 From c4e179226772ff34be2f73a47687e525bbf3854b Mon Sep 17 00:00:00 2001 From: Yurun Date: Tue, 16 Jun 2026 20:08:40 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix(tests):=20=E4=BF=AE=E5=A4=8D=20Windows?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=20aot/basic/file=5Foperations.phpt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/aot/basic/file_operations.phpt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/aot/basic/file_operations.phpt b/tests/aot/basic/file_operations.phpt index 64a67dbd..07b3c9b7 100644 --- a/tests/aot/basic/file_operations.phpt +++ b/tests/aot/basic/file_operations.phpt @@ -97,8 +97,8 @@ rmdir($tempDir); echo "Cleanup completed\n"; ?> --EXPECTF-- -Directory created: /tmp/aot_test_%s -File created: /tmp/aot_test_%s/test.txt +Directory created: %s +File created: %s/test.txt File content: Hello, World! This is a test file. @@ -114,8 +114,8 @@ Directory contents: - second_test.txt - test.txt First line from handle: Hello, World! -File copied to: /tmp/aot_test_%s/copied_test.txt -File moved to: /tmp/aot_test_%s/moved_test.txt +File copied to: %s/copied_test.txt +File moved to: %s/moved_test.txt Is test file a file: yes Is temp dir a directory: yes File modification time: %d-%d-%d %d:%d:%d -- 2.34.1