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.
34 lines
638 B
34 lines
638 B
<?php
|
|
use StdVector as VectorOf;
|
|
|
|
class StdParameterUser
|
|
{
|
|
public function __construct(public int $id) {}
|
|
}
|
|
|
|
function std_parameter_vector(#[VectorOf(Type::Int)] $vec): int
|
|
{
|
|
$vec[] = 42;
|
|
return $vec[0];
|
|
}
|
|
|
|
function std_parameter_map(#[StdMap(Type::String, Type::Float)] $map): float
|
|
{
|
|
$map['value'] = 2.5;
|
|
return $map['value'];
|
|
}
|
|
|
|
class StdParameterReceiver
|
|
{
|
|
public function accept(#[StdOrderedMap(Type::Int, StdParameterUser::class)] $users): int
|
|
{
|
|
return $users[0]->id;
|
|
}
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$vec = std::vector(Type::Int);
|
|
$vec[] = 7;
|
|
var_dump(std_parameter_vector($vec));
|
|
}
|
|
|