Skip to content

Improve phrasing in argument value errors in ext/random #9206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/random/engine_mt19937.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ PHP_METHOD(Random_Engine_Mt19937, __construct)
state->mode = MT_RAND_PHP;
break;
default:
zend_argument_value_error(2, "mode must be MT_RAND_MT19937 or MT_RAND_PHP");
zend_argument_value_error(2, "must be either MT_RAND_MT19937 or MT_RAND_PHP");
RETURN_THROWS();
}

Expand Down
2 changes: 1 addition & 1 deletion ext/random/engine_pcgoneseq128xslrr64.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ PHP_METHOD(Random_Engine_PcgOneseq128XslRr64, __construct)
}
seed128(engine->status, php_random_uint128_constant(t[0], t[1]));
} else {
zend_argument_value_error(1, "state strings must be 16 bytes");
zend_argument_value_error(1, "must be a 16 byte (128 bit) string");
RETURN_THROWS();
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion ext/random/engine_xoshiro256starstar.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ PHP_METHOD(Random_Engine_Xoshiro256StarStar, __construct)
}
seed256(engine->status, t[0], t[1], t[2], t[3]);
} else {
zend_argument_value_error(1, "state strings must be 32 bytes");
zend_argument_value_error(1, "must be a 32 byte (256 bit) string");
RETURN_THROWS();
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion ext/random/tests/02_engine/mt19937_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ try {

?>
--EXPECT--
Random\Engine\Mt19937::__construct(): Argument #2 ($mode) mode must be MT_RAND_MT19937 or MT_RAND_PHP
Random\Engine\Mt19937::__construct(): Argument #2 ($mode) must be either MT_RAND_MT19937 or MT_RAND_PHP
2 changes: 1 addition & 1 deletion ext/random/tests/02_engine/pcgoneseq128xslrr64_seed.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for ($i = 0; $i < 1000; $i++) {
?>
--EXPECTF--
Random\Engine\PcgOneseq128XslRr64::__construct(): Argument #1 ($seed) must be of type string|int|null, float given
Random\Engine\PcgOneseq128XslRr64::__construct(): Argument #1 ($seed) state strings must be 16 bytes
Random\Engine\PcgOneseq128XslRr64::__construct(): Argument #1 ($seed) must be a 16 byte (128 bit) string
object(Random\Engine\PcgOneseq128XslRr64)#%d (%d) {
["__states"]=>
array(2) {
Expand Down
2 changes: 1 addition & 1 deletion ext/random/tests/02_engine/xoshiro256starstar_seed.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ for ($i = 0; $i < 1000; $i++) {
?>
--EXPECTF--
Random\Engine\Xoshiro256StarStar::__construct(): Argument #1 ($seed) must be of type string|int|null, float given
Random\Engine\Xoshiro256StarStar::__construct(): Argument #1 ($seed) state strings must be 32 bytes
Random\Engine\Xoshiro256StarStar::__construct(): Argument #1 ($seed) must be a 32 byte (256 bit) string
object(Random\Engine\Xoshiro256StarStar)#%d (%d) {
["__states"]=>
array(4) {
Expand Down