PhpStorm 2022.3 Help

Code Inspection: Format function parameters mismatch

Reports the arguments of a format function (such as printf or sprintf) that are not mapped to any parameters or specification conversions.

See printf (php.net) and sprintf (php.net) for details.

  • In the following example, the sprintf() call contains two conversion specifications, %d and %s, but is provided three parameters. The last parameter $foo is therefore not mapped to any conversion specification:

    sprintf('There are %d monkeys in the %s', 5, 'tree', $foo);
  • In the following example, the sprintf() call contains three conversion specifications, %d, %s, and %s, but is only provided two parameters. The last conversion specification %s is therefore not mapped to any parameter:

    sprintf('There are %d %s in the %s', 5, 'tree');

Suppress an inspection in the editor

  1. Position the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 16 May 2022