Modernize for 4.0.0: PHP 8.1+, full typing, PHPUnit 10-12, GitHub Actions - #26
Modernize for 4.0.0: PHP 8.1+, full typing, PHPUnit 10-12, GitHub Actions#26serima wants to merge 1 commit into
Conversation
…ions - PHP ^8.1 minimum (was >=7.2); full parameter, return and property type declarations throughout - Fix lookupList() returning fewer targets than requested when adjacent ring positions belong to the same target (regression in the unreleased binary-search lookup, #24), with regression tests - Fix implicitly nullable constructor parameters deprecated in PHP 8.4 - Fix BenchmarkTest::median() element selection and TypeError under strict_types - HasherInterface::hash() now declared as hash(string $string): int|float - Replace Travis CI and Coveralls with GitHub Actions (PHP 8.1-8.5, PHPCS, PHPStan) - Upgrade PSR-2 to PSR-12; add PHPStan at level 9 - PHPUnit 10/11/12 with attributes instead of annotations - Drop committed composer.lock; add composer scripts (test, benchmark, cs, cs:fix, stan, check) Hash values and position derivation are unchanged: upgrading does not remap keys to different targets (verified against v3.0.0 with CRC32 and MD5 hashers over 2000 keys, including weighted targets and removal). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@pda @dmnc Before I merge this, I'd like to get a green light from you since it's a major release (4.0.0) — no rush, and happy to adjust anything. A quick summary of what this does and why I believe it's safe:
My plan after approval: merge, then create the If either of you would rather keep a lower PHP floor, split the release differently, or take over the release itself, just say the word. |
|
@serima this all looks very sensible to me and I think the BC interface changes are absolutely fine given it is a breaking version and you have kept the hashing consistent. Unfortunately I don't use flexihash in any projects at the moment as my big historical use case was sharding assets across CDN domains which is no longer necessary with HTTP/2. This means I can't really test it in an application. The only additional thing I might recommend is adding https://packagist.org/packages/rector/rector and a corresponding config file so that this sort of process can be automated in future. |
Summary
Modernizes the library as the 4.0.0 release while keeping it safe for existing users:
^8.1minimum (was>=7.2), with full parameter, return and property type declarations throughout.lookupList()could return fewer targets than requested when adjacent ring positions belonged to the same target (with the default 64 replicas this affects roughly 1 in 10 keys forlookupList($key, 2)). Duplicates are now skipped, restoring the v3.0.0 semantics. Regression tests included, verified to fail against the previous implementation.HasherInterface::hash()is now declared ashash(string $string): int|float(BC break for custom hashers, documented in the CHANGELOG).composer.lock, adds composer scripts (test,benchmark,cs,cs:fix,stan,check), refreshes README/CHANGELOG/ROADMAP.Compatibility
Hash values and position derivation are unchanged. Verified by running identical workloads (CRC32 and MD5 hashers, 2000 keys, weighted targets, target removal) against the v3.0.0 implementation: lookup results are byte-for-byte identical, so upgrading does not remap keys.
Existing 2.x/3.x users are unaffected per SemVer; documented BC breaks only affect custom
HasherInterfaceimplementations (must add the return type) andstrict_typescallers passing non-string targets.Verification
🤖 Generated with Claude Code