feat(php): 更新符号常量并添加参数列表支持

- 在Symbol类中添加argList方法返回'php::ArgList'
- 修改CompilerBase中参数列表的返回值格式
- 添加count-array.php示例文件展示数组计数功能
pull/1/head
韩天峰 4 months ago
parent c4c46bf3f0
commit 81957f56d7
  1. 30
      examples/error/count-array.php
  2. 2
      src/Php/CompilerBase.php
  3. 5
      src/Php/Symbol.php

@ -0,0 +1,30 @@
<?php
class FooArray
{
public array $array;
public function __construct(array $array)
{
$this->array = $array;
}
}
class Bar
{
public function run(array $array)
{
$n = count($array);
var_dump($n);
}
}
function main()
{
$bar = new Bar();
$foo = new FooArray([1, 2, 3]);
$bar->run($foo->array);
}

@ -3405,7 +3405,7 @@ class CompilerBase extends \PhpAot\Core\Translator
$list_args[] = $this->parseArg($arg);
}
return '{' . implode(', ', $list_args) . '}';
return Symbol::argList() . '{' . implode(', ', $list_args) . '}';
}
/**

@ -49,4 +49,9 @@ class Symbol
{
return 'php::getClassEntrySafe';
}
public static function argList(): string
{
return 'php::ArgList';
}
}

Loading…
Cancel
Save