On 28/05/16 09:06, Lester Caine wrote:
> class Person {
>   protected var $death; // var is intentional - my flag for a holder
>   $death->__type( DateTime, not_null = false );
> 
> To which one can add
>   $death->__limit( $birth, '120years' );
> Where $birth now has to be the same type and '120years' gets magically
> converted to a date offset :)

Adding that 'var' seemed totally natural as I wrote it. I could not
understand why at the time, but having slept on it, the reason has is
obvious. 'DateTime' can't be 'null' and any attempt to set it to such
will give you 'now' instead. BUT we have demonstrated (hopefully) that
we do need null dates, so we need a container that can either be null or
a date ... sounds suspiciously like good old var?

Now access to 'var' needs an attribute which can be
'public,private,protected' .. . but also 'read only' ( I'll ignore
'write only' because in my book that is part of the access level -
public read - protected write? ). The key element here is that if var is
a 'read_only' DateTime we don't need all the crap of DateTimeImmutable
and Derick's attempt at adding 'mutability' to the original dateTime
class would probably not have existed? The key I think here is IF 'var'
has been initialized and that depends on - perhaps - if the type
not_null is true. const comes to mind here as well and a
const var DateTime $start; Would give you a fixed snapshot time

HOPEFULLY you already see where this is going ...

Attributes such as __type, __limit, __length, __enum apply to the var
and are then used to ensure that the created value is valid.

Just to complete the picture in my archaic working practice...

public var $root_person
  $root_person->__type( Person, not_null = false );
  $root_person->__init( id1 );
Would have a value of an associative array of the data for 'Person'
consisting of the list of fully typed and constrained 'var' items. The
CODE for Person would simply work on the pointer to that hash. Which is
why I think I'm getting mixed up over the difference between the array
view of a value and the object view. In PHP they used to be
interchangeable but now things like this RFC are making them something
different?

-- 
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