mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Co-authored-by: Gina Peter Banyard <girgias@php.net> Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com> Co-authored-by: Tim Düsterhus <tim@tideways-gmbh.com>
38 lines
826 B
PHP
38 lines
826 B
PHP
--TEST--
|
|
A pipe interrupted by an exception, to demonstrate correct order of execution.
|
|
--FILE--
|
|
<?php
|
|
|
|
function foo() { echo __FUNCTION__, PHP_EOL; return 1; }
|
|
function bar() { echo __FUNCTION__, PHP_EOL; return false; }
|
|
function baz($in) { echo __FUNCTION__, PHP_EOL; return $in; }
|
|
function quux($in) { echo __FUNCTION__, PHP_EOL; throw new \Exception('Oops'); }
|
|
|
|
try {
|
|
$result = foo()
|
|
|> (bar() ? baz(...) : quux(...))
|
|
|> var_dump(...);
|
|
}
|
|
catch (Throwable $e) {
|
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
|
}
|
|
|
|
try {
|
|
$result = foo()
|
|
|> (throw new Exception('Break'))
|
|
|> (bar() ? baz(...) : quux(...))
|
|
|> var_dump(...);
|
|
}
|
|
catch (Throwable $e) {
|
|
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECTF--
|
|
foo
|
|
bar
|
|
quux
|
|
Exception: Oops
|
|
foo
|
|
Exception: Break
|