xref: /ext-fiber/tests/start-arguments.phpt (revision 068e4ea3)
1--TEST--
2Arguments to fiber callback
3--EXTENSIONS--
4fiber
5--FILE--
6<?php
7
8$fiber = new Fiber(function (int $x): int {
9    return $x + Fiber::suspend($x);
10});
11
12$x = $fiber->start(1);
13$fiber->resume(0);
14var_dump($fiber->getReturn());
15
16$fiber = new Fiber(function (int $x): int {
17    return $x + Fiber::suspend($x);
18});
19
20$fiber->start('test');
21
22?>
23--EXPECTF--
24int(1)
25
26Fatal error: Uncaught TypeError: {closure}(): Argument #1 ($x) must be of type int, string given in %sstart-arguments.php:%d
27Stack trace:
28#0 [internal function]: {closure}('test')
29#1 %sstart-arguments.php(%d): Fiber->start('test')
30#2 {main}
31  thrown in %sstart-arguments.php on line %d
32