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.
62 lines
1.1 KiB
62 lines
1.1 KiB
<?php
|
|
/**
|
|
* This file is part of Swoole-Compiler(AOT).
|
|
*
|
|
* @link https://www.swoole.com/
|
|
* @contact service@swoole.com
|
|
*/
|
|
|
|
class native_types
|
|
{
|
|
public const type_int = 'int';
|
|
public const type_float = 'float';
|
|
public const type_bool = 'bool';
|
|
}
|
|
|
|
class std
|
|
{
|
|
public static function int(mixed $value): int
|
|
{
|
|
return intval($value);
|
|
}
|
|
|
|
public static function float(mixed $value): float
|
|
{
|
|
return floatval($value);
|
|
}
|
|
|
|
public static function bool(mixed $value): bool
|
|
{
|
|
return boolval($value);
|
|
}
|
|
|
|
public static function array(mixed $type, int $size): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public static function fill(array $array, mixed $value): void
|
|
{
|
|
for ($i = 0; $i < count($array); $i++) {
|
|
$array[$i] = $value;
|
|
}
|
|
}
|
|
}
|
|
|
|
function objval(mixed $obj, string $class): object
|
|
{
|
|
if ($obj instanceof $class) {
|
|
return $obj;
|
|
}
|
|
throw new Exception('Invalid object type');
|
|
}
|
|
|
|
function &refval(&$var)
|
|
{
|
|
return $var;
|
|
}
|
|
|
|
function any(mixed $var): mixed
|
|
{
|
|
return $var;
|
|
} |