Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #region setup
- // Tests 1 and 2: exit after first item in php8.0.0rc1
- // php.ini
- // zend_extension=opcache
- // opcache.enable=1
- // opcache.enable_cli=1
- // opcache.memory_consumption=128
- $factory = function (string $msg): Closure {
- return function () use ($msg): void {
- fwrite(STDOUT, $msg);
- };
- };
- $initial_callbacks = [
- $factory('First item!'),
- $factory('Second item!'),
- $factory('Third item!'),
- $factory('Fourth item!'),
- ];
- $nl = function (): void {
- fwrite(STDOUT, PHP_EOL);
- };
- #endregion setup
- fwrite(STDOUT, PHP_EOL);
- fwrite(STDOUT, 'START: Test all work done in argument.' . PHP_EOL);
- $array = $initial_callbacks;
- while ((null !== $callback = array_shift($array)) && ($callback() || $nl() || true))
- /**/;
- fwrite(STDOUT, 'END: Test all work done in argument.' . PHP_EOL . PHP_EOL . PHP_EOL);
- fwrite(STDOUT, 'START: Test all work done in body inside if.' . PHP_EOL);
- $array = $initial_callbacks;
- while (true) {
- if (!((null !== $callback = array_shift($array)) && ($callback() || $nl() || true))) {
- break;
- }
- }
- fwrite(STDOUT, 'END: Test all work done in body inside if.' . PHP_EOL . PHP_EOL . PHP_EOL);
- fwrite(STDOUT, 'START: Test all work done in body print result.' . PHP_EOL);
- $array = $initial_callbacks;
- while (true) {
- $result = (null !== $callback = array_shift($array)) && ($callback() || $nl() || true);
- if (!$result) {
- break;
- }
- fwrite(STDOUT, $result . PHP_EOL);
- }
- fwrite(STDOUT, 'END: Test all work done in body print result.' . PHP_EOL);
- die(PHP_EOL);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement