rfc:multiple-catch
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:multiple-catch [2016/03/07 16:57] – created pierrick | rfc:multiple-catch [2016/05/01 21:58] – Closing vote pierrick | ||
---|---|---|---|
Line 2: | Line 2: | ||
* Version: 1.0 | * Version: 1.0 | ||
* Date: 2016-03-06 | * Date: 2016-03-06 | ||
- | * Author: Pierrick Charron, pierrick@php.net | + | * Author: Pierrick Charron |
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | It is sometime required to duplicate code of a catch statement because | + | When two different types of exceptions |
+ | |||
+ | For example : | ||
<code php> | <code php> | ||
Line 19: | Line 21: | ||
} catch (ExceptionType2 $e) { | } catch (ExceptionType2 $e) { | ||
// Same code to handle the exception | // Same code to handle the exception | ||
- | } catch (\Exception $e) { | + | } catch (Exception $e) { |
// ... | // ... | ||
} | } | ||
</ | </ | ||
+ | |||
+ | A solution to fix this problem on the user level would be to implement a common interface for '' | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC introduce | + | This RFC introduces |
<code php> | <code php> | ||
Line 40: | Line 44: | ||
</ | </ | ||
- | This syntax and functionality is compatible with the Union RFC proposed here : https:// | + | This syntax and functionality is compatible with the Union types RFC proposed here : https:// |
+ | |||
+ | ==== When is it useful ? ==== | ||
+ | |||
+ | * When a single method/ | ||
+ | * When libraries are leaking their dependency' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 59: | Line 69: | ||
==== To Opcache ==== | ==== To Opcache ==== | ||
None | None | ||
+ | |||
+ | ==== To PHP tools/IDE ==== | ||
+ | This change will require every PHP tools and IDE based on an AST parser to be modified to take this syntax change into account. | ||
+ | |||
+ | ===== Links and Literature ===== | ||
+ | |||
+ | Similar feature in Java: http:// | ||
+ | |||
+ | Request on StackOverflow: | ||
+ | |||
+ | ===== Vote ===== | ||
+ | As this is a language change, a 2/3 majority is required. The vote is a straight Yes/No vote for accepting the RFC and merging the patch. Voting started on 2016-04-17 and will end on 2016-05-01. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | Patch : [[https:// | + | Patch : [[https:// |
rfc/multiple-catch.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1