A printf-style call has a different number of values than its format string asks for

tx0/php:format-argumentsdefaultwarningreliability/api-misusedepth fastbug

What it finds

sprintf('%s of %s', $done): the number of values after a literal format string must cover its conversions. Too few is an ArgumentCountError in PHP 8; too many means a value meant for the output is silently left out. Positional conversions such as %2$s count by their highest position.

From the rule's source, format_arguments.rs.

Example from the rule's tests
<?phpfunction show($done, $total, $name){    $a = sprintf('%s of %s', $done);tx0 reports: the format of sprintf takes 2 values, but 1 are given    printf('%d%% done', $done, $total);tx0 reports: the format of printf takes 1 values, but 2 are given    $b = sprintf('%1$s and %1$s', $name);    $c = sprintf("%'.10d|%-5s", $done, $name);    $d = sprintf($name, $done);    return $a . $b . $c . $d;}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/php:format-arguments" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/php:format-arguments] reason="..."

tx0 explain tx0/php:format-arguments shows the same in the terminal. Found a false positive? Report it.