Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60448 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33460 invoked from network); 4 May 2012 19:10:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2012 19:10:54 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:41412] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/62-18322-DB924AF4 for ; Fri, 04 May 2012 15:10:53 -0400 Received: by wgbfg15 with SMTP id fg15so2494191wgb.11 for ; Fri, 04 May 2012 12:10:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=5rHJhg4DGtFGOkfGOrfViQluecUU4KImkE3snn+LV1I=; b=0T9HUQhRF3+8z/3TRTu33A30Lrvh6E2qZAybWg173XOidB8QBH29JZXRbYo42thze4 0yhDm8rGXEFyDQ64CArRNlEy6IkwZI4EPfiCaEFF4zogbgfPYzS3Tlq++43WWi95wa7m GVjkuuYdluV9zI1CCUJ2oCNyxk0pQhEO7O7C13Q85sJcTdXVpUdl+627VBn++ZVE1Sed vl8mPNsBtxZKGiM9LkhvkGSHg3pJj8T5P+anh33qvzAQBknyEhs+OZ++CtEHdETuDR2d lVgojFEfoVySRVk68tUXPobuvddop4Y3/3I0x0LEHpd9H6CZzlqlL6G5LYUF0LdqIy7i JUmQ== MIME-Version: 1.0 Received: by 10.180.82.136 with SMTP id i8mr15402706wiy.19.1336158649207; Fri, 04 May 2012 12:10:49 -0700 (PDT) Received: by 10.223.96.129 with HTTP; Fri, 4 May 2012 12:10:49 -0700 (PDT) In-Reply-To: <396c1a02d4e7195f2b89e26ace2276a6.squirrel@www.l-i-e.com> References: <396c1a02d4e7195f2b89e26ace2276a6.squirrel@www.l-i-e.com> Date: Fri, 4 May 2012 12:10:49 -0700 Message-ID: To: Richard Lynch Cc: PHP internals Content-Type: multipart/alternative; boundary=f46d04428c9ca64d4204bf3aad90 Subject: Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset() From: kris.craig@gmail.com (Kris Craig) --f46d04428c9ca64d4204bf3aad90 Content-Type: text/plain; charset=ISO-8859-1 On Fri, May 4, 2012 at 11:48 AM, Richard Lynch wrote: > On Wed, May 2, 2012 4:43 am, Pierre Joye wrote: > >>> empty() on the other hand, tests if something is empty, and only if > >>> it > >>> is empty. The result of an expression can be empty. > >>> > >> > >> an expression can also have a value of null. > > > > And NULL is empty. No issue here. > > Expressions can also return "", 0, 0.0, "0", array() > > You really think those should all be empty? > Unless I'm missing something here, aren't all those things already considered to be empty?? Here's what the PHP man page for empty() says: The following things are considered to be empty: - *""* (an empty string) - *0* (0 as an integer) - *0.0* (0 as a float) - *"0"* (0 as a string) - *NULL* - *FALSE* - *array()* (an empty array) - *var $var;* (a variable declared, but without a value in a class) If that's the way it already behaves, then why would keeping it that way even be an issue? If an expression returns any of those things, it's empty. I've been following the debate and I'm still a bit unclear as to what the benefit would be to allowing non-variables in isset(). I mean, as was stated earlier, expressions are neither "set" nor "unset". Furthermore, if you were to assign a variable to any valid expression (empty or otherwise), it would be considered "set". Therefore, through simple deductive logic, would an expression passed to isset() not, by definition, *always* return TRUE if the expression itself is syntactically valid? The answer seems to be yes as far as I can tell. And if that is the case, then what value is there in allowing it if the return value is always the same no matter what? --Kris --f46d04428c9ca64d4204bf3aad90--