> Just to be sure you don’t miss the herd that this elephant is concealing:
> 
> In addition, you *must* forbid unset() on those properties...


Shouldn't we delegate the whole problem to object type resolving and make it 
more strict? Right now properties are not guaranteed at all - you can
have `Foo` class with `$bar` property, but it does not mean that instance of 
`Foo` will actually have this property. The current implementation of
typed properties seems to be pretty consistent with this. Type check gives you 
nothing as far as the object's properties are concerned.

But if `$foo instanceof Foo` or `function (Foo $foo)` will test that `$foo`:

1. is an instance of `Foo`,
2. has all properties defined in `Foo`,
3. all typehinted properties are initialized,

then the problem will basically disappear - you can protect yourself from 
propagating uninitialized object by typehints or type checks (which you
would probably do anyway). And you still can create an uninitialized object for 
lazy initialization or whatever you want.


--

Regards,
Robert Korulczyk

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

Reply via email to