You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #57313 [Uid] Make AbstractUid implement Ds\Hashable if available (jahudka)
This PR was merged into the 7.2 branch.
Discussion
----------
[Uid] Make `AbstractUid` implement `Ds\Hashable` if available
| Q | A
| ------------- | ---
| Branch? | 7.2
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| License | MIT
This PR makes UUIDs usable with the PHP DS extension's `Map` and `Set` classes. It's a new feature and shouldn't cause any BC breaks.
The `Map` and `Set` classes in the DS extension have extended support for objects implementing the `Ds\Hashable` interface (as keys in `Map` and values in `Set`). By default, values are made unique by testing for strict equality, which will consider two `Uuid` instances to be distinct even though they represent the same UUID; with this PR merged, `Uuid` instances would behave as expected with these classes.
The current implementation of `AbstractUid` already includes the `equals()` method defined in the interface; the PR adds the missing `hash()` method and a shim for the interface in case the extension isn't loaded. I've also added a test for the new `hash()` method, checking both the behaviour of the method itself and the correctness of that behaviour when used with the `Ds\Set` class (that part of the test only runs if the `ds` extension is loaded).
I've read through the contributing docs, but it's still my first time contributing to Symfony, I'm sure I've made mistakes - please don't be too harsh on me! 🙏 ❤️
Commits
-------
1a0d9b0 [Uid] Make `AbstractUid` implement `Ds\Hashable` if available
0 commit comments