Remove mt_getrandmax() from WithTransaction jitter#1860
Conversation
There was a problem hiding this comment.
Pull request overview
Replaces mt_getrandmax() with 2 ** 53 for generating jitter in the WithTransaction operation, producing a random float in [0, 1] with full double-precision mantissa resolution.
Changes:
- Replace
mt_getrandmax()-based jitter withrandom_int(0, 2 ** 53) / 2 ** 53for better precision - Add test verifying jitter output is within
[0, 1]
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Operation/WithTransaction.php |
Replace jitter calculation to remove mt_getrandmax() dependency |
tests/Operation/WithTransactionTest.php |
Add test for jitter range validation |
You can also share your feedback on Copilot code review. Take the survey.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v2.x #1860 +/- ##
=========================================
Coverage 87.75% 87.75%
Complexity 3308 3308
=========================================
Files 447 447
Lines 6607 6607
=========================================
Hits 5798 5798
Misses 809 809
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Also, generating a float between [0,1] included is accepted.