Download src/php/php-src/Zend/tests/generators/bug71013.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/generators/bug71013.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/generators/bug71013.phpt
-
curl -L -o bug71013.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/generators/bug71013.phpt
1.04 kB
| --TEST-- | |
| Bug #71013 (Incorrect exception handler with yield from) | |
| --FILE-- | |
| class FooBar implements Iterator { | |
| function __construct() { echo "Constructing new FooBar\n"; } | |
| function __destruct() { echo "Destructing FooBar\n"; } | |
| function current (): mixed { throw new Exception; } | |
| function key (): int { return 0; } | |
| function next (): void {} | |
| function rewind (): void {} | |
| function valid (): bool { return true; } | |
| } | |
| function foo() { | |
| try { | |
| $f = new FooBar; | |
| yield from $f; | |
| } catch (Exception $e) { | |
| echo "[foo()] Caught Exception\n"; | |
| } | |
| } | |
| function bar() { | |
| echo "Starting bar()\n"; | |
| $x = foo(); | |
| try { | |
| var_dump($x->current()); | |
| } catch (Exception $e) { | |
| echo "[bar()] Caught Exception\n"; | |
| } | |
| echo "Unsetting \$x\n"; | |
| unset($x); | |
| echo "Finishing bar()\n"; | |
| } | |
| bar(); | |
| --EXPECT-- | |
| Starting bar() | |
| Constructing new FooBar | |
| [foo()] Caught Exception | |
| Destructing FooBar | |
| NULL | |
| Unsetting $x | |
| Finishing bar() | |