Menu

← Back to argument.*

Error Identifier: argument.vprintf

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

vprintf('%s is %d years old', ['Alice']);

Why is it reported? #

The number of format placeholders in the vprintf format string does not match the number of values in the array argument. The vprintf function requires the array to contain exactly as many values as there are placeholders in the format string. A mismatch will result in missing values or ignored extra values at runtime.

In the example above, the format string '%s is %d years old' contains 2 placeholders (%s and %d), but the array only provides 1 value ('Alice').

How to fix it #

Pass the correct number of values in the array to match the placeholders:

 <?php declare(strict_types = 1);
 
-vprintf('%s is %d years old', ['Alice']);
+vprintf('%s is %d years old', ['Alice', 30]);

Or adjust the format string if fewer values are intended:

 <?php declare(strict_types = 1);
 
-vprintf('%s is %d years old', ['Alice']);
+vprintf('%s says hello', ['Alice']);

How to ignore this error #

You can use the identifier argument.vprintf to ignore this error using a comment:

// @phpstan-ignore argument.vprintf
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: argument.vprintf

Rules that report this error #

  • PHPStan\Rules\Functions\PrintfArrayParametersRule [1] [2]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.