Class Constants With Different Types¶
With PHP, it is possible to have a class constant with different values, between a parent class, and its child class.
Quiz of the day : can you make a class constant with different types? Optionally different values.
Works on PHP 8.3. Application unknown.
The trick is to use union types, which allows adding new valid types without ascendant compatibility.
See Also¶
Different type of constants [Try me]