Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88274 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78840 invoked from network); 16 Sep 2015 23:26:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Sep 2015 23:26:48 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lsces.co.uk from 217.147.176.214 cause and error) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 217.147.176.214 mail4-2.serversure.net Linux 2.6 Received: from [217.147.176.214] ([217.147.176.214:55513] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/67-41443-6BAF9F55 for ; Wed, 16 Sep 2015 19:26:47 -0400 Received: (qmail 10997 invoked by uid 89); 16 Sep 2015 23:26:43 -0000 Received: by simscan 1.3.1 ppid: 10985, pid: 10991, t: 0.0822s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.8?) (lester@rainbowdigitalmedia.org.uk@86.160.91.166) by mail4.serversure.net with ESMTPA; 16 Sep 2015 23:26:43 -0000 To: Rowan Collins , internals@lists.php.net References: <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> <55F6B911.9080400@gmail.com> <96BE7F01-D04B-483B-B1A3-B45CED6DFCDC@craigfrancis.co.uk> <55F6F08C.1020506@gmail.com> <0BEF6D82-CB5F-49F6-A3A4-3267924A0CDA@thesba.com> <55F72CA9.2060301@gmail.com> <09369945-76FE-4E08-9C2C-15FB0577AD27@thesba.com> <55F752E7.9070801@gmail.com> <55F9B4C7.3050700@gmail.com> <440C64A2-4B4F-4AEF-ACE3-F3A6637EBAB6@thesba.com> <55F9D704.5050002@lsces.co.uk> <55F9EFA2.9020908@lsces.co.uk> <0022A1D9-DC37-4F49-B58E-FBED5AF872BA@gmail.com> Message-ID: <55F9FAB3.2050100@lsces.co.uk> Date: Thu, 17 Sep 2015 00:26:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <0022A1D9-DC37-4F49-B58E-FBED5AF872BA@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] PHP 7.1 - Address PHPSadness #28? From: lester@lsces.co.uk (Lester Caine) On 17/09/15 00:09, Rowan Collins wrote: >> That is better coding practice, but extract() is an equally >> >valid practice currently being used and that needs a different way of >> >handling if the elements exist. > I'm still not entirely sure what it is you need to "handle". > > What is the behaviour that you'd put in the if(! exists ()) block? More particularly, what would you put there and not put in the if(! is_null()) block, since if they're the same, then that's what if(! isset()) does, so we're all good? I'd answered that one, but it looks like it did not end up on the list. Pushing it again ... If the 'variable' exists but is NULL you create a default element of that name. If the 'variable' does not exist nothing gets created. So exists($checklist) { is_null($checklist) { create default/empty object(); } else { create populate odbject($checklist); } else { display code in place of object; } If $checklist is always +ve then one can use '0' in place of NULL, but when a 'default' value is difficult to define NULL fills the gap and in SQL that is well understood, and there is no reason that the is_null() check is not part of createobject function but hat is optional. I personally would stick with the $hash['checklist'] but others obviously prefer to loose the $hash once inside the 'object' and currently you end up CURRENTLY with isset($checklist) { createobject($checklist); } else { is_null($checklist) { createobject($checklist); } Styling element in place of object; } Assuming createobject also handles the NULL condition with a second is_null inside the function. exists simply streamlines this to exists($checklist) { createobject($checklist); // Null = empty or default object } else { Styling element in place of object; // !exists leaves out object, or has code to create one } -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk