So, #PHP typed class constants are vaguely useful?
Here is a nice usage case that will definitely makes everyone love them.
https://php-tips.readthedocs.io/en/latest/tips/crazy_const_type.html
So, #PHP typed class constants are vaguely useful?
Here is a nice usage case that will definitely makes everyone love them.
https://php-tips.readthedocs.io/en/latest/tips/crazy_const_type.html
@bobmagicii I'd say my experience is opposite, enum are more useful than typed const Both are cool features, in any case.
Enum limit values and scope of any equivalent constant, leading to easier to understand code. Sometimes, it leads to more conversion, but not so much.
Can you elaborate?
@dseguy if you say so. there were zero instances where i could make enum's do anything without doing it. their api is just gross and why doesn't it have like a __toValue() magic method. now, typed consts, on a proper struct. 🤌
$EnumInt->value //weak
// things it seemly could not do
(int)$EnumInt // stronk forced __toValue
echo $EnumInt // magic __toValue
sprintf('you picked %d', $EnumInt); // i can keep going