mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00

This commit add the possibility to catch multiple exception types in a single catch statement to avoid code duplication. try { // Some code... } catch (ExceptionType1 | ExceptionType2 $e) { // Code to handle the exception } catch (\Exception $e) { // ... }
25 lines
396 B
PHP
25 lines
396 B
PHP
--TEST--
|
|
Catch exception in the nested multicatch
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once __DIR__ . '/exceptions.inc';
|
|
|
|
try {
|
|
try {
|
|
echo 'TRY' . PHP_EOL;
|
|
throw new Exception3;
|
|
} catch (Exception1 | Exception3 $e) {
|
|
echo get_class($e) . PHP_EOL;
|
|
}
|
|
} catch(Exception2 | Exception3 $e) {
|
|
echo 'Should never be executed';
|
|
} finally {
|
|
echo 'FINALLY' . PHP_EOL;
|
|
}
|
|
|
|
?>
|
|
--EXPECT--
|
|
TRY
|
|
Exception3
|
|
FINALLY
|