TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
554 B
37 lines
554 B
--TEST--
|
|
objval
|
|
--FILE--
|
|
<?php
|
|
|
|
class TestObjval
|
|
{
|
|
public int $a;
|
|
public int $b;
|
|
|
|
public function __construct(int $a, int $b)
|
|
{
|
|
$this->a = $a;
|
|
$this->b = $b;
|
|
}
|
|
|
|
public function test()
|
|
{
|
|
return $this->a + $this->b;
|
|
}
|
|
}
|
|
|
|
function main()
|
|
{
|
|
$obj = new TestObjval(1, 2);
|
|
$arr = array();
|
|
$arr['obj'] = $obj;
|
|
$obj2 = $arr['obj']->toObject('TestObjval');
|
|
var_dump($obj2->test());
|
|
|
|
$obj3 = $obj->toObject(TestObjval::class);
|
|
var_dump($obj3->test());
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(3)
|
|
int(3)
|