diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index fb0ee33c..7b120f6a 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -2147,19 +2147,6 @@ class CompilerBase extends \PhpAot\Core\Translator '}'; } - protected function parseParameterType(Node\Param $param, ArgInfo $argInfo, string $var): string - { - if ($param->byRef) { - return self::TYPE_REF; - } - $class = ''; - $type = $this->parseTypeDecl($param->type, self::DECL_TYPE_OF_PARAM, $class); - if ($class and !$this->hasInterface($class) and !$this->isAbstractClass($class)) { - $argInfo->class = $class; - } - return $type; - } - /** * 获取包含路径 */ @@ -4820,28 +4807,6 @@ class CompilerBase extends \PhpAot\Core\Translator return $phpCode; } - protected function parseDeclare(mixed $v): void - { - $declares = $v->declares; - foreach ($declares as $declare) { - $key = $this->parseIdentifier($declare->key); - $value = $this->parseIdentifier($declare->value); - if ($key === 'ticks') { - $this->fatalError($v, 'declare(ticks=1) is not supported'); - } elseif ($key === 'encoding') { - if (strtolower($value) !== 'utf-8') { - $this->fatalError($v, 'declare(encoding="' . $value . '") is not supported, only UTF-8 is supported'); - } - } elseif ($key === 'strict_types') { - if (!($declare->value instanceof Node\Scalar\Int_) or $declare->value->value !== 1) { - $this->fatalError($v, 'declare(strict_types=0) is not allowed, only strict_types=1 is supported'); - } - } else { - $this->fatalError($v, 'declare(' . $key . '=' . $value . ') is not supported'); - } - } - } - protected function parseUse(Node\Stmt\Use_ $v2): string { $code = ''; diff --git a/src/Php/Preprocessor.php b/src/Php/Preprocessor.php index e0ede516..5d415fac 100644 --- a/src/Php/Preprocessor.php +++ b/src/Php/Preprocessor.php @@ -221,6 +221,19 @@ class Preprocessor extends CompilerBase } } + protected function parseParameterType(Node\Param $param, ArgInfo $argInfo, string $var): string + { + if ($param->byRef) { + return self::TYPE_REF; + } + $class = ''; + $type = $this->parseTypeDecl($param->type, self::DECL_TYPE_OF_PARAM, $class); + if ($class and !$this->hasInterface($class) and !$this->isAbstractClass($class)) { + $argInfo->class = $class; + } + return $type; + } + /** * @param $params array */ diff --git a/src/Php/Translator.php b/src/Php/Translator.php index bfddf59b..f5b697ea 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -1729,6 +1729,28 @@ CODE; return $this->getNativeName($methodDef->name, $classDef->namespace, $classDef->name); } + protected function parseDeclare(mixed $v): void + { + $declares = $v->declares; + foreach ($declares as $declare) { + $key = $this->parseIdentifier($declare->key); + $value = $this->parseIdentifier($declare->value); + if ($key === 'ticks') { + $this->fatalError($v, 'declare(ticks=1) is not supported'); + } elseif ($key === 'encoding') { + if (strtolower($value) !== 'utf-8') { + $this->fatalError($v, 'declare(encoding="' . $value . '") is not supported, only UTF-8 is supported'); + } + } elseif ($key === 'strict_types') { + if (!($declare->value instanceof Node\Scalar\Int_) or $declare->value->value !== 1) { + $this->fatalError($v, 'declare(strict_types=0) is not allowed, only strict_types=1 is supported'); + } + } else { + $this->fatalError($v, 'declare(' . $key . '=' . $value . ') is not supported'); + } + } + } + protected function parseNamespace(Node\Stmt\Namespace_ $node): string { $ns = $node->name ? $this->parseIdentifier($node->name) : '';