laminas / laminas-validator

Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria
https://docs.laminas.dev/laminas-validator/
BSD 3-Clause "New" or "Revised" License
134 stars 59 forks source link

Algorithm passed to Hash is only used if algorithm key is provided before hash key #398

Closed InvisibleSmiley closed 3 days ago

InvisibleSmiley commented 2 weeks ago

Bug Report

Q A
Version(s) 2.x

Summary

The order of option keys determines whether the given algorithm is used.

Current behavior

If the algorithm key is passed after the hash key, the algorithm is silently set to crc32 (default).

How to reproduce

// works
new Hash(['algorithm' => 'sha1', 'hash' => 'foo']);
// fails
new Hash(['hash' => 'foo', 'algorithm' => 'sha1']);

Expected behavior

Order of keys in options array is irrelevant.

gsteel commented 4 days ago

FWIW, it's gonna be a while before adoption of validator 3.0 gets any traction, so a fix for this in 2.x will get merged and released if you can provide it 👍

gsteel commented 3 days ago

Fixed in #399