From f64a4f499b11a7533e4eb2000f9488e8988fdda1 Mon Sep 17 00:00:00 2001 From: vlakoff <544424+vlakoff@users.noreply.github.com> Date: Sun, 16 Nov 2025 09:15:21 +0100 Subject: [PATCH] fix(tests): remove deprecated MT_RAND_PHP and fix mt_rand() upper bound MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Switched RNG to the default MT_RAND_MT19937 (removed deprecated MT_RAND_PHP). - Fixed off-by-one in mt_rand(0, $blockSize) — the upper bound was not hit with the previous mode, but is reached with MT_RAND_MT19937, causing OutOfBoundsException. Changed to mt_rand(0, $blockSize - 1). --- test/Common/BitArrayTest.php | 2 +- test/Common/ReedSolomonCodecTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Common/BitArrayTest.php b/test/Common/BitArrayTest.php index 84aefc2..75e3b28 100644 --- a/test/Common/BitArrayTest.php +++ b/test/Common/BitArrayTest.php @@ -89,7 +89,7 @@ public function testGetNextSet4() : void public function testGetNextSet5() : void { - mt_srand(0xdeadbeef, MT_RAND_PHP); + mt_srand(0xdeadbeef); for ($i = 0; $i < 10; ++$i) { $array = new BitArray(mt_rand(1, 100)); diff --git a/test/Common/ReedSolomonCodecTest.php b/test/Common/ReedSolomonCodecTest.php index 1c1b699..cdc4366 100644 --- a/test/Common/ReedSolomonCodecTest.php +++ b/test/Common/ReedSolomonCodecTest.php @@ -26,7 +26,7 @@ public static function tabs() : array #[DataProvider('tabs')] public function testCodec(int $symbolSize, int $generatorPoly, int $firstRoot, int $primitive, int $numRoots) : void { - mt_srand(0xdeadbeef, MT_RAND_PHP); + mt_srand(0xdeadbeef); $blockSize = (1 << $symbolSize) - 1; $dataSize = $blockSize - $numRoots; @@ -60,7 +60,7 @@ public function testCodec(int $symbolSize, int $generatorPoly, int $firstRoot, i $errorValue = mt_rand(1, $blockSize); do { - $errorLocation = mt_rand(0, $blockSize); + $errorLocation = mt_rand(0, $blockSize - 1); } while (0 !== $errorLocations[$errorLocation]); $errorLocations[$errorLocation] = 1;