rfc:multiple-catch
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:multiple-catch [2016/03/07 21:47] – pierrick | rfc:multiple-catch [2016/04/17 16:37] – pierrick | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2016-03-06 | * Date: 2016-03-06 | ||
* Author: Pierrick Charron < | * 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) { |
// ... | // ... | ||
} | } | ||
</ | </ | ||
- | One good solution to fix this problem on user level would be for ExceptionType1 and ExceptionType2 | + | A solution to fix this problem on the user level would be to implement a common interface |
===== Proposal ===== | ===== Proposal ===== | ||
- | This RFC introduce | + | This RFC introduces |
<code php> | <code php> | ||
Line 42: | 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 usefull ? ==== | ||
+ | |||
+ | * When a single method/ | ||
+ | * When libraries are leaking their dependency' | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 61: | 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 ===== | ===== Links and Literature ===== | ||
Line 68: | Line 79: | ||
Request on StackOverflow: | Request on StackOverflow: | ||
- | ===== Proposed Voting Choices | + | ===== 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. | + | 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. |
+ | |||
+ | <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