3 ms·
>So, singletons. That way you end up with more global state, with all its consequences. As you point out, the lack of properties solves that. The use of a sing
by CiaranMcNulty 6y ago
>So, singletons. That way you end up with more global state, with all its consequences.
As you point out, the lack of properties solves that. The use of a singleton probably relates to the identity issue
> at this point you may just as well skip the entire object part as I don't see why exactly it's needed for an identity check.
PHP only has 8 types (string, int, bool, float, array, null, resource, object) and they're not likely to be added to (resource is largely deprecated).
Given that, object is the only one that's not likely to be abused by relying on the actual scalar value. Keeping it as a singleton ensures that === will still work (it requires 'same instance')
- pdenton 6y agoThanks for clearing that up. There's one more thing not addressed by the RFC: how to check for a particular enum to exist. The way I see it, a new function "enum_exists" would be needed and validating a QCN would become this ugly: class_exists($qcn) || enum_exists($qcn) || interface_exists($qcn) || trait_exists($qcn)
- beberlei 6y agoits implicitly addressed by saying enums map to objects and clarifying how "::class" works, i.e. enum_exists is not necessary, because its implementation would essentially be class_exists.
- pdenton 6y agoAh, right. The assumption that "new ReflectionClass($qcn)" where "assert(class_exists($qcn))" works should still be valid as RefelctionEnum[sic] extends ReflectionClass. I'm not completely certain on this, though. If not, it'd definitely break things.
- beberlei 6y agoits definitely a weak point of the RFC at the moment.