Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93583 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93109 invoked from network); 26 May 2016 19:33:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2016 19:33:52 -0000 Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; 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:55040] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/1E-17600-F9F47475 for ; Thu, 26 May 2016 15:33:52 -0400 Received: (qmail 15893 invoked by uid 89); 26 May 2016 19:33:49 -0000 Received: by simscan 1.3.1 ppid: 15886, pid: 15889, t: 0.1738s 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; 26 May 2016 19:33:48 -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> Message-ID: <57474F9C.6080104@lsces.co.uk> Date: Thu, 26 May 2016 20:33:48 +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: <6f7403b6-bf22-a12b-dfb2-43fe82983e7d@fleshgrinder.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 26/05/16 20:16, Fleshgrinder wrote: > On 5/26/2016 9:10 PM, Lester Caine wrote: >> DateTime is probably a better example to work with than 'int' since it >> already has a long pedigree of problems and clashes where many projects >> had their own interpretation and still use their own version of the >> class. My problem with '\DateTime $d' is that by default it returns >> 'now' rather than an 'empty/null' value in which to put the data from >> the database. I can't create a 'null' version of DateTime so one has to >> have a phantom date simply to ensure you know if it has been initialized >> with your own data later - or continue to use the older user space classes. >> >> It is handling just how the variable/property is initialized that is the >> whole problem here and there may be very good reasons that the >> initialization is later then the 'construct' be that a DateTime or an >> int ... null is the correct way of indicating that 'as yet we do not >> have the value of type xxx' just as it does for an untyped value, so >> trying to make a special case to block it's use is simply strangling >> normal usage in other cases? > > Could you come up with some example code of what you cannot achieve? I > cannot think of a single situation that is valid and not a developer > error which would be impossible with the currently discussed approach. If I am creating an object which is a 'person' for which I actually want to ensure I have valid dates for birth, marriage and death and an integer 'no of siblings' then I have a set of 'typed' properties. Initially the object is not initialized ... no person found in the database ... so null values for every property in the object. When I search and find a match, then I may get someone who is 'alive' so the death property remains null. Currently one can not use DateTime variables to do any of this as they have already defined their own alternative to null by blocking it. So in this case it is pointless trying to create any 'can be null' flag? Class variables are simply not handling the problem consistently so one has to jump through hoops to get back what used to be a simple null initialised set of properties? -- 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