On 14 July 2018 15:37:32 BST, Levi Morrison <le...@php.net> wrote: >> class Validity { >> public \DateTimeInterface $validFrom; >> public ?\DateTimeInterface $validTo = null; >> } > >Even if this had a constructor we couldn't "trust" it because there >are ways to skip constructors.
Then the mechanisms should either be impossible with non-nullable properties, or have a way to mark the object initialised. If not, the object created would not be fully initialised, so accessing *the entire object* should be an error, not just accessing the specific properties which are marked non-nullable. I'm not claiming any of this is easy, but if you can't guarantee a property has a valid value, what is the type hint actually for? Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php