diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index f0eb01d8..f41427ef 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3659,7 +3659,7 @@ class CompilerBase extends \PhpAot\Core\Translator if (!$this->hasNativeClass($class)) { return false; } - $classDef = $this->classes[$class]; + $classDef = $this->getClassDef($class); if (!$classDef->hasMethod($method)) { return false; } diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 193a78f8..7fb32ac1 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -137,9 +137,6 @@ class Translator extends Preprocessor $this->climate->red('The target name [' . $name . '] must not be a reserved keyword'); exit(1); } - if (is_numeric($name)) { - $name = 'app_' . $name; - } $this->targetName = $name; } @@ -239,6 +236,14 @@ class Translator extends Preprocessor $this->localHeaders = []; } + public function getModuleName(): string + { + if (ctype_digit($this->targetName[0])) { + return 'app_' . $this->targetName; + } + return $this->targetName; + } + public function hasObjectFileCache(string $cppFile): bool { if (!$this->enableCache or $this->climate->arguments->defined('force')) { diff --git a/src/template/extension.cc.php b/src/template/extension.cc.php index a1065048..76d6e897 100644 --- a/src/template/extension.cc.php +++ b/src/template/extension.cc.php @@ -95,7 +95,7 @@ foreach ($this->functions as $functionDef): }; // clang-format on -PHP_MINIT_FUNCTION(targetName?>) { +PHP_MINIT_FUNCTION(getModuleName()?>) { // class/interface class entries classCeList as $ce): @@ -159,7 +159,7 @@ foreach ($this->nativeConstants as $name => $const): } -PHP_RINIT_FUNCTION(targetName?>) { +PHP_RINIT_FUNCTION(getModuleName()?>) { php::request_init(); php_app_init(); @@ -174,29 +174,29 @@ PHP_RINIT_FUNCTION(targetName?>) { return SUCCESS; } -PHP_RSHUTDOWN_FUNCTION(targetName?>) { +PHP_RSHUTDOWN_FUNCTION(getModuleName()?>) { php_app_clean(); php::request_shutdown(); return SUCCESS; } -zend_module_entry targetName?>_module_entry = { +zend_module_entry getModuleName()?>_module_entry = { STANDARD_MODULE_HEADER, - "targetName?>", + "getModuleName()?>", ext_functions, - PHP_MINIT(targetName?>), + PHP_MINIT(getModuleName()?>), nullptr, - PHP_RINIT(targetName?>), - PHP_RSHUTDOWN(targetName?>), + PHP_RINIT(getModuleName()?>), + PHP_RSHUTDOWN(getModuleName()?>), nullptr, nullptr, STANDARD_MODULE_PROPERTIES, }; buildMode === 'ext'): ?> -ZEND_GET_MODULE(targetName?>); +ZEND_GET_MODULE(getModuleName()?>); -zend_module_entry *get_module() { - return &targetName ?>_module_entry; +zend_module_entry *get_module() { + return &getModuleName() ?>_module_entry; } \ No newline at end of file