Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93666 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30352 invoked from network); 1 Jun 2016 09:40:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2016 09:40:14 -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:54056] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/C1-11325-C7DAE475 for ; Wed, 01 Jun 2016 05:40:12 -0400 Received: (qmail 25112 invoked by uid 89); 1 Jun 2016 09:40:09 -0000 Received: by simscan 1.3.1 ppid: 25101, pid: 25109, t: 0.0793s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.7?) (lester@rainbowdigitalmedia.org.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 1 Jun 2016 09:40:09 -0000 To: internals@lists.php.net References: Message-ID: <574EAD78.5000402@lsces.co.uk> Date: Wed, 1 Jun 2016 10:40:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Set object properties inline From: lester@lsces.co.uk (Lester Caine) On 01/06/16 03:15, Jesse Schalken wrote: > For large structures, this gets verbose very quick. There is a good example > of this here > > involving > 18 unnecessarily variables. > > I can remove the local variables by defining setters for all the properties: It's nice to see a page of code I can actually read and follow without having to dig out the 'new functions' crib sheets ... The main reason I recognise the code is it has elements I was working with carried over from the PHP4 stuff I started with and I'm still at the alternate solution ... $static1 = new Data\StaticVariable; $static1->name = 'variable name'; $static1->value = $unknown1; $static1->functionName = 'blahFunction'; $static1->className = null; Morphed into simply passing an array to the constructor ... $static1 = new Data\StaticVariable( array( 'name' => 'variable name', 'value' => $unknown1, 'functionName' => 'blahFunction' ) ); // className defaults to null Of cause the short cut at that time was to drop the names and simply count the variables, but what this replaces is all the complications of named parameters and allowed passing objects in such as '$unknown1' -- 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