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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to