A built-in function is called with too few or too many arguments, which PHP 8 rejects

tx0/php:builtin-argument-countstricterrorreliability/api-misusedepth fastbug

What it finds

A built-in function is called with too few or too many arguments, which PHP 8 rejects

Example from the rule's tests
<?php$a = str_replace('a', 'b');tx0 reports: str_replace takes at least 3 arguments, but is given 2$b = array_key_exists($key);tx0 reports: array_key_exists takes 2 arguments, but is given 1$c = strlen($s, 'utf-8');tx0 reports: strlen takes 1 argument, but is given 2$d = in_array($needle, $haystack, true, 1);tx0 reports: in_array takes at most 3 arguments, but is given 4$e = str_replace('a', 'b', $s);$f = max(...$values);$g = json_decode(json: $text);$h = sprintf('%s %s', $a, $b);$i = $object->strlen($a, $b);$j = App\strlen($a, $b);$k = implode($parts);
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 from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/php:builtin-argument-count" = "error"

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:builtin-argument-count] reason="..."

tx0 explain tx0/php:builtin-argument-count shows the same in the terminal. Found a false positive? Report it.