如何为方法调用启用不匹配的typehint警告?

时间:2015-06-04 12:12:53

标签: php phpstorm phpdoc

我有一种方法需要int

/**
 * @param int $someInt
 */
public function methodExpectingInt($someInt)
{
    // stuff
}

然而,只有在将对象传入其中时从某处调用时,PhpStorm才会发出警告。

/**
 * @return void
 */
public function someMethod()
{
    $this->methodExpectingInt(23); // no warning but as an int everything is fine
    $this->methodExpectingInt(new \Object()); // gets a warning in phpstorm \o/
    $this->methodExpectingInt("this string should issue a warning"); // no warning yet is string
    $this->methodExpectingInt(null); // no warning yet is null
    $this->methodExpectingInt(2.9); // no warning yet is a float
}

看起来像这样:

Screenshot of the method call and missing warning

0 个答案:

没有答案