fix(aot): 修复静态方法调用中的占位符生成问题

- 将 Symbol::getCalledCe() 替换为 Symbol::getCalledClass() 以正确处理静态方法调用
- 添加了针对 static::bar(...) 语法的测试用例
- 确保继承类中的静态方法调用能够正确解析到子类方法
pull/1/head
韩天峰 4 months ago
parent 7e582d2eba
commit 1fbaa07820
  1. 2
      src/Php/CompilerBase.php
  2. 0
      tests/aot/place-holder/001.phpt
  3. 31
      tests/aot/place-holder/002.phpt
  4. 0
      tests/aot/place-holder/003.phpt

@ -4049,7 +4049,7 @@ class CompilerBase extends \PhpAot\Core\Translator
$methodPtr = $this->identifierToStr($expr->name, literal: true);
$fn = Symbol::getCalledCe() . ', php::getMethod(' . Symbol::getCalledCe() . ', ' . $methodPtr . ')';
$this->context->beforeStmtLines[] = '// Static Method Call: static::' . $this->parseIdentifier($expr->name) . '()';
$placeHolder = $this->genArray([Symbol::getCalledCe(), $methodPtr]);
$placeHolder = $this->genArray([Symbol::getCalledClass(), $methodPtr]);
} elseif ($this->isNameExpr($expr->class)) {
if ($class === 'self') {
$class = $this->class;

@ -0,0 +1,31 @@
--TEST--
place-holder
--FILE--
<?php
class TestPlaceHolder {
static function foo()
{
$fn4 = (static::bar(...));
$fn4();
}
static function bar()
{
var_dump(__METHOD__);
}
}
class TestPlaceHolder2 extends TestPlaceHolder {
static function bar()
{
echo "baz\n";
}
}
function main()
{
TestPlaceHolder2::foo();
}
?>
--EXPECT--
baz
Loading…
Cancel
Save