Comments (4)
It's ok I suppose to use my implementation, but I would rather not have to so that I can take easy advantage of updates and fixes.
Would an extension of MyClabs\Enum\Enum
which implements Hashable not also benefit from updates and fixes upstream?
from ext-ds.
Sadly the equals
method in that class is final
.
from ext-ds.
It is unfortunate that we do have a base equals method. I think checking for an exists function and calling it is a reasonable idea, can't see why not.
from ext-ds.
This works just fine for me:
<?php declare(strict_types = 1);
namespace App\Library\Enum;
use Ds\Hashable;
use MyCLabs\Enum\Enum as BaseEnum;
/**
* @psalm-immutable
* @extends BaseEnum<string>
*/
abstract class Enum extends BaseEnum implements Hashable
{
public function hash(): string
{
return $this->getValue();
}
}
The point is you don't need to override the equals
method since the base Enum class already implements it and it is compatible with Hashable.
That said I do agree that being able to provide a custom equality function could be beneficial in some cases. It's not necessary for MyCLabs enums though.
from ext-ds.
Related Issues (20)
- Segmentation fault when Map is used with IteratorIterator (v1.3.0) HOT 3
- . HOT 1
- map method for Set? HOT 3
- PHP 8.1 compatibility HOT 5
- How to make sure extension is used HOT 5
- How to install in PHP8 Docker alpine:version image? HOT 8
- Support php 7.4's `__unserialize` to prepare for PHP 9.0 removing Serializable
- Release supporting PHP 8.1 HOT 11
- Audit and update documentation HOT 1
- ReflectionClass and ReflectionObject not reporting information when using Ds\Map via extension
- Passing array item by reference breaks \DS\Set behaviour HOT 1
- php_ds.dll for PHP 8.2.x on Windows HOT 2
- Pecl install missing php 8.2 HOT 3
- Better Interface Segregation (Future Version?) HOT 3
- Clarify Support for PHP 8.3.x and 9.x? HOT 11
- Segmentation fault merging keys of maps containing maps HOT 7
- DLL missing on PECL for 1.5.0 HOT 3
- Upgrade PECL page to identify homepage HOT 2
- Null coalescing operator on Vector make search failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ext-ds.