Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93604 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75472 invoked from network); 27 May 2016 09:53:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 May 2016 09:53:10 -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:34498] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/66-37127-40918475 for ; Fri, 27 May 2016 05:53:09 -0400 Received: (qmail 3030 invoked by uid 89); 27 May 2016 09:53:05 -0000 Received: by simscan 1.3.1 ppid: 3024, pid: 3027, t: 0.0775s 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; 27 May 2016 09:53:05 -0000 To: internals@lists.php.net References: <20160525215208.034FC1A801B3@dd1730.kasserver.com> <5fd54aa0-4fdf-c1e7-eae8-765aa89c8498@fleshgrinder.com> <08963b03-8394-6d62-4e5b-393f3fcb5647@fleshgrinder.com> <9e9db70d-d72d-d93e-0c81-18c2aa228618@gmail.com> <409002d8-b5e3-5990-7358-246adc7e3cab@fleshgrinder.com> <57474A08.80807@lsces.co.uk> <6f7403b6-bf22-a12b-dfb2-43fe82983e7d@fleshgrinder.com> <57474F9C.6080104@lsces.co.uk> <1733cfce-001b-1079-e929-88f7dde0f2dd@gmail.com> <57475F27.3090306@lsces.co.uk> <50f5d1c9-d24f-1afe-4c34-70aafd981524@fleshgrinder.com> <5747697A.7000906@lsces.co.uk> <37377d3b-827a-4cfd-580b-e33862084ab6@gmail.com> <5747F02A.2010808@lsces.co.uk> <426da65f-bc9a-93ed-ce16-0fefe8b9eb43@gmail.com> Message-ID: <57481901.1070102@lsces.co.uk> Date: Fri, 27 May 2016 10:53:05 +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: <426da65f-bc9a-93ed-ce16-0fefe8b9eb43@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: lester@lsces.co.uk (Lester Caine) On 27/05/16 10:16, Rowan Collins wrote: > My comment was in reaction to Lester expressing surprise at destroying > and re-creating objects when new data is fetched. To be clear, I'm > talking about this: > > // Clear old data > $this->data = []; > // Re-populate from new DB result > foreach ( $db_resultset as $row ) { > $this->data[] = new SomeModel($row); > } > > The most useful typehints are inside the SomeModel class, not the > table-level wrapper. This is true even if they're just dumb structs, and > all the behaviour is at the table level, because it presumably has > basically one field: array $data. Probably the only difference here is that '$row' in my result set is not a dumb structure. It has type information, field lengths and potentially even value constraints. So my table level wrapper can potentially have the same typehints that you are then adding to SomeModel. All the properties of SomeModel already exist and if typed properties are working correctly in PHP $row can simply be accessed directly. This is why in my book all of the debate about 'attributes' and everything else is so tied up in the definition of making a simple variable a much more flexible generic object. -- 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