Why \Zlikavac32\Enum\Enum::enumerate isn't abstract method?
IMO it would be better if \Zlikavac32\Enum\Enum::enumerate was an abstract method, so that every class extending it has to implement the method, instead of throwing an exception on parent method call manually?
Edit:
Now I see that extension class also has to be an abstract class, so abstract method won't do much.
@zoka123 Is this still relevant? :)
Since the extension class has to be abstract, my suggestion doesn't work.
However, I still think it would be great if we could avoid manual exception throwing, and somehow enforce implementing methods in the extension class. What do you think? Does the extension (i.e. the enum) class have to be abstract?
@zoka123 Since this is a user land implementation, certain compromise must exist.
If class is not abstract, there is no guarantee that someone will not manually instantiate a class, and therefore accidentally introduce new enum instance.
Note that this is still not 100% guarantee that you will have one object instance per enum element, it just make is harder to do.
Reasoning being behind this is that I'd like to produce early warning "hey, you're doing something wrong".
If you have an idea how to enforce it without abstract class, I'm all ears. Until then, runtime is best that can be done :).
Of course, best thing would be to have a native PHP enum implementation :)