1.2.991. Printf Number Of Arguments

The number of arguments provided to printf(), vprintf() and vsprintf() doesn’t match the format string.

Extra arguments are ignored, and are dead code as such. Missing arguments are reported with a warning, and nothing is displayed.

Omitted arguments produce an error.

<?php

// not enough arguments
printf(' a %s ', $a1);
// OK
printf(' a %s ', $a1, $a2);
// too many arguments
printf(' a %s ', $a1, $a2, $a3);

// not enough arguments
sprintf(' a %s ', $a1);
// OK
\sprintf(' a %s ', $a1, $a2);
// too many arguments
sprintf(' a %s ', $a1, $a2, $a3);

?>

See also printf, sprintf and vsprintf.

1.2.991.1. Suggestions

  • Sync the number of argument with the format command

1.2.991.2. Specs

Short name

Structures/PrintfArguments

Rulesets

All, Analyze, CE, CI-checks

Exakat since

1.0.1

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

Medium

Features

print

Examples

PhpIPAM

Available in

Entreprise Edition, Community Edition, Exakat Cloud