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
865 B

--TEST--
static closure created in an instance method remains a valid delayed callback
--ENV--
USE_ZEND_ALLOC=0
--FILE--
<?php
final class CallbackHolder
{
private Closure $callback;
public function __construct(Closure $callback)
{
$this->callback = $callback;
}
public function invoke(): mixed
{
return ($this->callback)();
}
}
final class CallbackFactory
{
public function create(): CallbackHolder
{
return new CallbackHolder(
static function (): never {
throw new LogicException('expected callback');
},
);
}
}
function main(): void
{
$callback = (new CallbackFactory())->create();
try {
$callback->invoke();
} catch (LogicException $error) {
echo $error->getMessage(), "\n";
}
}
?>
--EXPECT--
expected callback