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.
47 lines
902 B
47 lines
902 B
--TEST--
|
|
Native class: abstract methods dispatch through the native virtual thunk
|
|
--FILE--
|
|
<?php
|
|
|
|
#[Native]
|
|
abstract class NativeAbstractValue
|
|
{
|
|
abstract public function value(): int;
|
|
|
|
abstract public function label(string $prefix = 'value'): string;
|
|
}
|
|
|
|
#[Native]
|
|
class NativeConcreteValue extends NativeAbstractValue
|
|
{
|
|
public function value(): int
|
|
{
|
|
return 42;
|
|
}
|
|
|
|
public function label(string $prefix = 'concrete'): string
|
|
{
|
|
return $prefix . '=' . $this->value();
|
|
}
|
|
}
|
|
|
|
function readAbstractValue(NativeAbstractValue $value): int
|
|
{
|
|
return $value->value();
|
|
}
|
|
|
|
function readAbstractLabel(NativeAbstractValue $value): string
|
|
{
|
|
return $value->label();
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$value = new NativeConcreteValue();
|
|
var_dump(readAbstractValue($value));
|
|
var_dump(readAbstractLabel($value));
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(42)
|
|
string(11) "concrete=42"
|
|
|