PhpStorm 中参数过多的函数调用警告

Warnings for function calls with too many parameters in PhpStorm

PhpStorm 警告 PHP 代码中的许多问题(潜在的或真实的)。通常,我会看到这样的代码:

function doSomething($a, $b) {
     // ...
}

$value = doSomething("1", "2", "3"); // the third parameter is superfluous!

我知道这实际上是 PHP 的一个功能,但我希望我的代码库有更严格的规则。我可以让 PhpStorm 显示参数过多的函数调用的警告吗?

我认为这种支票更属于风格(ala javacheckstyle)类别。 PHPStormPHP Code Sniffer. Take a look at the docs here 集成。

代码嗅探器让您定义自己的编码标准规则,因此您可以尝试为此添加规则。

  1. Settings/Preferences | Editor | Inspections
  2. PHP | Code Smell
  3. Parameters number mismatch declaration