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.
41 lines
785 B
41 lines
785 B
--TEST--
|
|
Native class: clone accepts rooted native-producing expressions
|
|
--FILE--
|
|
<?php
|
|
|
|
#[Native]
|
|
class NativeCloneExpressionValue
|
|
{
|
|
public int $number = 40;
|
|
|
|
public function __clone(): void
|
|
{
|
|
$this->number++;
|
|
}
|
|
}
|
|
|
|
#[Native]
|
|
class NativeCloneExpressionHolder
|
|
{
|
|
public ?NativeCloneExpressionValue $value;
|
|
}
|
|
|
|
function makeNativeCloneExpressionValue(): NativeCloneExpressionValue
|
|
{
|
|
return new NativeCloneExpressionValue();
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$fromCall = clone makeNativeCloneExpressionValue();
|
|
var_dump($fromCall->number);
|
|
|
|
$holder = new NativeCloneExpressionHolder();
|
|
$holder->value = makeNativeCloneExpressionValue();
|
|
$fromProperty = clone $holder->value;
|
|
var_dump($fromProperty->number);
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(41)
|
|
int(41)
|
|
|