Re:Perils of Constructors
by TazeTSchnitzel on Saturday July 27, 2019 @05:13PM
(#20544227)
PHP 7.4 adds optional type declarations for properties on an object, and so there was the problem of how to avoid an inconsistent state (type not matching before initialisation). The route that was eventually taken was to have the properties not be null, but be unset. If you try to read from them at runtime without having written to them first, an error is thrown. Notably, there's no requirement everything be defined when the constructor exits.
[ Parent
| on HN ]
There are no comments on this comment yet.