refactor(php): 优化代码结构并添加测试用例

- 修复了AstNodeType.php中的命名空间引用问题
- 将parseTrait方法从Translator.php末尾移至中间位置
- 添加了ref 002测试用例验证数组引用行为
- 统一了代码风格和导入语句格式
pull/1/head
韩天峰 5 months ago
parent 2050945532
commit 2ad8df01da
  1. 2
      src/Php/AstNodeType.php
  2. 10
      src/Php/Translator.php
  3. 23
      tests/aot/ref/002.phpt

@ -145,6 +145,6 @@ trait AstNodeType
protected function isNull(NodeAbstract $expr): bool
{
return $expr instanceof Node\Expr\ConstFetch && $expr->name->toString() === 'null';
return $expr instanceof Expr\ConstFetch && $expr->name->toString() === 'null';
}
}

@ -1247,6 +1247,11 @@ class Translator extends Preprocessor
return $code;
}
protected function parseTrait(Node\Stmt\Trait_ $trait)
{
throw new Unsupported('Unsupported Trait ');
}
private function getRegisterClassFunctionArgDef(ClassDef|InterfaceDef $classDef): string
{
$depsCeList = $this->getRegisterClassFunctionCeList($classDef);
@ -1367,9 +1372,4 @@ class Translator extends Preprocessor
return $code;
}
protected function parseTrait(Node\Stmt\Trait_ $trait)
{
throw new Unsupported('Unsupported Trait ');
}
}

@ -0,0 +1,23 @@
--TEST--
ref 002
--FILE--
<?php
function main()
{
$a = [1, 2, 3];
$b = &$a;
$b[] = 5;
var_dump($a);
}
?>
--EXPECT--
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(5)
}
Loading…
Cancel
Save