Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51832 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83269 invoked from network); 8 Apr 2011 02:49:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Apr 2011 02:49:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=mail_ben_schmidt@yahoo.com.au; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=mail_ben_schmidt@yahoo.com.au; sender-id=unknown; domainkeys=good Received-SPF: error (pb1.pair.com: domain yahoo.com.au from 98.138.91.137 cause and error) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: mail_ben_schmidt@yahoo.com.au X-Host-Fingerprint: 98.138.91.137 nm7-vm3.bullet.mail.ne1.yahoo.com Received: from [98.138.91.137] ([98.138.91.137:39428] helo=nm7-vm3.bullet.mail.ne1.yahoo.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2A/E0-04528-FA77E9D4 for ; Thu, 07 Apr 2011 22:49:20 -0400 Received: from [98.138.90.54] by nm7.bullet.mail.ne1.yahoo.com with NNFMP; 08 Apr 2011 02:49:16 -0000 Received: from [98.138.87.12] by tm7.bullet.mail.ne1.yahoo.com with NNFMP; 08 Apr 2011 02:49:16 -0000 Received: from [127.0.0.1] by omp1012.mail.ne1.yahoo.com with NNFMP; 08 Apr 2011 02:49:16 -0000 X-Yahoo-Newman-Id: 831146.40730.bm@omp1012.mail.ne1.yahoo.com Received: (qmail 36133 invoked from network); 8 Apr 2011 02:49:16 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.au; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=dcIB04kFEVVGVsEfKgh48Y3mqwZJ6z6HeB91oBHvOIrM+13f83l2vxuhoWFPN2UnzgYHFIKPdUITqJBfsTvu4fY0MdF6rDJ749D3t9i0maeQucKbyOQ9DEC5GgEVbQ6knTo7c+p5AHqUTGi5lOrVDthktKkFQ0/wwdUfoIqrsDY= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com.au; s=s1024; t=1302230956; bh=4+sJ0pUqsM8x3F+/tMb74xJUVEmkYfWy1r5DOhsXo7w=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=wcQg5SYZdI8pj1yLM/FHzy/fSVYzL46qYR8in3jGPv1Ga6ovuETpMRypvLlooPW/r/1xvd92UzlXEsVut3AEk8KWRY7NSXu9mmXDmqeQ2QgFFw6QjnntMMWZ8KN8pspNqMkQtE4Aip+BgZibpuqYp/osVwMMn1P2lnC88Hn8Hnw= Received: from 194.20.70.115.static.exetel.com.au (mail_ben_schmidt@115.70.20.194 with plain) by smtp129.mail.mud.yahoo.com with SMTP; 07 Apr 2011 19:49:13 -0700 PDT X-Yahoo-SMTP: enFMnPSswBAexaHyzgobwuUTrYOhZdJ0KRA2SjA- X-YMail-OSG: wk7G6vkVM1mm9tPxZJC5ycc3Z8hG5HmZUEk71xICfNr9XjX kR667x8g4SpW8UQYaQ6kuHUYW5v7_NSm8kpz_2Pr82OIIvlzZfHpbO1hO8rH Ui9FvjidoYigyoWzK3vx1EARo667f6d4fKVEpUOnWtejVyL_nikt5CmJstIc y5pMORlR2Najo5k54jP1rYqEGFLUbiewc549SZ0vQxyqecQ_9A3V4MvyL7ob 1CxZD_tGoByb5H0ymu4B9SrLA1NKIWKC9k_pweN4WoX0mkDNK3AZj6dKZsff bas9lsLexl2ZkYWKiyUOefgsthuDIraGNXJVpubHrt2ADPASkmvOKxjJCq9R DIYv3Wq4Uu0I1CzFKP6TQK0swIA-- X-Yahoo-Newman-Property: ymail-3 Message-ID: <4D9E77A5.5040309@yahoo.com.au> Date: Fri, 08 Apr 2011 12:49:09 +1000 User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-GB; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 ThunderBrowse/3.3.5 MIME-Version: 1.0 To: Rasmus Lerdorf CC: Rafael Dohms , internals References: <4D950434.3060704@yahoo.com.au> <4D9E0543.1080600@lerdorf.com> In-Reply-To: <4D9E0543.1080600@lerdorf.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Implicit isset/isempty check on short-ternary operator From: mail_ben_schmidt@yahoo.com.au (Ben Schmidt) On 8/04/11 4:41 AM, Rasmus Lerdorf wrote: > On 4/7/11 2:30 PM, Rafael Dohms wrote: >> On Thu, Mar 31, 2011 at 7:46 PM, Ben Schmidt >> wrote: >>> On 1/04/11 3:29 AM, David Coallier wrote: >>>> >>>> Hey there, >>>> >>>> I've been working on a little patch that will allow variables ($1) in >>>> a short-ternary operation to go through an implicit isset >>>> (zend_do_isset_or_isempty) check so that the average use-case for the >>>> short-ternary operator doesn't yield in a notice whenever the first >>>> variable of the expression isn't set. >>>> >>>> So the use-case I'm considering is the following: >>>> >>>> >>> $list = array('name' => 'list'); >>>> >>>> echo $list['name'] ?: 'List not set.' . PHP_EOL; >>>> echo $list['name-notset'] ?: 'List not set.' . PHP_EOL; >>>> ?> >>>> >>>> This example, which we all know, will result in a notice for the >>>> second echo statement because the requested array-key doesn't actually >>>> exist in the array. >>> >>> I'm not familiar with the construct, but to be honest, I fail to see how >>> it is useful without the suppression of the notice. I mean, it's a >>> shorthand for isset($var)?$var:$something_else isn't it? That >>> presupposes that $var may not be set, but that you've accounted for that >>> fact, so don't want a notice about it. Obviously the isset() can only be >>> applied if the 'left hand side' is an lval, but I think it makes sense >>> to apply it whenever it is an lval. >>> >>> So a big +1 from me. >>> >>> Ben. >>> >> >> Its also a +1 for me, it would make the ternary operator much more >> useful to me e remove lots of verbose code for handling arrays. > > Well, it would change the semantics. And Ben, no, it isn't shorthand for an > isset() it is like writing (boolean)$var?$var:$something Thanks for the clarification, Rasmus. That makes sense. I still think the patch would be very useful, though I can also see how an argument could be made for keeping the warning. In my opinion, the case for removing the warning is stronger than for keeping it. Ben.