This is an old revision of the document!
PHP RFC: Your Title Here
- Version: 0.1
- Date: 2015-02-02
- Author: Niklas Keller, me@kelunik.com
- Status: Draft
- First Published at: http://wiki.php.net/rfc/in_operator
Introduction
This RFC adds a new in
operator. It simplifies contains
checks for strings and arrays and checks for accessible properties in objects.
Proposal
Add a new operator (expr1) in (expr2)
. For strings and arrays, it checks whether expr2
contains expr1
.
$contains = "foo" in ["a", "b", "c"]; // false $contains = "foo" in ["foo", "bar"]; // true $contains = "foo" in "foobar"; // true $contains = "php" in "foobar"; // false
For objects, it works a bit differently, it checks if expr1
is a accessible property name of the expr2
.
$stdClass = new StdClass; $stdClass->foo = "bar"; $contains = "foo" in $stdClass; // true $contains = "bar" in $stdClass; // false
Backward Incompatible Changes
New reserved keyword in
.
Proposed PHP Version(s)
Next major release, at the time of writing PHP 7.
RFC Impact
To SAPIs
Describe the impact to CLI, Development web server, embedded PHP etc.
To Existing Extensions
Will existing extensions be affected?
To Opcache
It is necessary to develop RFC's with opcache in mind, since opcache is a core extension distributed with PHP.
Please explain how you have verified your RFC's compatibility with opcache.
New Constants
A T_IN
constant for use with ext/tokenizer has been added.
Open Issues
Make sure there are no open issues when the vote starts!
Unaffected PHP Functionality
List existing areas/features of PHP that will not be changed by the RFC.
This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise.
Future Scope
None.
Proposed Voting Choices
Requires a 2/3 majority.
Patches and Tests
Links to any external patches and tests go here.
If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed.
Make it clear if the patch is intended to be the final patch, or is just a prototype.
Implementation
After the project is implemented, this section should contain
- the version(s) it was merged to
- a link to the git commit(s)
- a link to the PHP manual entry for the feature
References
Links to external references, discussions or RFCs
Rejected Features
Keep this updated with features that were discussed on the mail lists.