Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60450 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42246 invoked from network); 4 May 2012 20:27:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 May 2012 20:27:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.45 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.210.45 mail-pz0-f45.google.com Received: from [209.85.210.45] ([209.85.210.45:49545] helo=mail-pz0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/04-18322-E9B34AF4 for ; Fri, 04 May 2012 16:27:10 -0400 Received: by dadv2 with SMTP id v2so3785557dad.32 for ; Fri, 04 May 2012 13:27:07 -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=TvQXHVqT8UhR8Y8uSWWaYtkGMEIB1eNjIRepD9dPiOY=; b=kcTWTPOSOVK85BhzfB0dsi+4lRhgfSIpfbAH862irqqSRY6IXnqlVeUmEk+oMYwOTb ViQhq/fAiqD1GhYZK/1XO0KiA8vZ5TjIjzcEpVE1N5pm3JqjPZIEBHLpyq7Lr7hV5TUI bJRp0JBPf8xQsavEisu6wr8vxbeih/6mMXDRxnTGujiUfKwSf+lHQtBv3vYqqBF780DA y/8YwDKnRafL3lZGuUMzg6OlJMCHDjCgEL5PTOvWQ2dTXQSOtJ48cNB2hYeTeEZFigUr Vpc/t6PXNMqu2wWDoiAT2z3h/j2RxaVqVVGDGAwh4jeRxAhURt/S9k/BFG0qidqxfjh7 yaMg== MIME-Version: 1.0 Received: by 10.68.134.232 with SMTP id pn8mr21970041pbb.106.1336163227328; Fri, 04 May 2012 13:27:07 -0700 (PDT) Received: by 10.68.229.197 with HTTP; Fri, 4 May 2012 13:27:07 -0700 (PDT) In-Reply-To: References: <396c1a02d4e7195f2b89e26ace2276a6.squirrel@www.l-i-e.com> Date: Fri, 4 May 2012 22:27:07 +0200 Message-ID: To: Kris Craig Cc: Richard Lynch , PHP internals Content-Type: multipart/alternative; boundary=047d7b10c86186e1ef04bf3bbebb Subject: Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset() From: tyra3l@gmail.com (Ferenc Kovacs) --047d7b10c86186e1ef04bf3bbebb Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > > 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? yeah, this wouldn't be much to think about if isset in php wouldn't handle null values as not set. and as I mentioned expressions can return null, so it isn't true that any expression given to isset would always result in true. but I think we were talked this over already, so not much point repeating the same arguments over and over again. to summarize, the following cons were brought up against allowing expressions for isset : - if you pass an undefined constant to isset, you will get unexpected result as isset will raise a notice and can return unexpected result as = the constant is casted to string before being passed to isset(btw. this is h= ow expressions work everywhere else, so it isn't a real surprise, but it is= a change to the current behavior). - this is a valid concern, but the same problem applies to empty too, so it is a general problem with the current patch/rfc. I think it would be nice mentioning this in the rfc, as this could/will cause a few wtf moments for some people. - isset(CONST) could be seen as defined("CONST") but they are returning different results if CONS is defined with NULL or undefined. - this is a valid concern, and there is no good solution, for isset(CONST) we either go cosistent with isset or declared, but can't= do both at the same time. - semantically empty can make sense for expressions, isset doesn't: - yep, the only thing that makes this a little less clear/obvious is the fact that isset in php also checks for value, not only the "existence" of the variable. - following the previous point, there are much more fluent use-cases for empty(expression) than for isset(expression) - this is true, for null check you should use comparing the value, for other cases empty could be much more useful, only the isset(CONST= ) could be useful, but I mentioned the problems with that above. after discussing this and thinking it over a few times, I decided that I will drop my case about supporting both empty and isset. I think that keeping the argument handling for isset and empty in sync doesn't worth the possible gotchas. and I now a little less sure about suporting this change for empty(), given how much do we emphasized over the years that empty won't trigger any warning about the non-existent variables. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --047d7b10c86186e1ef04bf3bbebb--