vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Diagnostic that detects incorrect `sprintf` use

Open TimWolla opened this issue 2 years ago • 0 comments

Feature description or problem with existing feature

I'd like to see a diagnostic error if I call sprintf() with an inappropriate number of arguments.

Describe the solution you'd like

When my sprintf() format string contains 2 placeholders, but I only pass 1 value, then PHP will throw an ArgumentCountError. I'd like Intelephense to report this error for me.

Additional context

<?php

printf(
	'%s %s', // two placeholders
	'foo' // only one parameter
);

/*
Fatal error: Uncaught ArgumentCountError: 3 arguments are required, 2 given in test.php on line 5
*/

image

TimWolla avatar Aug 05 '22 13:08 TimWolla