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.
38 lines
778 B
38 lines
778 B
--TEST--
|
|
TypePHP FiberGenerator methods expose Iterator-compatible return types
|
|
--INI--
|
|
error_reporting=E_ALL
|
|
--FILE--
|
|
<?php
|
|
function reflected_generator(): iterable
|
|
{
|
|
yield 1;
|
|
}
|
|
|
|
function main(): void
|
|
{
|
|
$generator = reflected_generator();
|
|
foreach ([
|
|
'rewind' => 'void',
|
|
'next' => 'void',
|
|
'valid' => 'bool',
|
|
'current' => 'mixed',
|
|
'key' => 'mixed',
|
|
'send' => 'mixed',
|
|
'throw' => 'mixed',
|
|
'getReturn' => 'mixed',
|
|
] as $method => $expected) {
|
|
$type = (new ReflectionMethod($generator, $method))->getReturnType();
|
|
echo $method, ':', $type?->getName() ?? 'none', "\n";
|
|
}
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
rewind:void
|
|
next:void
|
|
valid:bool
|
|
current:mixed
|
|
key:mixed
|
|
send:mixed
|
|
throw:mixed
|
|
getReturn:mixed
|
|
|