diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 90cd516b..0fbae6a9 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -2185,11 +2185,21 @@ class CompilerBase extends \PhpAot\Core\Translator $this->error("{$msg} in {$this->file}:{$node->getStartLine()}"); } + protected function warning(Node $node, string $msg): void + { + $this->climate->yellow("{$msg} in {$this->file}:{$node->getStartLine()}"); + } + protected function errorUndefinedVariable(Variable $node): never { $this->fatalError($node, "The variable `\${$node->name}` is undefined"); } + protected function warningUndefinedBehavior(NodeAbstract $expr): void + { + $this->warning($expr, 'Use this expression carefully, which may be inconsistent with the dynamic execution behavior'); + } + protected function dump(NodeAbstract $v): void { if ($this->debugLine == $v->getStartLine()) { diff --git a/src/Php/FuncCallOptimizer.php b/src/Php/FuncCallOptimizer.php index 216069b5..926dd2d5 100644 --- a/src/Php/FuncCallOptimizer.php +++ b/src/Php/FuncCallOptimizer.php @@ -14,6 +14,7 @@ trait FuncCallOptimizer { public function genFuncGetArgs(string $name, Node\Expr\FuncCall $expr): string { + $this->warningUndefinedBehavior($expr); $funcDef = $this->functionDef; $list = []; foreach ($funcDef->argInfoList as $i => $argInfo) { @@ -30,6 +31,7 @@ trait FuncCallOptimizer public function genFuncGetArg(string $name, Node\Expr\FuncCall $expr) { + $this->warningUndefinedBehavior($expr); $position = $expr->args[0]->value; if ($this->isScalarInt($position)) { $funcDef = $this->functionDef; @@ -109,6 +111,7 @@ trait FuncCallOptimizer protected function genFuncNumArgs(string $name, Node\Expr\FuncCall $expr): string { + $this->warningUndefinedBehavior($expr); $funcDef = $this->functionDef; foreach ($funcDef->argInfoList as $i => $argInfo) { if ($argInfo->variadic) {