diff --git a/composer.json b/composer.json index 34f1381..794e7fe 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "php": ">=5.2.0" }, "require-dev": { - "phpunit/phpunit": "4.*|5.*" + "phpunit/phpunit": "*" }, "suggest": { "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." diff --git a/lib/random.php b/lib/random.php index 6df1cb0..9429ec3 100644 --- a/lib/random.php +++ b/lib/random.php @@ -183,7 +183,7 @@ class_exists('COM') try { $RandomCompatCOMtest = new COM('CAPICOM.Utilities.1'); /** @psalm-suppress TypeDoesNotContainType */ - if (method_exists($RandomCompatCOMtest, 'GetRandom')) { + if (is_callable(array($RandomCompatCOMtest, 'GetRandom'))) { // See random_bytes_com_dotnet.php require_once $RandomCompatDIR.DIRECTORY_SEPARATOR.'random_bytes_com_dotnet.php'; } diff --git a/tests/unit/RandomBytesTest.php b/tests/unit/RandomBytesTest.php index 4b3ab43..c6e2048 100644 --- a/tests/unit/RandomBytesTest.php +++ b/tests/unit/RandomBytesTest.php @@ -40,7 +40,9 @@ public function testOutput() random_bytes(12), random_bytes(64), random_bytes(64), - random_bytes(1.5) + PHP_VERSION_ID < 80100 + ? random_bytes(1.5) + : random_bytes(1) ); $this->assertTrue( diff --git a/tests/unit/RandomIntTest.php b/tests/unit/RandomIntTest.php index c8cbb0d..b6371b7 100644 --- a/tests/unit/RandomIntTest.php +++ b/tests/unit/RandomIntTest.php @@ -16,10 +16,14 @@ public function testOutput() random_int(-1000, 1000), random_int(~PHP_INT_MAX, PHP_INT_MAX), random_int("0", "1"), - random_int(0.11111, 0.99999), + PHP_VERSION_ID < 80100 + ? random_int(0.11111, 0.99999) + : 0, random_int($half_neg_max, PHP_INT_MAX), random_int(0.0, 255.0), - random_int(-4.5, -4.5), + PHP_VERSION_ID < 80100 + ? random_int(-4.5, -4.5) + : -4, random_int("1337e3","1337e3") );