rfc:in_operator
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:in_operator [2015/02/19 23:56] – updated draft kelunik | rfc:in_operator [2015/02/26 19:40] – kelunik | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: In Operator ====== | ====== PHP RFC: In Operator ====== | ||
- | * Version: 0.2 | + | * Version: 0.4 |
- | * Date: 2015-02-17 | + | * Date: 2015-02-26 |
* Authors: Niklas Keller < | * Authors: Niklas Keller < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
- | This RFC adds a new '' | + | This RFC adds a new '' |
===== Proposal ===== | ===== Proposal ===== | ||
Add a new operator '' | Add a new operator '' | ||
- | It uses strict comparison ('' | + | It uses strict comparison ('' |
<code php> | <code php> | ||
Line 20: | Line 20: | ||
$contains = " | $contains = " | ||
$contains = 0 in [" | $contains = 0 in [" | ||
+ | |||
+ | $contains = [" | ||
+ | $contains = [" | ||
</ | </ | ||
- | If the first parameter is an array, it checks for every element whether it's contained in the '' | + | '' |
<code php> | <code php> | ||
- | $contains = [" | + | function gen () { |
- | $contains = [" | + | yield " |
- | $contains = [[" | + | yield " |
- | $contains = [["foo", " | + | |
+ | | ||
+ | } | ||
+ | |||
+ | $contains = " | ||
+ | $contains = "baz" in gen(); // false | ||
</ | </ | ||
- | For stings, it behaves exactly like '' | + | If '' |
<code php> | <code php> | ||
$contains = " | $contains = " | ||
$contains = " | $contains = " | ||
+ | $contains = 0 in " | ||
+ | $contains = 0 in 100; // true | ||
</ | </ | ||
- | Objects are not supported, because | + | **Note**: This is a difference compared to '' |
+ | |||
+ | Other values than '' | ||
+ | |||
+ | If '' | ||
+ | |||
+ | ==== Why strict? ==== | ||
+ | It's strict | ||
+ | |||
+ | ==== Precedence ==== | ||
+ | It should | ||
+ | |||
+ | <code php> | ||
+ | if (!$input in $validValues) { | ||
+ | // ... | ||
+ | } | ||
+ | </ | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | New reserved keyword '' | + | New reserved keyword '' |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 50: | Line 76: | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
- | Make sure there are no open issues when the vote starts! | + | None. |
===== Future Scope ===== | ===== Future Scope ===== | ||
- | None. | + | There could be a syntax that allows to check for multiple values at once, e.g. |
+ | <code php> | ||
+ | $contains = ...[" | ||
+ | </ | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
Line 59: | Line 88: | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | TBD | + | * https:// |
- | + | ||
- | ===== Implementation ===== | + | |
- | TBD | + | |
===== Rejected Features ===== | ===== Rejected Features ===== | ||
Keep this updated with features that were discussed on the mail lists. | Keep this updated with features that were discussed on the mail lists. | ||
+ | |||
+ | ===== Changelog ===== | ||
+ | * v0.4: Removed possibility to check multiple values using an array. |
rfc/in_operator.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1