Closed TysonAndre closed 2 years ago
@iluuu1994 after I'd mentioned strict_hash, I'd realized there was one last edge case I'd forgotten to unit test for Teds\strict_hash
and unique_values/StrictHashMap, but after I implement this change, the condition (X === Y) === true
(PHP's ===
operator) will imply that Teds\strict_hash(X) === Teds\strict_hash(Y)
for all php values, including float/array edge cases
If the top level value is an array, and the array contains reference cycles at any nesting depth, then give up on the current hash computation and only hash the parts of the top level that aren't arrays (keys, values)
This still meets the condition that if
X === Y
, thenstrict_hash(X) === strict_hash(Y)
- collisions are already inevitable due to the https://en.wikipedia.org/wiki/Pigeonhole_principlee.g. for