Skip to content

Commit

Permalink
Fix: Select random mode depending on PHP version
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Jan 2, 2024
1 parent 1884fd7 commit a8b318c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,10 +687,22 @@ public function seed($seed = null)
if ($seed === null) {
mt_srand();
} else {
mt_srand((int) $seed, MT_RAND_PHP);
mt_srand((int) $seed, self::mode());
}
}

/**
* @see https://www.php.net/manual/en/migration83.deprecated.php#migration83.deprecated.random
*/
private static function mode(): int
{
if (PHP_VERSION_ID < 80300) {
return MT_RAND_PHP;
}

return MT_RAND_MT19937;

Check warning on line 703 in src/Generator.php

View check run for this annotation

Codecov / codecov/patch

src/Generator.php#L703

Added line #L703 was not covered by tests
}

public function format($format, $arguments = [])
{
return call_user_func_array($this->getFormatter($format), $arguments);
Expand Down

0 comments on commit a8b318c

Please sign in to comment.