<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>[PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
        <description>Hi internals!

As per the comments I created an RFC, proposing to allow arbitrary
expressions to be passed to empty() and isset():

https://wiki.php.net/rfc/empty_isset_exprs

The patch is available as a PR:

https://github.com/php/php-src/pull/54

Nikita

PS: I added isset() too, to address the consistency concerns mentioned on IRC.

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php</description>
        <link>http://www.serverphorums.com/read.php?7,478374,478374#msg-478374</link>
        <lastBuildDate>Sat, 25 May 2013 08:25:51 +0200</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,490790#msg-490790</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,490790#msg-490790</link>
            <description><![CDATA[ On Fri, May 4, 2012 2:10 pm, Kris Craig wrote:<br />
&gt; On Fri, May 4, 2012 at 11:48 AM, Richard Lynch &lt;ceo@l-i-e.com&gt; wrote:<br />
&gt;<br />
&gt;&gt; On Wed, May 2, 2012 4:43 am, Pierre Joye wrote:<br />
&gt;&gt; &gt;&gt;&gt; empty() on the other hand, tests if something is empty, and only<br />
&gt;&gt; if<br />
&gt;&gt; &gt;&gt;&gt; it<br />
&gt;&gt; &gt;&gt;&gt; is empty. The result of an expression can be empty.<br />
&gt;&gt; &gt;&gt;&gt;<br />
&gt;&gt; &gt;&gt;<br />
&gt;&gt; &gt;&gt; an expression can also have a value of null.<br />
&gt;&gt; &gt;<br />
&gt;&gt; &gt; And NULL is empty. No issue here.<br />
&gt;&gt;<br />
&gt;&gt; Expressions can also return &quot;&quot;, 0, 0.0, &quot;0&quot;, array()<br />
&gt;&gt;<br />
&gt;&gt; You really think those should all be empty?<br />
&gt;&gt;<br />
&gt;<br />
&gt; Unless I'm missing something here, aren't all those things already<br />
considered to be empty??  Here's what the PHP man page for empty()<br />
says:<br />
&gt;<br />
&gt; The following things are considered to be empty:<br />
&gt;<br />
&gt;    - *&quot;&quot;* (an empty string)<br />
&gt;    - *0* (0 as an integer)<br />
&gt;    - *0.0* (0 as a float)<br />
&gt;    - *&quot;0&quot;* (0 as a string)<br />
&gt;    - *NULL*<br />
&gt;    - *FALSE*<br />
&gt;    - *array()* (an empty array)<br />
&gt;    - *var $var;* (a variable declared, but without a value in a class)<br />
<br />
I am suggesting that some of those wouldn't make so much sense being<br />
&quot;empty&quot; in an expression.<br />
<br />
empty(2.0 - 1.9999999999999);<br />
<br />
Might not be 0.0, but that's not the point.<br />
<br />
For some not-empty values added or subtracted, more or less at the<br />
whims of digital float behave would or wouldn't be empty.<br />
<br />
Furthermore, empty on &quot;0&quot; was originally designed user input via<br />
GET/POST so that an &lt;option&gt;0&lt;/option&gt; would be empty()<br />
<br />
-- <br />
brain cancer update:<br />
<a href="http://richardlynch.blogspot.com/search/label/brain%20tumor" target="_blank"  rel="nofollow">http://richardlynch.blogspot.com/search/label/brain%20tumor</a><br />
Donate:<br />
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=FS9NLTNEEKWBE" target="_blank"  rel="nofollow">https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=FS9NLTNEEKWBE</a><br />
<br />
<br />
<br />
<br />
-- <br />
brain cancer update:<br />
<a href="http://richardlynch.blogspot.com/search/label/brain%20tumor" target="_blank"  rel="nofollow">http://richardlynch.blogspot.com/search/label/brain%20tumor</a><br />
Donate:<br />
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=FS9NLTNEEKWBE" target="_blank"  rel="nofollow">https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=FS9NLTNEEKWBE</a><br />
<br />
<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Richard Lynch</dc:creator>
            <category>php-internals</category>
            <pubDate>Sat, 05 May 2012 14:30:09 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,490583#msg-490583</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,490583#msg-490583</link>
            <description><![CDATA[ &gt;<br />
&gt;<br />
&gt; Hmm I'd never really thought about that before.  But now that you mention<br />
&gt; it, that does sound like a problem.  Honestly, I can see no value in<br />
&gt; maintaining a different &quot;standard&quot; for what constitutes a set or not-set<br />
&gt; variable depending on the function.  While I understand Pierre's point that<br />
&gt; people have used $var = NULL; in the past to unset variables, I don't think<br />
&gt; we should actually be supporting that.  After all, $var = (anything,<br />
&gt; including nothing) is, by definition, &quot;setting&quot; the variable to something<br />
&gt; (or nothing).<br />
&gt;<br />
&gt; I would analogize this to a printed dictionary.  Let's say you look up the<br />
&gt; word, &quot;glarbofatass&quot;.  It's not there.  So you take out another dictionary<br />
&gt; and look it up again.  There's an entry for it, but the entry says, &quot;This<br />
&gt; word has no meaning.&quot;  In the first dictionary, &quot;glarbofatass&quot; is not set..<br />
&gt;  In the second dictionary, &quot;glarbofatass&quot; is set to the state of having no<br />
&gt; meaning.  Nevertheless, it *is* set.<br />
&gt;<br />
&gt; I've never thought of setting something to NULL as being *literally *the<br />
&gt; same thing as unsetting it (though the purpose and end result are mostly<br />
&gt; the same).  If we didn't have an unset() function, I might feel differently<br />
&gt; about this.  But we do, so really I don't see why &quot;= NULL&quot; needs to be an<br />
&gt; alias for unset().  To be honest, I doubt this would pose any real BC<br />
&gt; breakage, either, unless someone can point me to an instance where somebody<br />
&gt; uses &quot;= NULL&quot; to unset a variable and then checks it with isset() later,<br />
&gt; expecting FALSE.<br />
&gt;<br />
&gt; Personally, I would consider &quot;= NULL&quot; == unset() but only as it pertains<br />
&gt; to isset() to be a bug that should be fixed, not a &quot;feature&quot; that should be<br />
&gt; preserved.  And if we make that change (perhaps target it for PHP 6 since<br />
&gt; it would nonetheless pose a fundamental logic change, albeit an extremely<br />
&gt; minor and low-impact one), then this RFC suddenly makes a lot more sense<br />
&gt; while allowing the scope to be limited to empty() without creating any<br />
&gt; annoying contradictions.<br />
&gt;<br />
&gt;<br />
then maybe you should open a separate rfc and thread for that.<br />
btw. $foo = null; doesn't equals/aliases  unset($foo); only isset() written<br />
in a way so that it checks the existence of the variable AND if it exists<br />
then checks that it's value isn't null.<br />
maybe this isn't nice for a newcommer to the language, but it is how isset<br />
works for a pretty long time now, and changing it would be a major BC break..<br />
not impossible, but that would definitively deserve a separate RFC and<br />
discussion.<br />
<br />
-- <br />
Ferenc Kovács<br />
@Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a>]]></description>
            <dc:creator>Ferenc Kovacs</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 04 May 2012 23:30:07 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,490521#msg-490521</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,490521#msg-490521</link>
            <description><![CDATA[ On Fri, May 4, 2012 at 1:27 PM, Ferenc Kovacs &lt;tyra3l@gmail.com&gt; wrote:<br />
<br />
&gt;<br />
&gt;&gt; I've been following the debate and I'm still a bit unclear as to what the<br />
&gt;&gt; benefit would be to allowing non-variables in isset().  I mean, as was<br />
&gt;&gt; stated earlier, expressions are neither &quot;set&quot; nor &quot;unset&quot;.  Furthermore,<br />
&gt;&gt; if<br />
&gt;&gt; you were to assign a variable to any valid expression (empty or<br />
&gt;&gt; otherwise),<br />
&gt;&gt; it would be considered &quot;set&quot;.  Therefore, through simple deductive logic,<br />
&gt;&gt; would an expression passed to isset() not, by definition, *always* return<br />
&gt;&gt;<br />
&gt;&gt; TRUE if the expression itself is syntactically valid?<br />
&gt;&gt;<br />
&gt;<br />
&gt; yeah, this wouldn't be much to think about if isset in php wouldn't handle<br />
&gt; null values as not set.<br />
&gt;<br />
<br />
Hmm I'd never really thought about that before.  But now that you mention<br />
it, that does sound like a problem.  Honestly, I can see no value in<br />
maintaining a different &quot;standard&quot; for what constitutes a set or not-set<br />
variable depending on the function.  While I understand Pierre's point that<br />
people have used $var = NULL; in the past to unset variables, I don't think<br />
we should actually be supporting that.  After all, $var = (anything,<br />
including nothing) is, by definition, &quot;setting&quot; the variable to something<br />
(or nothing).<br />
<br />
I would analogize this to a printed dictionary.  Let's say you look up the<br />
word, &quot;glarbofatass&quot;.  It's not there.  So you take out another dictionary<br />
and look it up again.  There's an entry for it, but the entry says, &quot;This<br />
word has no meaning.&quot;  In the first dictionary, &quot;glarbofatass&quot; is not set.<br />
 In the second dictionary, &quot;glarbofatass&quot; is set to the state of having no<br />
meaning.  Nevertheless, it *is* set.<br />
<br />
I've never thought of setting something to NULL as being *literally *the<br />
same thing as unsetting it (though the purpose and end result are mostly<br />
the same).  If we didn't have an unset() function, I might feel differently<br />
about this.  But we do, so really I don't see why &quot;= NULL&quot; needs to be an<br />
alias for unset().  To be honest, I doubt this would pose any real BC<br />
breakage, either, unless someone can point me to an instance where somebody<br />
uses &quot;= NULL&quot; to unset a variable and then checks it with isset() later,<br />
expecting FALSE.<br />
<br />
Personally, I would consider &quot;= NULL&quot; == unset() but only as it pertains to<br />
isset() to be a bug that should be fixed, not a &quot;feature&quot; that should be<br />
preserved.  And if we make that change (perhaps target it for PHP 6 since<br />
it would nonetheless pose a fundamental logic change, albeit an extremely<br />
minor and low-impact one), then this RFC suddenly makes a lot more sense<br />
while allowing the scope to be limited to empty() without creating any<br />
annoying contradictions.<br />
<br />
--Kris]]></description>
            <dc:creator>Kris Craig</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 04 May 2012 23:20:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,490426#msg-490426</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,490426#msg-490426</link>
            <description><![CDATA[ &gt;<br />
&gt;<br />
&gt; I've been following the debate and I'm still a bit unclear as to what the<br />
&gt; benefit would be to allowing non-variables in isset().  I mean, as was<br />
&gt; stated earlier, expressions are neither &quot;set&quot; nor &quot;unset&quot;.  Furthermore, if<br />
&gt; you were to assign a variable to any valid expression (empty or otherwise),<br />
&gt; it would be considered &quot;set&quot;.  Therefore, through simple deductive logic,<br />
&gt; would an expression passed to isset() not, by definition, *always* return<br />
&gt; TRUE if the expression itself is syntactically valid?<br />
<br />
<br />
yeah, this wouldn't be much to think about if isset in php wouldn't handle<br />
null values as not set.<br />
and as I mentioned expressions can return null, so it isn't true that any<br />
expression given to isset would always result in true.<br />
but I think we were talked this over already, so not much point repeating<br />
the same arguments over and over again.<br />
<br />
to summarize, the following cons were brought up against allowing<br />
expressions for isset :<br />
<br />
<br />
   - if you pass an undefined constant to isset, you will get unexpected<br />
   result as isset will raise a notice and can return unexpected result as the<br />
   constant is casted to string before being passed to isset(btw. this is how<br />
   expressions work everywhere else, so it isn't a real surprise, but it is a<br />
   change to the current behavior).<br />
      - this is a valid concern, but the same problem applies to empty too,<br />
      so it is a general problem with the current patch/rfc. I think<br />
it would be<br />
      nice mentioning this in the rfc, as this could/will cause a few<br />
wtf moments<br />
      for some people.<br />
   - isset(CONST) could be seen as defined(&quot;CONST&quot;) but they are returning<br />
   different results if CONS is defined with NULL or undefined.<br />
      - this is a valid concern, and there is no good solution, for<br />
      isset(CONST) we either go cosistent with isset or declared, but can't do<br />
      both at the same time.<br />
   - semantically empty can make sense for expressions, isset doesn't:<br />
      - yep, the only thing that makes this a little less clear/obvious is<br />
      the fact that isset in php also checks for value, not only the<br />
&quot;existence&quot;<br />
      of the variable.<br />
   - following the previous point, there are much more fluent use-cases for<br />
   empty(expression) than for isset(expression)<br />
      - this is true, for null check you should use comparing the value,<br />
      for other cases empty could be much more useful, only the isset(CONST)<br />
      could be useful, but I mentioned the problems with that above.<br />
<br />
after discussing this and thinking it over a few times, I decided that I<br />
will drop my case about supporting both empty and isset.<br />
I think that keeping the argument handling for isset and empty in sync<br />
doesn't worth the possible gotchas.<br />
and I now a little less sure about suporting this change for empty(), given<br />
how much do we emphasized over the years that empty won't trigger any<br />
warning about the non-existent variables.<br />
<br />
-- <br />
Ferenc Kovács<br />
@Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a>]]></description>
            <dc:creator>Ferenc Kovacs</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 04 May 2012 22:30:48 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,490390#msg-490390</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,490390#msg-490390</link>
            <description><![CDATA[ On Fri, May 4, 2012 at 11:48 AM, Richard Lynch &lt;ceo@l-i-e.com&gt; wrote:<br />
<br />
&gt; On Wed, May 2, 2012 4:43 am, Pierre Joye wrote:<br />
&gt; &gt;&gt;&gt; empty() on the other hand, tests if something is empty, and only if<br />
&gt; &gt;&gt;&gt; it<br />
&gt; &gt;&gt;&gt; is empty. The result of an expression can be empty.<br />
&gt; &gt;&gt;&gt;<br />
&gt; &gt;&gt;<br />
&gt; &gt;&gt; an expression can also have a value of null.<br />
&gt; &gt;<br />
&gt; &gt; And NULL is empty. No issue here.<br />
&gt;<br />
&gt; Expressions can also return &quot;&quot;, 0, 0.0, &quot;0&quot;, array()<br />
&gt;<br />
&gt; You really think those should all be empty?<br />
&gt;<br />
<br />
Unless I'm missing something here, aren't all those things already<br />
considered to be empty??  Here's what the PHP man page for empty() says:<br />
<br />
The following things are considered to be empty:<br />
<br />
   - *&quot;&quot;* (an empty string)<br />
   - *0* (0 as an integer)<br />
   - *0.0* (0 as a float)<br />
   - *&quot;0&quot;* (0 as a string)<br />
   - *NULL*<br />
   - *FALSE*<br />
   - *array()* (an empty array)<br />
   - *var $var;* (a variable declared, but without a value in a class)<br />
<br />
<br />
If that's the way it already behaves, then why would keeping it that way<br />
even be an issue?  If an expression returns any of those things, it's empty.<br />
<br />
I've been following the debate and I'm still a bit unclear as to what the<br />
benefit would be to allowing non-variables in isset().  I mean, as was<br />
stated earlier, expressions are neither &quot;set&quot; nor &quot;unset&quot;.  Furthermore, if<br />
you were to assign a variable to any valid expression (empty or otherwise),<br />
it would be considered &quot;set&quot;.  Therefore, through simple deductive logic,<br />
would an expression passed to isset() not, by definition, *always* return<br />
TRUE if the expression itself is syntactically valid?  The answer seems to<br />
be yes as far as I can tell.  And if that is the case, then what value is<br />
there in allowing it if the return value is always the same no matter what?<br />
<br />
--Kris]]></description>
            <dc:creator>Kris Craig</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 04 May 2012 21:20:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,490370#msg-490370</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,490370#msg-490370</link>
            <description><![CDATA[ On Wed, May 2, 2012 4:43 am, Pierre Joye wrote:<br />
&gt;&gt;&gt; empty() on the other hand, tests if something is empty, and only if<br />
&gt;&gt;&gt; it<br />
&gt;&gt;&gt; is empty. The result of an expression can be empty.<br />
&gt;&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt; an expression can also have a value of null.<br />
&gt;<br />
&gt; And NULL is empty. No issue here.<br />
<br />
Expressions can also return &quot;&quot;, 0, 0.0, &quot;0&quot;, array()<br />
<br />
You really think those should all be empty?<br />
<br />
Or you want different behavior for expressions vs variables. I'm<br />
assuming virtually everybody would agree THAT is unacceptable...<br />
<br />
Or are the rules for what is or isn't empty going to also change. Again.<br />
<br />
-- <br />
brain cancer update:<br />
<a href="http://richardlynch.blogspot.com/search/label/brain%20tumor" target="_blank"  rel="nofollow">http://richardlynch.blogspot.com/search/label/brain%20tumor</a><br />
Donate:<br />
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=FS9NLTNEEKWBE" target="_blank"  rel="nofollow">https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=FS9NLTNEEKWBE</a><br />
<br />
<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Richard Lynch</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 04 May 2012 20:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,489926#msg-489926</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,489926#msg-489926</link>
            <description><![CDATA[ Patrick ALLAERT wrote:<br />
&gt; 2012/5/3 Lester Caine&lt;lester@lsces.co.uk&gt;:<br />
&gt;&gt; Anthony Ferrara wrote:<br />
&gt;&gt;&gt;<br />
&gt;&gt;&gt; I voted for the ability to use an expression for isset() as well,<br />
&gt;&gt;&gt; since I agree with Ferenc, it's a matter of consistency.  Sure, the<br />
&gt;&gt;&gt; use-case for isset() is definitely weaker than for empty(), but at the<br />
&gt;&gt;&gt; same token they are definitely related...<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt; I just can't help feeling that it is the wrong use of both. If the function<br />
&gt;&gt; is returning a value, then it's returning a value that needs to be used<br />
&gt;&gt; somewhere so the work flow handles that. If the function returns nothing<br />
&gt;&gt; instead that just seems wrong and needs to be handled better. I'm used to<br />
&gt;&gt; getting back 'false' if the function failed and just check for that so why<br />
&gt;&gt; would there be any logical reason for using isset or empty to check a<br />
&gt;&gt; function return?<br />
&gt;<br />
&gt; Use case:<br />
&gt;<br />
&gt; // Function definition:<br />
&gt; function getFriends()<br />
&gt; {<br />
&gt;      // SQL SELECT or Fetching from XML or Fetching from LDAP or ...<br />
&gt;      return $resultsAsArray;<br />
&gt; }<br />
&gt;<br />
&gt; // Looping on results:<br />
&gt; foreach ( getFriends() as $friend )<br />
&gt; {<br />
&gt;      echo $friend[&quot;name&quot;], &quot;\n&quot;;<br />
&gt; }<br />
&gt;<br />
&gt; // Case where the results are actually not iterated:<br />
&gt; $amIAssocial = empty( getFriends() );<br />
&gt;<br />
&gt; 1. It it not wrong to return &quot;nothing&quot;, like empty sets (empty<br />
&gt; arrays), it is a valid case.<br />
&gt; 2. Returning &quot;false&quot; in the case there is no &quot;results&quot; would be a bad<br />
&gt; idea: not only you would have to put a condition in the function<br />
&gt; definition, but you would also require all iterations (e.g. foreach)<br />
&gt; to be encapsulated in a condition statement to prevent looping on<br />
&gt; &quot;false&quot;.<br />
<br />
OK I'm just so used to<br />
if( $rs = $this-&gt;mDb-&gt;query( $query, $bindVars ) ) {<br />
   while( $row = $rs-&gt;fetchRow() ) {<br />
   }<br />
}<br />
<br />
So I can't see where 'empty( $rs-&gt;fetchRow() )' would fit into the work flow ...<br />
<br />
-- <br />
Lester Caine - G8HFL<br />
-----------------------------<br />
Contact - <a href="http://lsces.co.uk/wiki/?page=contact" target="_blank"  rel="nofollow">http://lsces.co.uk/wiki/?page=contact</a><br />
L.S.Caine Electronic Services - <a href="http://lsces.co.uk" target="_blank"  rel="nofollow">http://lsces.co.uk</a><br />
EnquirySolve - <a href="http://enquirysolve.com/" target="_blank"  rel="nofollow">http://enquirysolve.com/</a><br />
Model Engineers Digital Workshop - <a href="http://medw.co.uk//" target="_blank"  rel="nofollow">http://medw.co.uk//</a><br />
Firebird - <a href="http://www.firebirdsql.org/index.php" target="_blank"  rel="nofollow">http://www.firebirdsql.org/index.php</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Lester Caine</dc:creator>
            <category>php-internals</category>
            <pubDate>Thu, 03 May 2012 22:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,489921#msg-489921</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,489921#msg-489921</link>
            <description><![CDATA[ &gt;&gt; I just can't help feeling that it is the wrong use of both. If the function<br />
&gt;&gt; is returning a value, then it's returning a value that needs to be used<br />
&gt;&gt; somewhere so the work flow handles that. If the function returns nothing<br />
&gt;&gt; instead that just seems wrong and needs to be handled better. I'm used to<br />
&gt;&gt; getting back 'false' if the function failed and just check for that so why<br />
&gt;&gt; would there be any logical reason for using isset or empty to check a<br />
&gt;&gt; function return?<br />
&gt;<br />
&gt; Use case:<br />
&gt;<br />
&gt; // Function definition:<br />
&gt; function getFriends()<br />
&gt; {<br />
&gt;    // SQL SELECT or Fetching from XML or Fetching from LDAP or ....<br />
&gt;    return $resultsAsArray;<br />
&gt; }<br />
&gt;<br />
&gt; // Looping on results:<br />
&gt; foreach ( getFriends() as $friend )<br />
&gt; {<br />
&gt;    echo $friend[&quot;name&quot;], &quot;\n&quot;;<br />
&gt; }<br />
&gt;<br />
&gt; // Case where the results are actually not iterated:<br />
&gt; $amIAssocial = empty( getFriends() );<br />
<br />
This is the exact same thing:<br />
$amIAssocial = !getFriends();<br />
<br />
<br />
Earlier, I sent this to Lester only:<br />
Most people don't realize that an empty array is already falsy so they<br />
feel the need to use empty. That is the only use-case the RFC gives<br />
for making this change. From the RFC: &quot;For example if func() is<br />
expected to return an array, it feels more natural to verify it's<br />
emptiness using empty() instead of !.&quot;<br />
-- <br />
Herman Radtke<br />
<a href="mailto:&#104;&#101;&#114;&#109;&#97;&#110;&#114;&#97;&#100;&#116;&#107;&#101;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;">&#104;&#101;&#114;&#109;&#97;&#110;&#114;&#97;&#100;&#116;&#107;&#101;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;</a> | <a href="http://hermanradtke.com" target="_blank"  rel="nofollow">http://hermanradtke.com</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Herman Radtke</dc:creator>
            <category>php-internals</category>
            <pubDate>Thu, 03 May 2012 22:40:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,489850#msg-489850</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,489850#msg-489850</link>
            <description><![CDATA[ 2012/5/3 Lester Caine &lt;lester@lsces.co.uk&gt;:<br />
&gt; Anthony Ferrara wrote:<br />
&gt;&gt;<br />
&gt;&gt; I voted for the ability to use an expression for isset() as well,<br />
&gt;&gt; since I agree with Ferenc, it's a matter of consistency.  Sure, the<br />
&gt;&gt; use-case for isset() is definitely weaker than for empty(), but at the<br />
&gt;&gt; same token they are definitely related...<br />
&gt;<br />
&gt;<br />
&gt; I just can't help feeling that it is the wrong use of both. If the function<br />
&gt; is returning a value, then it's returning a value that needs to be used<br />
&gt; somewhere so the work flow handles that. If the function returns nothing<br />
&gt; instead that just seems wrong and needs to be handled better. I'm used to<br />
&gt; getting back 'false' if the function failed and just check for that so why<br />
&gt; would there be any logical reason for using isset or empty to check a<br />
&gt; function return?<br />
<br />
Use case:<br />
<br />
// Function definition:<br />
function getFriends()<br />
{<br />
    // SQL SELECT or Fetching from XML or Fetching from LDAP or ...<br />
    return $resultsAsArray;<br />
}<br />
<br />
// Looping on results:<br />
foreach ( getFriends() as $friend )<br />
{<br />
    echo $friend[&quot;name&quot;], &quot;\n&quot;;<br />
}<br />
<br />
// Case where the results are actually not iterated:<br />
$amIAssocial = empty( getFriends() );<br />
<br />
1. It it not wrong to return &quot;nothing&quot;, like empty sets (empty<br />
arrays), it is a valid case.<br />
2. Returning &quot;false&quot; in the case there is no &quot;results&quot; would be a bad<br />
idea: not only you would have to put a condition in the function<br />
definition, but you would also require all iterations (e.g. foreach)<br />
to be encapsulated in a condition statement to prevent looping on<br />
&quot;false&quot;.<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Patrick ALLAERT</dc:creator>
            <category>php-internals</category>
            <pubDate>Thu, 03 May 2012 20:20:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,489444#msg-489444</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,489444#msg-489444</link>
            <description><![CDATA[ Anthony Ferrara wrote:<br />
&gt; I voted for the ability to use an expression for isset() as well,<br />
&gt; since I agree with Ferenc, it's a matter of consistency.  Sure, the<br />
&gt; use-case for isset() is definitely weaker than for empty(), but at the<br />
&gt; same token they are definitely related...<br />
<br />
I just can't help feeling that it is the wrong use of both. If the function is <br />
returning a value, then it's returning a value that needs to be used somewhere <br />
so the work flow handles that. If the function returns nothing instead that just <br />
seems wrong and needs to be handled better. I'm used to getting back 'false' if <br />
the function failed and just check for that so why would there be any logical <br />
reason for using isset or empty to check a function return?<br />
<br />
-- <br />
Lester Caine - G8HFL<br />
-----------------------------<br />
Contact - <a href="http://lsces.co.uk/wiki/?page=contact" target="_blank"  rel="nofollow">http://lsces.co.uk/wiki/?page=contact</a><br />
L.S.Caine Electronic Services - <a href="http://lsces.co.uk" target="_blank"  rel="nofollow">http://lsces.co.uk</a><br />
EnquirySolve - <a href="http://enquirysolve.com/" target="_blank"  rel="nofollow">http://enquirysolve.com/</a><br />
Model Engineers Digital Workshop - <a href="http://medw.co.uk//" target="_blank"  rel="nofollow">http://medw.co.uk//</a><br />
Firebird - <a href="http://www.firebirdsql.org/index.php" target="_blank"  rel="nofollow">http://www.firebirdsql.org/index.php</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Lester Caine</dc:creator>
            <category>php-internals</category>
            <pubDate>Thu, 03 May 2012 09:20:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,489390#msg-489390</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,489390#msg-489390</link>
            <description><![CDATA[ hi Anthony,<br />
<br />
On Wed, May 2, 2012 at 1:37 PM, Anthony Ferrara &lt;ircmaxell@gmail.com&gt; wrote:<br />
<br />
&gt; I voted for the ability to use an expression for isset() as well,<br />
&gt; since I agree with Ferenc, it's a matter of consistency.  Sure, the<br />
&gt; use-case for isset() is definitely weaker than for empty(),<br />
<br />
No, it is not about consistency but goals and meaning. An expression<br />
is not set or unset. Anyway, that's not something we can argue about<br />
forever :-).<br />
<br />
Cheers,<br />
-- <br />
Pierre<br />
<br />
@pierrejoye | <a href="http://blog.thepimp.net" target="_blank"  rel="nofollow">http://blog.thepimp.net</a> | <a href="http://www.libgd.org" target="_blank"  rel="nofollow">http://www.libgd.org</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Pierre Joye</dc:creator>
            <category>php-internals</category>
            <pubDate>Thu, 03 May 2012 07:40:04 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488964#msg-488964</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488964#msg-488964</link>
            <description><![CDATA[ On Wed, May 2, 2012 at 11:43 AM, Pierre Joye &lt;pierre.php@gmail.com&gt; wrote:<br />
<br />
&gt; hi,<br />
&gt;<br />
&gt; On Wed, May 2, 2012 at 11:36 AM, Ferenc Kovacs &lt;tyra3l@gmail.com&gt; wrote:<br />
&gt;<br />
&gt; &gt; $foo=null;<br />
&gt; &gt; var_dump(isset($foo)); //prints bool(false)<br />
&gt;<br />
&gt; No offset meant, but it is totally expected and well known, and as far<br />
&gt; as I remember documented too. Assigning NULL to a variable unsets it<br />
&gt; (so to say).<br />
&gt;<br />
&gt;<br />
sure, as I quoted the documentation here.<br />
I just wanted to emphasize, that isset not only checks if a variable is set<br />
or not, but also checks the value of the variable, which makes your<br />
argument (&quot;An expression is not set per se. isset goals, by design, from<br />
the very1st day, is to test the existence of a variable and a variable<br />
only.&quot;) much weaker.<br />
<br />
<br />
<br />
&gt; &gt;&gt; empty() on the other hand, tests if something is empty, and only if it<br />
&gt; &gt;&gt; is empty. The result of an expression can be empty.<br />
&gt; &gt;&gt;<br />
&gt; &gt;<br />
&gt; &gt; an expression can also have a value of null.<br />
&gt;<br />
&gt; And NULL is empty. No issue here.<br />
&gt;<br />
<br />
yeah, but that wasn't my point, I was saying that an expression can also<br />
have a value of null, which can be checked by isset, so empty and isset<br />
isn't any different in that regard for expressions.<br />
<br />
-- <br />
Ferenc Kovács<br />
@Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a>]]></description>
            <dc:creator>Ferenc Kovacs</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 13:40:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488963#msg-488963</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488963#msg-488963</link>
            <description><![CDATA[ Pierre,<br />
<br />
On Wed, May 2, 2012 at 5:43 AM, Pierre Joye &lt;pierre.php@gmail.com&gt; wrote:<br />
&gt; hi,<br />
&gt;<br />
&gt; On Wed, May 2, 2012 at 11:36 AM, Ferenc Kovacs &lt;tyra3l@gmail.com&gt; wrote:<br />
&gt;<br />
&gt;&gt; $foo=null;<br />
&gt;&gt; var_dump(isset($foo)); //prints bool(false)<br />
&gt;<br />
&gt; No offset meant, but it is totally expected and well known, and as far<br />
&gt; as I remember documented too. Assigning NULL to a variable unsets it<br />
&gt; (so to say).<br />
<br />
Well, except that it doesn't unset it.  It only fails isset().  The<br />
symbol still exists in the symbol table, and the zval is still<br />
allocated.  That's one reason that isset() can return false, and<br />
array_key_exists() will return true.  But right now there's no way to<br />
check if a symbol exists since isset returns falls for a null value in<br />
a symbol (and there's no other way to check it)...<br />
<br />
Not saying it should change, just that it's a corner case that's not<br />
accounted for in the API...<br />
<br />
I voted for the ability to use an expression for isset() as well,<br />
since I agree with Ferenc, it's a matter of consistency.  Sure, the<br />
use-case for isset() is definitely weaker than for empty(), but at the<br />
same token they are definitely related...<br />
<br />
Anthony<br />
<br />
&gt;&gt;&gt; empty() on the other hand, tests if something is empty, and only if it<br />
&gt;&gt;&gt; is empty. The result of an expression can be empty.<br />
&gt;&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt; an expression can also have a value of null.<br />
&gt;<br />
&gt; And NULL is empty. No issue here.<br />
&gt;<br />
&gt; Cheers,<br />
&gt; --<br />
&gt; Pierre<br />
&gt;<br />
&gt; @pierrejoye | <a href="http://blog.thepimp.net" target="_blank"  rel="nofollow">http://blog.thepimp.net</a> | <a href="http://www.libgd.org" target="_blank"  rel="nofollow">http://www.libgd.org</a><br />
&gt;<br />
&gt; --<br />
&gt; PHP Internals - PHP Runtime Development Mailing List<br />
&gt; To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a><br />
&gt;<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Anthony Ferrara</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 13:40:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488902#msg-488902</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488902#msg-488902</link>
            <description><![CDATA[ On Wed, May 2, 2012 at 11:43 AM, Pierre Joye &lt;pierre.php@gmail.com&gt; wrote:<br />
&gt; hi,<br />
&gt;<br />
&gt; On Wed, May 2, 2012 at 11:36 AM, Ferenc Kovacs &lt;tyra3l@gmail.com&gt; wrote:<br />
&gt;<br />
&gt;&gt; $foo=null;<br />
&gt;&gt; var_dump(isset($foo)); //prints bool(false)<br />
&gt;<br />
&gt; No offset meant,<br />
<br />
lapsus :) s,offset,offense,<br />
<br />
<br />
<br />
-- <br />
Pierre<br />
<br />
@pierrejoye | <a href="http://blog.thepimp.net" target="_blank"  rel="nofollow">http://blog.thepimp.net</a> | <a href="http://www.libgd.org" target="_blank"  rel="nofollow">http://www.libgd.org</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Pierre Joye</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 11:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488901#msg-488901</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488901#msg-488901</link>
            <description><![CDATA[ hi,<br />
<br />
On Wed, May 2, 2012 at 11:36 AM, Ferenc Kovacs &lt;tyra3l@gmail.com&gt; wrote:<br />
<br />
&gt; $foo=null;<br />
&gt; var_dump(isset($foo)); //prints bool(false)<br />
<br />
No offset meant, but it is totally expected and well known, and as far<br />
as I remember documented too. Assigning NULL to a variable unsets it<br />
(so to say).<br />
<br />
&gt;&gt; empty() on the other hand, tests if something is empty, and only if it<br />
&gt;&gt; is empty. The result of an expression can be empty.<br />
&gt;&gt;<br />
&gt;<br />
&gt; an expression can also have a value of null.<br />
<br />
And NULL is empty. No issue here.<br />
<br />
Cheers,<br />
-- <br />
Pierre<br />
<br />
@pierrejoye | <a href="http://blog.thepimp.net" target="_blank"  rel="nofollow">http://blog.thepimp.net</a> | <a href="http://www.libgd.org" target="_blank"  rel="nofollow">http://www.libgd.org</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Pierre Joye</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 11:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488897#msg-488897</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488897#msg-488897</link>
            <description><![CDATA[ On Wed, May 2, 2012 at 11:10 AM, Pierre Joye &lt;pierre.php@gmail.com&gt; wrote:<br />
<br />
&gt; hi,<br />
&gt;<br />
&gt; On Wed, May 2, 2012 at 10:46 AM, Laruence &lt;laruence@php.net&gt; wrote:<br />
&gt;<br />
&gt; &gt;    so I think if you want to change empty, you should also change isset..<br />
&gt;<br />
&gt; An expression is not set per se. isset goals, by design, from the very<br />
&gt; 1st day, is to test the existence of a variable and a variable only.<br />
&gt;<br />
<br />
&quot;Returns TRUE if var exists and has value other than NULL, FALSE otherwise.&quot;<br />
<br />
$foo=null;<br />
var_dump(isset($foo)); //prints bool(false)<br />
<br />
<br />
&gt;<br />
&gt; empty() on the other hand, tests if something is empty, and only if it<br />
&gt; is empty. The result of an expression can be empty.<br />
&gt;<br />
&gt;<br />
an expression can also have a value of null.<br />
<br />
-- <br />
Ferenc Kovács<br />
@Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a>]]></description>
            <dc:creator>Ferenc Kovacs</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 11:43:21 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488887#msg-488887</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488887#msg-488887</link>
            <description><![CDATA[ hi,<br />
<br />
On Wed, May 2, 2012 at 10:46 AM, Laruence &lt;laruence@php.net&gt; wrote:<br />
<br />
&gt;    so I think if you want to change empty, you should also change isset.<br />
<br />
An expression is not set per se. isset goals, by design, from the very<br />
1st day, is to test the existence of a variable and a variable only.<br />
<br />
empty() on the other hand, tests if something is empty, and only if it<br />
is empty. The result of an expression can be empty.<br />
<br />
Cheers,<br />
-- <br />
Pierre<br />
<br />
@pierrejoye | <a href="http://blog.thepimp.net" target="_blank"  rel="nofollow">http://blog.thepimp.net</a> | <a href="http://www.libgd.org" target="_blank"  rel="nofollow">http://www.libgd.org</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Pierre Joye</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 11:20:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488872#msg-488872</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488872#msg-488872</link>
            <description><![CDATA[ On Mon, Apr 30, 2012 at 3:50 PM, Patrick ALLAERT &lt;patrickallaert@php.net&gt; wrote:<br />
&gt; Hi,<br />
&gt;<br />
&gt; 2012/4/12 Nikita Popov &lt;nikita.ppv@googlemail.com&gt;:<br />
&gt;&gt; PS: I added isset() too, to address the consistency concerns mentioned on IRC.<br />
&gt;<br />
&gt; I would have voted +1 if it didn't contain the isset() change. None of<br />
&gt; the examples used in the isset_with_expr.phpt test seems logic to me.<br />
Hi:<br />
     isset and empty are generally think as a pair,  and the both even<br />
share one ZEND_OP: ZEND_ISSET_ISEMPTY_VAR<br />
<br />
    so I think if you want to change empty, you should also change isset.<br />
<br />
thanks<br />
&gt;<br />
&gt; Care to explain the consistency concerns here?<br />
&gt;<br />
&gt; Patrick<br />
&gt;<br />
&gt; --<br />
&gt; PHP Internals - PHP Runtime Development Mailing List<br />
&gt; To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a><br />
&gt;<br />
<br />
<br />
<br />
-- <br />
Laruence  Xinchen Hui<br />
<a href="http://www.laruence.com/" target="_blank"  rel="nofollow">http://www.laruence.com/</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Laruence</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 10:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488729#msg-488729</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488729#msg-488729</link>
            <description><![CDATA[ Sent from my iPhone<br />
<br />
在 2012-5-2，3:52，Ferenc Kovacs &lt;tyra3l@gmail.com&gt; 写道：<br />
<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt;&gt; So isset(UNDEFINEDCONSTANT) will be isset(&quot;UNDEFINEDCONSTANT&quot;) which<br />
&gt;&gt; will/should<br />
&gt;&gt; 1) yield a notice, which is unnexpected for isset<br />
&gt;&gt; 2) return true, which is also unexpected.<br />
&gt;&gt;<br />
&gt;&gt; I don't see much point in that.<br />
&gt;&gt;<br />
&gt;&gt;<br />
&gt; yep, and if we allow expressions then it is the expected behavior, but you<br />
&gt; are right that this is will change the current standard that isset/empty<br />
&gt; can't raise a notice.<br />
&gt; but this isn't specific to isset, empty will also follow the same pattern..<br />
&gt;<br />
This is really a issue .<br />
<br />
Thanks<br />
&gt; --<br />
&gt; Ferenc Kovács<br />
&gt; @Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Xinchen Hui</dc:creator>
            <category>php-internals</category>
            <pubDate>Wed, 02 May 2012 03:40:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488631#msg-488631</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488631#msg-488631</link>
            <description><![CDATA[ &gt;<br />
&gt;<br />
&gt; So isset(UNDEFINEDCONSTANT) will be isset(&quot;UNDEFINEDCONSTANT&quot;) which<br />
&gt; will/should<br />
&gt; 1) yield a notice, which is unnexpected for isset<br />
&gt; 2) return true, which is also unexpected.<br />
&gt;<br />
&gt; I don't see much point in that.<br />
&gt;<br />
&gt;<br />
yep, and if we allow expressions then it is the expected behavior, but you<br />
are right that this is will change the current standard that isset/empty<br />
can't raise a notice.<br />
but this isn't specific to isset, empty will also follow the same pattern.<br />
<br />
-- <br />
Ferenc Kovács<br />
@Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a>]]></description>
            <dc:creator>Ferenc Kovacs</dc:creator>
            <category>php-internals</category>
            <pubDate>Tue, 01 May 2012 22:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488595#msg-488595</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488595#msg-488595</link>
            <description><![CDATA[ On Tue, May 1, 2012 at 7:24 PM, Patrick ALLAERT &lt;patrickallaert@php.net&gt;wrote:<br />
<br />
&gt; 2012/5/1 Ferenc Kovacs &lt;tyra3l@gmail.com&gt;:<br />
&gt; &gt; On Mon, Apr 30, 2012 at 2:39 PM, Nikita Popov &lt;nikita.ppv@googlemail.com<br />
&gt; &gt;wrote:<br />
&gt; &gt; - both isset and empty are language constructs, which many people use<br />
&gt; &gt; almost interchangeability, changing one of them in a way that the same<br />
&gt; &gt; expression works with one of them, but blows up with a parse error seems<br />
&gt; &gt; wrong to me.<br />
&gt;<br />
&gt; I wish that more wrong usages could blow up with parse errors way<br />
&gt; before waiting for the incorrect line to be run.<br />
&gt;<br />
<br />
One could argue that then you should pick a compiled language.<br />
<br />
<br />
&gt; While there is some valid use cases for empty() I see none for<br />
&gt; isset(), it must remain a targeted and specific construct IMHO.<br />
&gt;<br />
<br />
I agree that there is less valid use-cases, but I feel that keeping the two<br />
method consistent about this is more important.<br />
<br />
<br />
&gt;<br />
&gt; &gt; - maybe you think that isset doesn't really make sense with expressions,<br />
&gt;<br />
&gt; exact :)<br />
&gt;<br />
&gt; &gt; but don't forget that this patch would also allow constants to be used<br />
&gt; with<br />
&gt; &gt; empty/isset.<br />
&gt;<br />
&gt; That is not a very good think IMO.<br />
&gt;<br />
&gt; For the same reason: this patch would also allow writing: empty( false<br />
&gt; ) or empty( null ) which are both clueless.<br />
&gt;<br />
<br />
how is that different than for example writing is_null(null) ?<br />
<br />
<br />
&gt; The fact that this patch would now allow syntactically doubtful things<br />
&gt; doesn't mean they should be encouraged nor propagated to isset().<br />
&gt;<br />
<br />
we are already have that all over the place, I don't think that this<br />
particular patch will change anything about that.<br />
could you elaborate on this part a little bit?<br />
I mean you can write &quot;stupid&quot; code right now ($null=null;isset($null);<br />
instead of isset(null);), I can't see how would this patch worsen the<br />
situation. If anything, the silly code could be understood easier, as you<br />
wouldn't need to debug the value of the $null variable passed in.<br />
So I think that<br />
1, we already too late to prevent that kind of code<br />
2. even if we could, I don't think that the currently discussed patch would<br />
really encourage that kind of code<br />
3, there are/could be valid use-cases for isset<br />
4, isset and empty should work the same way in regards of the argument<br />
parsing.<br />
<br />
ofc. this is only my opinion, if I am the minority here, then it is fine<br />
too, I just wanted to explain what was the reasoning behind that discussion..<br />
<br />
-- <br />
Ferenc Kovács<br />
@Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a>]]></description>
            <dc:creator>Ferenc Kovacs</dc:creator>
            <category>php-internals</category>
            <pubDate>Tue, 01 May 2012 20:40:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488551#msg-488551</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488551#msg-488551</link>
            <description><![CDATA[ 2012/5/1 Ferenc Kovacs &lt;tyra3l@gmail.com&gt;:<br />
&gt; On Mon, Apr 30, 2012 at 2:39 PM, Nikita Popov &lt;nikita.ppv@googlemail.com&gt;wrote:<br />
&gt; - both isset and empty are language constructs, which many people use<br />
&gt; almost interchangeability, changing one of them in a way that the same<br />
&gt; expression works with one of them, but blows up with a parse error seems<br />
&gt; wrong to me.<br />
<br />
I wish that more wrong usages could blow up with parse errors way<br />
before waiting for the incorrect line to be run.<br />
While there is some valid use cases for empty() I see none for<br />
isset(), it must remain a targeted and specific construct IMHO.<br />
<br />
&gt; - maybe you think that isset doesn't really make sense with expressions,<br />
<br />
exact :)<br />
<br />
&gt; but don't forget that this patch would also allow constants to be used with<br />
&gt; empty/isset.<br />
<br />
That is not a very good think IMO.<br />
<br />
For the same reason: this patch would also allow writing: empty( false<br />
) or empty( null ) which are both clueless.<br />
The fact that this patch would now allow syntactically doubtful things<br />
doesn't mean they should be encouraged nor propagated to isset().<br />
<br />
Cheers,<br />
Patrick<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Patrick ALLAERT</dc:creator>
            <category>php-internals</category>
            <pubDate>Tue, 01 May 2012 19:30:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488540#msg-488540</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488540#msg-488540</link>
            <description><![CDATA[ Hi,<br />
<br />
On Tue, May 1, 2012 at 18:43, Ferenc Kovacs &lt;tyra3l@gmail.com&gt; wrote:<br />
&gt;<br />
&gt; albeit I'm not laruence, but I also supported the idea to keep consistency<br />
&gt; across the allowed params of empty and isset.<br />
&gt; here is my reasoning:<br />
&gt; - both isset and empty are language constructs, which many people use<br />
&gt; almost interchangeability, changing one of them in a way that the same<br />
&gt; expression works with one of them, but blows up with a parse error seems<br />
&gt; wrong to me.<br />
&gt; - maybe you think that isset doesn't really make sense with expressions,<br />
&gt; but don't forget that this patch would also allow constants to be used with<br />
&gt; empty/isset, and imo isset(some_constant); would be useful and maybe more<br />
&gt; straightforward for the people new to the language.<br />
<br />
<br />
So isset(UNDEFINEDCONSTANT) will be isset(&quot;UNDEFINEDCONSTANT&quot;) which will/should<br />
1) yield a notice, which is unnexpected for isset<br />
2) return true, which is also unexpected.<br />
<br />
I don't see much point in that.<br />
<br />
Best regards,<br />
<br />
-- <br />
Etienne Kneuss<br />
<a href="http://www.colder.ch" target="_blank"  rel="nofollow">http://www.colder.ch</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Etienne Kneuss</dc:creator>
            <category>php-internals</category>
            <pubDate>Tue, 01 May 2012 19:00:57 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488536#msg-488536</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488536#msg-488536</link>
            <description><![CDATA[ On Mon, Apr 30, 2012 at 2:39 PM, Nikita Popov &lt;nikita.ppv@googlemail.com&gt;wrote:<br />
<br />
&gt; On Mon, Apr 30, 2012 at 9:50 AM, Patrick ALLAERT &lt;patrickallaert@php.net&gt;<br />
&gt; wrote:<br />
&gt; &gt; Hi,<br />
&gt; &gt;<br />
&gt; &gt; 2012/4/12 Nikita Popov &lt;nikita.ppv@googlemail.com&gt;:<br />
&gt; &gt;&gt; PS: I added isset() too, to address the consistency concerns mentioned<br />
&gt; on IRC.<br />
&gt; &gt;<br />
&gt; &gt; I would have voted +1 if it didn't contain the isset() change. None of<br />
&gt; &gt; the examples used in the isset_with_expr.phpt test seems logic to me.<br />
&gt; &gt;<br />
&gt; &gt; Care to explain the consistency concerns here?<br />
&gt; The concerns came from laruence, so maybe he could drop a comment here<br />
&gt; :) Basically, empty() and isset() are very similar in their nature, so<br />
&gt; changing only one of them might seem inconsistent.<br />
&gt;<br />
&gt; Personally I don't see much use in allowing expressions in isset().<br />
&gt; People being confused by empty(trim($_GET['foo'])) not working is<br />
&gt; quite common, but I've never heard of somebody trying to use isset()<br />
&gt; on a function call. The name already makes clear that it's intended<br />
&gt; for use on variables.<br />
<br />
<br />
albeit I'm not laruence, but I also supported the idea to keep consistency<br />
across the allowed params of empty and isset.<br />
here is my reasoning:<br />
- both isset and empty are language constructs, which many people use<br />
almost interchangeability, changing one of them in a way that the same<br />
expression works with one of them, but blows up with a parse error seems<br />
wrong to me.<br />
- maybe you think that isset doesn't really make sense with expressions,<br />
but don't forget that this patch would also allow constants to be used with<br />
empty/isset, and imo isset(some_constant); would be useful and maybe more<br />
straightforward for the people new to the language.<br />
<br />
-- <br />
Ferenc Kovács<br />
@Tyr43l - <a href="http://tyrael.hu" target="_blank"  rel="nofollow">http://tyrael.hu</a>]]></description>
            <dc:creator>Ferenc Kovacs</dc:creator>
            <category>php-internals</category>
            <pubDate>Tue, 01 May 2012 18:50:05 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,488097#msg-488097</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,488097#msg-488097</link>
            <description><![CDATA[ hi,<br />
<br />
On Mon, Apr 30, 2012 at 3:05 PM, Nikita Popov &lt;nikita.ppv@googlemail.com&gt; wrote:<br />
<br />
&gt; I changed the vote to have three options: &quot;Both empty() and isset()&quot;,<br />
&gt; &quot;Only empty()&quot; or &quot;None&quot;<br />
&gt;<br />
&gt; <a href="https://wiki.php.net/rfc/empty_isset_exprs#vote" target="_blank"  rel="nofollow">https://wiki.php.net/rfc/empty_isset_exprs#vote</a><br />
<br />
Please post a top thread to notice everyone about this new vote with a<br />
short explanation.<br />
<br />
Yes, I told you that on IRC a good dozen times since you sent this<br />
mail here, but there are good reasons why we do so. For one, many do<br />
not follow any single thread on internals and I would not have noticed<br />
that mail if I was not on IRC today. So please do it, or the votes<br />
result, no matter the outcome, cannot be accepted.<br />
<br />
Thanks for your understanding,<br />
-- <br />
Pierre<br />
<br />
@pierrejoye | <a href="http://blog.thepimp.net" target="_blank"  rel="nofollow">http://blog.thepimp.net</a> | <a href="http://www.libgd.org" target="_blank"  rel="nofollow">http://www.libgd.org</a><br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Pierre Joye</dc:creator>
            <category>php-internals</category>
            <pubDate>Mon, 30 Apr 2012 22:30:03 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,487947#msg-487947</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,487947#msg-487947</link>
            <description><![CDATA[ On Mon, Apr 30, 2012 at 9:50 AM, Patrick ALLAERT &lt;patrickallaert@php.net&gt; wrote:<br />
&gt; Hi,<br />
&gt;<br />
&gt; 2012/4/12 Nikita Popov &lt;nikita.ppv@googlemail.com&gt;:<br />
&gt;&gt; PS: I added isset() too, to address the consistency concerns mentioned on IRC.<br />
&gt;<br />
&gt; I would have voted +1 if it didn't contain the isset() change. None of<br />
&gt; the examples used in the isset_with_expr.phpt test seems logic to me.<br />
&gt;<br />
&gt; Care to explain the consistency concerns here?<br />
&gt;<br />
&gt; Patrick<br />
<br />
I changed the vote to have three options: &quot;Both empty() and isset()&quot;,<br />
&quot;Only empty()&quot; or &quot;None&quot;<br />
<br />
<a href="https://wiki.php.net/rfc/empty_isset_exprs#vote" target="_blank"  rel="nofollow">https://wiki.php.net/rfc/empty_isset_exprs#vote</a><br />
<br />
Nikita<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Nikita Popov</dc:creator>
            <category>php-internals</category>
            <pubDate>Mon, 30 Apr 2012 15:10:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,487941#msg-487941</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,487941#msg-487941</link>
            <description><![CDATA[ On Mon, Apr 30, 2012 at 9:50 AM, Patrick ALLAERT &lt;patrickallaert@php.net&gt; wrote:<br />
&gt; Hi,<br />
&gt;<br />
&gt; 2012/4/12 Nikita Popov &lt;nikita.ppv@googlemail.com&gt;:<br />
&gt;&gt; PS: I added isset() too, to address the consistency concerns mentioned on IRC.<br />
&gt;<br />
&gt; I would have voted +1 if it didn't contain the isset() change. None of<br />
&gt; the examples used in the isset_with_expr.phpt test seems logic to me.<br />
&gt;<br />
&gt; Care to explain the consistency concerns here?<br />
The concerns came from laruence, so maybe he could drop a comment here<br />
:) Basically, empty() and isset() are very similar in their nature, so<br />
changing only one of them might seem inconsistent.<br />
<br />
Personally I don't see much use in allowing expressions in isset().<br />
People being confused by empty(trim($_GET['foo'])) not working is<br />
quite common, but I've never heard of somebody trying to use isset()<br />
on a function call. The name already makes clear that it's intended<br />
for use on variables.<br />
<br />
So, I'm not quite sure what I'm supposed to do about this. Should I<br />
add two vote options, one for empty() only, one for both?<br />
<br />
Nikita<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Nikita Popov</dc:creator>
            <category>php-internals</category>
            <pubDate>Mon, 30 Apr 2012 14:50:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,487842#msg-487842</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,487842#msg-487842</link>
            <description><![CDATA[ Hi,<br />
<br />
2012/4/12 Nikita Popov &lt;nikita.ppv@googlemail.com&gt;:<br />
&gt; PS: I added isset() too, to address the consistency concerns mentioned on IRC.<br />
<br />
I would have voted +1 if it didn't contain the isset() change. None of<br />
the examples used in the isset_with_expr.phpt test seems logic to me.<br />
<br />
Care to explain the consistency concerns here?<br />
<br />
Patrick<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Patrick ALLAERT</dc:creator>
            <category>php-internals</category>
            <pubDate>Mon, 30 Apr 2012 10:00:02 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,478787#msg-478787</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,478787#msg-478787</link>
            <description><![CDATA[ On Fri, Apr 13, 2012 at 12:42 AM, Galen Wright-Watson<br />
&lt;ww.galen@gmail.com&gt; wrote:<br />
&gt; Just to be clear, under the new behavior, calling &quot;empty&quot; or &quot;isset&quot; on<br />
&gt; undefined variables and undefined array indices shouldn't produce a notice<br />
&gt; when E_NOTICE is set, correct? Basically, the change isn't regressive.<br />
Yup, that's right. So the change is BC-safe :)<br />
<br />
&gt; If this is so, how about adding appropriate regression<br />
&gt; tests to empty_with_expr.phpt and empty_with_isset.phpt?<br />
The normal empty()/isset() behavior (including the suppression of the<br />
notice) is tested in a few other tests, that's why I didn't add<br />
additional tests for it there :)<br />
<br />
Nikita<br />
<br />
-- <br />
PHP Internals - PHP Runtime Development Mailing List<br />
To unsubscribe, visit: <a href="http://www.php.net/unsub.php" target="_blank"  rel="nofollow">http://www.php.net/unsub.php</a>]]></description>
            <dc:creator>Nikita Popov</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 13 Apr 2012 14:20:01 +0200</pubDate>
        </item>
        <item>
            <guid>http://www.serverphorums.com/read.php?7,478374,478433#msg-478433</guid>
            <title>Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()</title>
            <link>http://www.serverphorums.com/read.php?7,478374,478433#msg-478433</link>
            <description><![CDATA[ On Thu, Apr 12, 2012 at 2:42 PM, Nikita Popov &lt;nikita.ppv@googlemail.com&gt;wrote:<br />
<br />
&gt;<br />
&gt; As per the comments I created an RFC, proposing to allow arbitrary<br />
&gt; expressions to be passed to empty() and isset():<br />
&gt;<br />
&gt; <a href="https://wiki.php.net/rfc/empty_isset_exprs" target="_blank"  rel="nofollow">https://wiki.php.net/rfc/empty_isset_exprs</a><br />
&gt;<br />
&gt; The patch is available as a PR:<br />
&gt;<br />
&gt; <a href="https://github.com/php/php-src/pull/54" target="_blank"  rel="nofollow">https://github.com/php/php-src/pull/54</a><br />
&gt;<br />
&gt; Nikita<br />
&gt;<br />
&gt; PS: I added isset() too, to address the consistency concerns mentioned on<br />
&gt; IRC.<br />
&gt;<br />
&gt; Just to be clear, under the new behavior, calling &quot;empty&quot; or &quot;isset&quot; on<br />
undefined variables and undefined array indices shouldn't produce a notice<br />
when E_NOTICE is set, correct? Basically, the change isn't regressive.<br />
<br />
    &lt;?php<br />
    error_reporting(E_ALL);<br />
    echo empty($foo) ? &quot;\$foo isn't set\n&quot; : &quot;foo: $foo\n&quot;;<br />
    # result: &quot;$foo isn't set&quot;, and no &quot;Undefined variable&quot; notice.<br />
<br />
From my reading of the patch this is true, but I want to make sure I'm not<br />
missing something. If this is so, how about adding appropriate regression<br />
tests to empty_with_expr.phpt and empty_with_isset.phpt?]]></description>
            <dc:creator>Galen Wright-Watson</dc:creator>
            <category>php-internals</category>
            <pubDate>Fri, 13 Apr 2012 00:50:01 +0200</pubDate>
        </item>
    </channel>
</rss>
