xref: /PHP-8.2/Zend/tests/fibers/ticks.phpt (revision 2bc6025c)
1--TEST--
2Prevent switching fibers in tick function
3--FILE--
4<?php
5
6declare(ticks=1);
7
8register_tick_function(function (): void {
9    if (Fiber::getCurrent() !== null) {
10        Fiber::suspend();
11    }
12});
13
14$fiber = new Fiber(function (): void {
15    echo "1\n";
16    echo "2\n";
17    echo "3\n";
18});
19
20$fiber->start();
21
22?>
23--EXPECTF--
241
25
26Fatal error: Uncaught FiberError: Cannot switch fibers in current execution context in %sticks.php:%d
27Stack trace:
28#0 %sticks.php(%d): Fiber::suspend()
29#1 %sticks.php(%d): {closure}()
30#2 [internal function]: {closure}()
31#3 %sticks.php(%d): Fiber->start()
32#4 {main}
33  thrown in %sticks.php on line %d
34