On 02/20/2015 07:54 AM, Niklas Keller wrote:
Hi internals,

"In Operator" is now in discussion phase.

This RFC adds a new in operator which simplifies contains checks for strings 
and arrays.
Currently, we have to usein_array($needle, $haystack, true) or 
strpos($haystack, $needle) !== false.
These functions have a inconsistent parameter order, so it's hard to remember 
which is the right one
for each. The in operator makes these checks way more readable. Additionally, 
it also works for Traversable.
https://wiki.php.net/rfc/in_operator

Question: The timline says "Line up any remaining RFCs that target PHP
7.0.", does that mean RFCs have to
start voting on Mar 15 or should the vote end there?

It would really make sense to vote on this RFC after there has been a
vote on https://wiki.php.net/rfc/context_sensitive_lexer.

Regards, Niklas

While I love the idea, strict type comparison for in would, in essence, be a toe-dip into the scalar strict typing world (see other thread) that would be very confusing. Consider:

if (3 in $_GET['filters']) { ... }

That would always be false, because $_GET is always strings. To make that work I'd need to first cast all of the elements in that array to ints... which I'm not actually sure how to do cleanly.

I'd much rather we tighten up the rules around implicit casts generally, as discussed elsewhere, and then allow those "loose but not as loose as we have now" rules here.

--Larry Garfield

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to