Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101612 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76463 invoked from network); 17 Jan 2018 18:47:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Jan 2018 18:47:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=info@eordes.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=info@eordes.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain eordes.com from 209.85.128.176 cause and error) X-PHP-List-Original-Sender: info@eordes.com X-Host-Fingerprint: 209.85.128.176 mail-wr0-f176.google.com Received: from [209.85.128.176] ([209.85.128.176:36000] helo=mail-wr0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3D/A0-12394-15A9F5A5 for ; Wed, 17 Jan 2018 13:47:45 -0500 Received: by mail-wr0-f176.google.com with SMTP id d9so19988238wre.3 for ; Wed, 17 Jan 2018 10:47:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eordes-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=VoyvLuOFkNWIjvLNYtcqjazCIFIHY56383n744UI+vw=; b=j8PUP0fXGnBGWRg0kVExyeWNP+ru6QufLmw2uhK7HxbbtDOqEqhh5WzpOwJKQZdMcQ UVS/g6z1tldepRp7U1kuXZaA6lbfMtdu2nZYUUU8XKRjkJooQhuFOu/fuAa9kEdUU8Hg fLoLYsQ6GreJddpsyOWc2KFXtIFR5p69op7Ybp0yZVZrcKlcyNpxJ56VHnst0tUhHtDb 643b6P+eZY5GFgT/K+RfjvkkRFlQzTQvfRSUCDzyyVDXF+NLqxUHUYbbbIStnq30I4yf qDr9C8tEJNEpGzcKCwXesjafTsqk+GT5PNkp+fGj+HkU52vvHuzbsKK4yLxeekSl8zoF Uwpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=VoyvLuOFkNWIjvLNYtcqjazCIFIHY56383n744UI+vw=; b=aNw1XDFZeEJrOEOCwHvWcMt9TSV6glCq/2AZboixexJEfjYBJ+vcKV7Y6Oy1i4tnNa Qqn4WqXnQQrqeJki5HZKn9mC3huFxW5lHmUStozkFHMSl+O5wDEMTBGqlTO3SsrU0/ZJ O13u4uhZx27Fxtkwngf7J8DjycTyQILYI2MBQeqya2eca1PEQQzRgnfvHP8k9GVcNBee 2u3SmKYxyY64mciYP35rUNPxYyQJbQGtKIL+4rGCxDcnQqqjAWNrnfJviO12e+HJgtOD mc+kP253r+i6zlNQxUkSu7rABP3Y08cU7czDsb5LkeThaZIzMwhNouzr8uSnUSDrd/HR psmg== X-Gm-Message-State: AKwxytddq0v2n3lSeg6sO1YWmD3nanTcV7jmgTw8qFkzviAh+++ImiKN Fmlu+0eAFi7sg6dzazUC/iuxGls5 X-Google-Smtp-Source: ACJfBou3bcJ6ZsVfMZRw9KAHB4ujEVTkSxPCzYyynFr49Iy5y/PhrmyAZKQnFzMZaiNULxd68L3P0w== X-Received: by 10.223.157.205 with SMTP id q13mr3679666wre.205.1516214862447; Wed, 17 Jan 2018 10:47:42 -0800 (PST) Received: from [192.168.0.20] (static-144-248-27-46.ipcom.comunitel.net. [46.27.248.144]) by smtp.gmail.com with ESMTPSA id p94sm4375811wrb.95.2018.01.17.10.47.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jan 2018 10:47:41 -0800 (PST) To: Andrey Andreev Cc: Marco Pivetta , PHP Internals List References: <6fac0482-93fe-b15f-632c-1058232abcf0@eordes.com> Message-ID: <12ad9ff5-10bb-8a0d-5048-a5d30849a2ba@eordes.com> Date: Wed, 17 Jan 2018 19:47:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: es-CO Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Improve null-coalescing operator (??) adding empty check (??:) From: info@eordes.com (Lito) On 17/01/18 19:43, Andrey Andreev wrote: > Hi, > > > On Wed, Jan 17, 2018 at 8:28 PM, Lito wrote: >> No $foo ?: 'default' , it's only equivalent to (isset($foo) && $foo) ? $foo >> : 'default' if $foo exists. >> >> Also PHP has added ?? as null-coalescing operator that works with undefined >> variables/attributes/keys, my proposal is an improvement over this one. >> >> I don't want to endorse usage of undefined variables, can be used in a large >> set of situations, like object attributes, array keys, etc... >> >> Anyway thanks for your feedback. >> Lito. >> > There is a shorter version: > > empty($foo) ? 'default' : $foo; > > And I think that's quite convenient for the few use cases it has > (refer to Nikita's reply). > > Cheers, > Andrey. > Yes, I think that: $foo = $foo ??: 'default'; Is more clear and with less code than: $foo = empty($foo) ? 'default' : $foo; As ?? does. Regards, Lito.