diff options
| author | Pierrick Charron <pierrick@php.net> | 2016-05-01 18:47:08 -0400 |
|---|---|---|
| committer | Pierrick Charron <pierrick@php.net> | 2016-05-01 18:47:08 -0400 |
| commit | 0aed2cc2a440e7be17552cc669d71fdd24d1204a (patch) | |
| tree | 19bb9bb48c0d634d502112b84c49795b998e64cf /Zend/zend_ast.c | |
| parent | 770a6d1342fcc30bb273ac6d65fc9fc057b1ce21 (diff) | |
| download | php-git-0aed2cc2a440e7be17552cc669d71fdd24d1204a.tar.gz | |
Allow catching multiple exception types in a single catch statement
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) {
// ...
}
Diffstat (limited to 'Zend/zend_ast.c')
| -rw-r--r-- | Zend/zend_ast.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index eee4a44e86..e7c6111919 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -776,19 +776,22 @@ static void zend_ast_export_encaps_list(smart_str *str, char quote, zend_ast_lis } } -static void zend_ast_export_name_list(smart_str *str, zend_ast_list *list, int indent) +static void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list *list, int indent, const char *separator) { uint32_t i = 0; while (i < list->children) { if (i != 0) { - smart_str_appends(str, ", "); + smart_str_appends(str, separator); } zend_ast_export_name(str, list->child[i], 0, indent); i++; } } +#define zend_ast_export_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, ", ") +#define zend_ast_export_catch_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, "|") + static void zend_ast_export_var_list(smart_str *str, zend_ast_list *list, int indent) { uint32_t i = 0; @@ -1584,7 +1587,7 @@ simple_list: break; case ZEND_AST_CATCH: smart_str_appends(str, "} catch ("); - zend_ast_export_ns_name(str, ast->child[0], 0, indent); + zend_ast_export_catch_name_list(str, ast->child[0], indent); smart_str_appends(str, " $"); zend_ast_export_var(str, ast->child[1], 0, indent); smart_str_appends(str, ") {\n"); |
