Skip to content

gmp_random_seed(): update example for PHP 8 - #5965

Merged
lacatoire merged 1 commit into
php:masterfrom
qodelicious:gmp-random-seed-example-valueerror
Oct 19, 2026
Merged

lacatoire merged 1 commit into
php:masterfrom
qodelicious:gmp-random-seed-example-valueerror

Conversation

@qodelicious

Copy link
Copy Markdown
Contributor

The example still called gmp_random(), which was removed in PHP 8.0.0, and showed the warning and false return that gmp_random_seed() no longer produces (it throws a ValueError as of PHP 8.0.0, as the changelog already says).

The example now uses gmp_random_bits() and gmp_random_range() and catches the ValueError. The output was checked with PHP 8.4. gmp_random() is also dropped from the parameter description and the See also list.

Fixes #1387

The example called gmp_random(), which was removed in PHP 8.0.0, and
showed the warning and false return that gmp_random_seed() no longer
produces. Use gmp_random_bits()/gmp_random_range() and catch the
ValueError instead, and drop gmp_random() from the related functions.

Fixes php#1387
@lacatoire
lacatoire merged commit ea41e5c into php:master Oct 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gmp_random_seed() throws a ValueError as of PHP 8.0, return section is incorect

2 participants