Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61395 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89337 invoked from network); 18 Jul 2012 14:20:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jul 2012 14:20:48 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:34274] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9C/39-39169-E36C6005 for ; Wed, 18 Jul 2012 10:20:47 -0400 Received: by qafi31 with SMTP id i31so3276853qaf.8 for ; Wed, 18 Jul 2012 07:20:43 -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=tLQ8k3qVtPSgO/km1fbohFiULIFCrgfcKLHDWLK4tA8=; b=ytxhwCpltlEVk4dBg/dUAOx5NuTCrv8UZsd5tNVHPL+plpoRGSq3t4Zh4pTUAW+D6c G52E63E68XUlvjFluNyscvtTpJapKAsjZBcGG6UelovLdxDLDvW26gL4+AjBUm1kXDt4 3AoThWXdCKYtMAjJTkvhCMMmrNeiyKCUPVicdAL9XVQciB7yHXveNVsDVQymzSXptukV nWJ/bsTX/3Kjqcc7MRKHnniOMH1xMAPktscPBdFslAXmF2IUDIUKK8hRrAB9Lg/Yinbw kSQP5Gwm8tFIIJXkAq/o+Q2tPhgobmGE12/HyJxavDCEKoBFr7omYQEcMVgxh71hdaDW O0FQ== MIME-Version: 1.0 Received: by 10.229.136.131 with SMTP id r3mr1485240qct.145.1342621243690; Wed, 18 Jul 2012 07:20:43 -0700 (PDT) Received: by 10.229.182.4 with HTTP; Wed, 18 Jul 2012 07:20:43 -0700 (PDT) In-Reply-To: References: Date: Wed, 18 Jul 2012 10:20:43 -0400 Message-ID: To: Rafael Dohms Cc: PHP internals Content-Type: multipart/alternative; boundary=00248c768f9e4c4f9304c51b5e76 Subject: Re: [PHP-DEV] Implicit isset in ternary operator From: ircmaxell@gmail.com (Anthony Ferrara) --00248c768f9e4c4f9304c51b5e76 Content-Type: text/plain; charset=ISO-8859-1 Rafael, One point of clarity: On Wed, Jul 18, 2012 at 10:15 AM, Rafael Dohms wrote: > Hey Everyone, > > With the syntax improvements for 5.4 and some of the de-referencing work, > code looks so much sleeker then before, but there is still one use case > that really bugs me. > > Given this code: > > $width = (isset($config['width']))? $config['width'] : 300; > > The code is pretty straight forward, if width is set in the array, use it > otherwise use 300. > > This code would look much better if it could make use of the ternary > operator > > $width = $config['width'] ?: 300; > > The only reason for this to not work is: it throws a notice if the array > key is not there (which is the case we are covering anyway) > > This is basically because the ternary operator does not do a internal > implicit isset, only an empty. > It does not do an empty. Empty would avoid notices as well. All it does is an implicit bool cast... > Does this seem like a possible improvement we can work on? Anyone > interested in championing the change? > I like it in principle. My only concern is *why* wasn't it done this way in the first place... Is there a reason? Anthony --00248c768f9e4c4f9304c51b5e76--