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.
33 lines
689 B
33 lines
689 B
--TEST--
|
|
std vector: class value type accepts typed parameter subclass at runtime
|
|
--FILE--
|
|
<?php
|
|
class StdVectorRuntimeClassValue
|
|
{
|
|
public function __construct(public int $value)
|
|
{
|
|
}
|
|
}
|
|
|
|
class StdVectorRuntimeClassValueChild extends StdVectorRuntimeClassValue
|
|
{
|
|
}
|
|
|
|
function std_vector_runtime_class_value(StdVectorRuntimeClassValue $value): void
|
|
{
|
|
$vector = std::vector(StdVectorRuntimeClassValue::class);
|
|
|
|
try {
|
|
$vector[] = $value;
|
|
var_dump($vector[0]->value);
|
|
} catch (Throwable $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
}
|
|
|
|
function main() {
|
|
std_vector_runtime_class_value(new StdVectorRuntimeClassValueChild(1));
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
int(1)
|
|
|