Description
Hello.
I wanted to use this package for my project (BTW good job, it looks very useful).
However I encountered an issue when I tried using it alongside php-ds/ext-ds (https://github.com/php-ds/ext-ds). What I would like to do is to use Enum objects inside Set structure, which by definition should store only unique values. The objects are compared using Hashable interface (https://github.com/php-ds/polyfill/blob/master/src/Hashable.php).
The issue is that my enum should therefore extend your Enum abstract class and implement Hashable at the same time. Unfortunately both have "equals" method declared and there are incompatibilities between the two. Due to how the Enum abstract class is designed, I cannot solve it without redeclaring the abstract enum class completely. The issues are:
- "equals" method from this package accepts only Enums as an argument. I think here you could safely drop the type declaration without it mattering much (you can check the type inside). Also the argument could be made that method like this should just return false when different type is passed instead of throwing an exception.
- "equals" method from php-ds/ext-ds has return type declaration declared (bool), while method in this package has none. I understand that the difference comes from the fact that you want to keep older PHP compatibility, so as long as you continue to do that there is not much we can do about it. Return type declaration can also be added by overriding the method, however in this case the abstract Enum class declares this method as final. While I agree with the reason why this was done, it also makes it impossible for me to do anything about that issue.
I'll probably use my own Enum class for now, but I would like to hear if you would be interested in fixing that issue somehow. I would be glad to help if you do.