rfc:in_operator
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:in_operator [2015/02/02 13:10] – very basic draft kelunik | rfc:in_operator [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== PHP RFC: Your Title Here ====== | + | ====== PHP RFC: In Operator |
- | * Version: 0.1 | + | * Version: 0.5.1 |
- | * Date: 2015-02-02 | + | * Date: 2015-03-15 |
- | * Author: Niklas Keller, me@kelunik.com | + | * 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 '' |
+ | |||
+ | ===== Motivation ===== | ||
+ | Checking if a specific input in an allowed range of value is a very common check in web application, | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | Add a new operator '' | + | Add a new operator '' |
- | $contains | + | It uses strict comparison ('' |
- | $contains | + | |
- | $contains | + | |
- | $contains = " | + | |
- | For objects, it works a bit differently, it checks if '' | + | <code php> |
+ | $contains = " | ||
+ | $contains = " | ||
+ | $contains = " | ||
+ | $contains = " | ||
+ | $contains = 0 in [" | ||
- | | + | $contains |
- | $stdClass-> | + | $contains = ["foo"] in [" |
- | $contains = " | + | </ |
- | $contains = "bar" in $stdClass; // false | + | |
- | ===== Backward Incompatible Changes ===== | + | '' |
- | New reserved keyword | + | |
- | ===== Proposed PHP Version(s) ===== | + | <code php> |
- | Next major release, at the time of writing PHP 7. | + | function gen () { |
+ | yield " | ||
+ | yield " | ||
+ | // code below here wouldn' | ||
+ | // because it stops if there' | ||
+ | } | ||
- | ===== RFC Impact ===== | + | $contains |
- | ==== To SAPIs ==== | + | $contains |
- | Describe the impact to CLI, Development web server, embedded PHP etc. | + | </ |
- | ==== To Existing Extensions ==== | + | If '' |
- | Will existing extensions be affected? | + | |
- | ==== To Opcache ==== | + | <code php> |
- | It is necessary to develop RFC's with opcache in mind, since opcache is a core extension distributed with PHP. | + | $contains |
+ | $contains | ||
+ | </ | ||
- | Please explain how you have verified your RFC's compatibility with opcache. | + | Other expressions than '' |
- | ==== New Constants | + | ==== Why strict? |
- | A '' | + | It's strict because otherwise something like '' |
- | ===== Open Issues ===== | + | ==== Precedence |
- | Make sure there are no open issues when the vote starts! | + | It should have the same precedence as '' |
- | ===== Unaffected PHP Functionality ===== | + | <code php> |
- | List existing areas/features of PHP that will not be changed by the RFC. | + | if (!$input in $validValues) { |
+ | // ... | ||
+ | } | ||
+ | </ | ||
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. | + | ===== Backward Incompatible Changes ===== |
+ | New reserved keyword '' | ||
- | ===== Future Scope ===== | + | ===== Proposed PHP Version(s) |
- | None. | + | Next major release, at the time of writing PHP 7. |
- | ===== Proposed Voting Choices | + | ===== RFC Impact |
- | Requires a 2/3 majority. | + | ==== New Constants ==== |
+ | A '' | ||
- | ===== Patches and Tests ===== | + | ===== Future Scope ===== |
- | Links to any external patches and tests go here. | + | There could be a syntax that allows |
+ | <code php> | ||
+ | $contains = ...[" | ||
+ | </ | ||
- | If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed. | + | ===== Votes ===== |
+ | Requires a 2/3 majority. Even if it passes, it will //only// get merged if the [[rfc/ | ||
- | Make it clear if the patch is intended to be the final patch, or is just a prototype. | + | <doodle title=" |
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
- | ===== Implementation ===== | + | Voting started on 2015-03-15 and ends on 2015-03-29. |
- | After the project is implemented, | + | |
- | | + | |
- | | + | |
- | | + | |
- | ===== References | + | ===== Patches and Tests ===== |
- | Links to external references, discussions or RFCs | + | * https:// |
===== 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.5: Removed integer support, so the strictness is consistent. | ||
+ | * v0.4: Removed possibility to check multiple values using an array. |
rfc/in_operator.1422882658.txt.gz · Last modified: 2017/09/22 13:28 (external edit)