Skip to content

Conversation

@ruudk
Copy link
Contributor

@ruudk ruudk commented Oct 23, 2025

PHP 8.5 will be released next month and this library has an issue with the hashCode function.

Fixes #39

@ruudk ruudk changed the title Add PHP 8.5 to CI matrix chore: Add PHP 8.5 to CI matrix Oct 23, 2025
ruudk added 2 commits October 23, 2025 18:41
PHP 8.5 introduced stricter float-to-int casting that throws an error when
a float value is not representable as an integer. The hashCode function's
bit shifting operations could produce values exceeding PHP's integer range,
causing automatic conversion to float and subsequent casting errors.

This fix applies bitwise AND with 0xFFFFFFFF to keep values within 32-bit
range and properly converts from unsigned to signed 32-bit integers,
preventing float conversion while maintaining consistent hash values.

Fixes amplitude#39
@ruudk ruudk changed the title chore: Add PHP 8.5 to CI matrix fix: Introduce PHP 8.5 compatibility for hashCode function Oct 23, 2025
@ruudk
Copy link
Contributor Author

ruudk commented Oct 23, 2025

@bgiori @tyiuhc Please have a look. I have no idea if the hash code function is how it should be.

Copy link
Collaborator

@zhukaihan zhukaihan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the PR. Left a comment.

Co-authored-by: Peter Zhu <7332407+zhukaihan@users.noreply.github.com>
@zhukaihan zhukaihan merged commit 8f87a6e into amplitude:main Oct 28, 2025
9 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 28, 2025
## [1.2.5](1.2.4...1.2.5) (2025-10-28)

### Bug Fixes

* Introduce PHP 8.5 compatibility for hashCode function  ([#38](#38)) ([8f87a6e](8f87a6e))
@github-actions
Copy link

🎉 This PR is included in version 1.2.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[PHP 8.5] The float -1.1395574650780983E+19 is not representable as an int, cast occurred

2 participants