diff --git a/phpunit/src/ServerEnvironmentTest.php b/phpunit/src/ServerEnvironmentTest.php index 54697ee8..38f2b1e1 100644 --- a/phpunit/src/ServerEnvironmentTest.php +++ b/phpunit/src/ServerEnvironmentTest.php @@ -43,6 +43,7 @@ class ServerEnvironmentTest extends TestCase $method = new ReflectionMethod(Translator::class, 'registerServerEnvironment'); $code = $method->invoke($compiler, 'C:\\project\\"quoted"\\main.php'); + $this->assertStringContainsString('php::Var &_SERVER = _global_var__SERVER;', $code); $this->assertStringContainsString('php::Str php_self = "PHP_SELF";', $code); $this->assertStringContainsString('php::Str script_name = "SCRIPT_NAME";', $code); $this->assertStringContainsString('php::Str script_filename = "SCRIPT_FILENAME";', $code); diff --git a/src/Translator.php b/src/Translator.php index cc5b5baa..54eb22f1 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -3232,7 +3232,7 @@ CODE; private function registerServerEnvironment(string $entryFile): string { - $cppCode = 'php::Var &_SERVER = _global_var__SERVER;' . PHP_EOL; + $cppCode = 'php::Var &_SERVER = ' . $this->escapeGlobalVar('_SERVER') . ';' . PHP_EOL; $cppCode .= 'php::Str php_self = "PHP_SELF";' . PHP_EOL; $cppCode .= 'php::Str script_name = "SCRIPT_NAME";' . PHP_EOL; $cppCode .= 'php::Str script_filename = "SCRIPT_FILENAME";' . PHP_EOL;