Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88181 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26345 invoked from network); 14 Sep 2015 12:10:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Sep 2015 12:10:36 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.178 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 209.85.212.178 mail-wi0-f178.google.com Received: from [209.85.212.178] ([209.85.212.178:35105] helo=mail-wi0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 87/51-17471-939B6F55 for ; Mon, 14 Sep 2015 08:10:36 -0400 Received: by wicge5 with SMTP id ge5so139759921wic.0 for ; Mon, 14 Sep 2015 05:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=JtmKPtGpRq2Uhsv9E8XwTwLChFWIn4Gz69OLdLHEblI=; b=eiuq7NxXHJMV+FfFLmPUes3cOd5fyMugRmxyezKO/IfMQkjeyOSN0nEtv7Al9NICKb RYJT1AYK+P1U0Njs2b4RRY+DSwTGriozc9AXC7KTvgYlU5VoMFgq9s4d5rBozcg8a37D Xgo9pFvC+wE2emNJWtWRFn795mMQSc5W5izeoff0UpRIXMVX1T0X4PO4rI0ACGoXf9VF 4eb4yH3QjlD2tKqdyUwDYztzd2TIqFd5V6Fb78bGq7hgvY74VtfqooYiDAQ6LwDRYGWq hLnvcBN0GQfuKN/NBOXG363Ba3kwqEzC3SWZJ4wUVFwM4QGdFUzMvooziRS7UXkYvMWP i8Rw== X-Received: by 10.180.86.100 with SMTP id o4mr25224358wiz.59.1442232630883; Mon, 14 Sep 2015 05:10:30 -0700 (PDT) Received: from [192.168.0.127] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id kb9sm15189833wjb.49.2015.09.14.05.10.29 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 Sep 2015 05:10:30 -0700 (PDT) To: Craig Francis References: <55DD4269.4090402@gmail.com> <6348DFA7-04BD-41BB-A500-17A8A531B56C@craigfrancis.co.uk> <55DDA4C9.9040603@gmail.com> <3C69BF4B-52E6-4D04-8601-8D23DFCC538E@craigfrancis.co.uk> <55DDD60F.5090509@gmail.com> <8C74463E-DBA2-4015-8159-0B44D973387F@craigfrancis.co.uk> <55DE0907.6040904@gmail.com> <1F615BCD-1B9B-4C51-A210-869F1AA1F6E3@craigfrancis.co.uk> <55E5EBBF.6020803@gmail.com> <0BA3A129-D356-4781-B6DE-E2B5A7924AE2@craigfrancis.co.uk> <55E6EC36.6090301@gmail.com> <9AF329EC-99A5-412D-A52B-432627A5520F@gmail.com> <6F4D91EE-B56E-4B83-B1AF-598C3F6897FC@craigfrancis.co.uk> <55F07BA4.2000204@gmail.com> Cc: internals@lists.php.net Message-ID: <55F6B911.9080400@gmail.com> Date: Mon, 14 Sep 2015 13:09:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: rowan.collins@gmail.com (Rowan Collins) Craig Francis wrote on 14/09/2015 12:46: > So yes, in the example above, an isset() would work, but I was trying to show why I don't think it's odd to "suppress a warning for a plain variable" when it does not exist. Yes, and I agree that this example shows a reasonable use of isset(). It works fine as it is, and doesn't need any functionality adding or removing. > Actually, I think they do use an array to store the values, then do an extract() to make them local variables in the View (keeping the variable names shorter and easier to read). Incidentally, I've always wondered why extract() would ever be useful in modern code, but I agree that if you don't want/need the overhead of a separate template compiler, that approach actually works quite nicely. > Yes, it is mis-used with arrays, but I would still argue that a single exists() function would work better for all of these examples when testing if they exist. > > And I would hope that no-one was using an unset() as something distinctly different from a NULL value. If you don't need the ability to distinguish unset() from null, what would any of these examples gain from using exists() over isset()? > I agree that we should not have a function that distinguishes between unset($foo) and $foo=null. But if you take the "is null" check out of isset(), that's exactly what you have; that's why the "is null" check is there in the first place. That's why I said I could agree with an exists() function (not under that name) as a nicer syntax for array_key_exists(), but not as a replacement for isset(). You could have an exists() function which works like array_key_exists() on an array, but identically to isset() on plain variables, but I think that would just be confusing. Hence my suggestion that any new function throw an error if given something other than an array access. Regards, -- Rowan Collins [IMSoP]