Only Initialize With Short Assignation Coalesce

no-email (Damien Seguy), Damien Seguy
Sat, 22 Oct 2022 00:00:00 +0000

It is not possible to access a property before its initialisation. This is true to both static and normal properties.
While normal properties are initialized at constructor time, static properties might require a check before assignation : in case the property has not been yet assigned, a Fatal error will stop the code execution.
In fact, there is a way : it is the short assignation with coalesce, which will accept to check the NULL value, and only fill it if it is null.