diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 3c8f4ecf..11fdaf94 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -47,7 +47,7 @@ return (new PhpCsFixer\Config()) 'phpdoc_types_order' => ['sort_algorithm' => 'none', 'null_adjustment' => 'always_last'], 'phpdoc_separation' => false, 'phpdoc_summary' => false, - 'ordered_class_elements' => true, + 'ordered_class_elements' => false, 'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'], 'ordered_types' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], 'single_line_comment_style' => ['comment_types' => []], diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index b21aa500..6eb8500a 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -902,7 +902,7 @@ class CompilerBase extends \PhpAot\Core\Translator case 'Scalar_Float': return $this->parseScalarFloat($expr); case 'Scalar_String': - return $this->getLiteralString($expr->value); + return $expr->hasAttribute('noLiteralString') ? $this->genCharPtr($expr->value) : $this->getLiteralString($expr->value); default: abort($expr); } @@ -3549,6 +3549,8 @@ class CompilerBase extends \PhpAot\Core\Translator protected function parseEval(Expr\Eval_ $expr): string { + // 对 eval() 指令的 PHP 代码段禁止字面量优化 + $expr->expr->setAttribute('noLiteralString', true); return 'php::eval(' . $this->parseIdentifier($expr->expr) . ')'; }