1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00
Files
archived-php-src/ext/standard/tests/strings/bug69751.phpt
Aliaksandr Bystry 41df5c0675 Fix bug #69751
Change error message of sprintf/printf for missing/invalid position
specifier to make it clear that this is talking about the specifier,
not the number of arguments passed to the function. Also mention
the upper limit of INT_MAX.

Closes GH-7515.
2021-09-29 12:21:37 +02:00

29 lines
646 B
PHP

--TEST--
Bug #69751: Change Error message of sprintf/printf for missing/typo position specifier.
--FILE--
<?php
try {
sprintf('%$s, %2$s %1$s', "a", "b");
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
try {
sprintf('%3$s, %2$s %1$s', "a", "b");
} catch (ArgumentCountError $e) {
echo $e->getMessage(), "\n";
}
try {
sprintf('%2147483648$s, %2$s %1$s', "a", "b");
} catch (ValueError $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
Argument number specifier must be greater than zero and less than %d
4 arguments are required, 3 given
Argument number specifier must be greater than zero and less than %d