Kinda sad you can’t use enum members as keys in a WeakMap. Gotta use SplObjectStorage which can have garbage collection (or lack thereof) implications.

The latter is not nearly as concise, either.

@michaeldyrynda From PHP 8.2 you can use ->value on the left hand size to make this work, if your enum's are string/int backed.
@derickr works for sure and is how I’ve had to do it, just grim having to do it at all. I’d expect the inference to be implicit but at that point may as well just use an associative array.