rfc:isset_ternary
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:isset_ternary [2014/09/17 01:58] – Say no to curly quotes levim | rfc:isset_ternary [2015/12/24 21:14] – add docs link ajf | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Null Coalesce Operator ====== | ====== PHP RFC: Null Coalesce Operator ====== | ||
- | * Version: 0.2.1 | + | * Version: 0.2.3 |
* Date: 2014-09-06, last updated 2014-09-16 | * Date: 2014-09-06, last updated 2014-09-16 | ||
- | * Author: Andrea Faulds, ajf@ajf.me | + | * Author: Andrea Faulds |
- | * Status: | + | * Contributor: |
+ | * Status: | ||
* First Published at: http:// | * First Published at: http:// | ||
Line 9: | Line 10: | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | PHP is a web-focussed programming language, so processing user data is a frequent activity. In such processing it is common to check for something' | + | PHP is a web-focussed programming language, so processing user data is a frequent activity. In such processing it is common to check for something' |
===== Proposal ===== | ===== Proposal ===== | ||
Line 42: | Line 43: | ||
</ | </ | ||
- | ===== Proposed PHP Version(s) ===== | + | This example demonstrates the precedence relative to the ternary operator and the boolean or operator, which is the same as C#: |
- | This proposed for the next PHP x, which at the time of this writing would be PHP 7. | + | <code php> |
+ | var_dump(2 ?? 3 ? 4 : 5); // (2 ?? 3) ? 4 : 5 => int(4) | ||
+ | var_dump(0 || 2 ?? 3 ? 4 : 5); // ((0 || 2) ?? 3) ? 4 : 5 => int(4) | ||
+ | </ | ||
+ | This example demonstrates how it is a short-circuiting operator: | ||
- | ===== Proposed Voting Choices ===== | + | <code php> |
+ | function foo() { | ||
+ | echo " | ||
+ | } | ||
+ | var_dump(true ?? foo()); // outputs bool(true), " | ||
+ | </ | ||
- | As this is a language change, a 2/3 majority is required. A straight Yes/No vote would be held. | + | ===== Proposed PHP Version(s) ===== |
+ | |||
+ | This proposed for the next PHP x, which at the time of this writing | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
Line 56: | Line 68: | ||
The original patch was graciously provided by Nikita Popov. | The original patch was graciously provided by Nikita Popov. | ||
+ | |||
+ | ===== Vote ===== | ||
+ | |||
+ | As this is a language change, a 2/3 majority is required. A straight Yes/No vote is being held. | ||
+ | |||
+ | Voting started on 2014-09-20 and ended on 2014-09-27. | ||
+ | |||
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | After the project is implemented, | + | |
- | - the version(s) it was merged to | + | Merged into master |
- | | + | |
- | - a link to the PHP manual | + | Documented at: http:// |
===== References ===== | ===== References ===== | ||
Line 77: | Line 100: | ||
This list is quite probably incomplete. | This list is quite probably incomplete. | ||
+ | |||
+ | Operator precedence in C#: http:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
Line 83: | Line 108: | ||
===== Changelog ===== | ===== Changelog ===== | ||
+ | * v0.2.3 - Added short-circuit example | ||
+ | * v0.2.2 - Added precedence example | ||
* v0.2.1 - Added chaining example | * v0.2.1 - Added chaining example | ||
* v0.2 - Overhauled proposal, proposing new operator ''??'' | * v0.2 - Overhauled proposal, proposing new operator ''??'' | ||
* v0.1 - Created | * v0.1 - Created |
rfc/isset_ternary.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1