Php 如何为方法调用启用不匹配的typehint警告?
我有一个方法需要Php 如何为方法调用启用不匹配的typehint警告?,php,phpstorm,phpdoc,Php,Phpstorm,Phpdoc,我有一个方法需要int: /** * @param int $someInt */ public function methodExpectingInt($someInt) { // stuff } 然而,当仅在向其中传递对象时才从某处调用时,PhpStorm中将出现警告 /** * @return void */ public function someMethod() { $this->methodExpectingInt(23); // no warning
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
}
它将如下所示:
使用的PhpStorm版本是什么?可能是在v9中修复的。在任何情况下:没有额外的设置——这就是它目前的工作方式(v8.x)——不幸的是,我找不到票证(肯定有一个票证存在)。@LazyOne如果它不是当前的功能,那么我将创建一个票证=)@LazyOne当前我使用8.0。3@LazyOne如果有这个的复制品,我们会发现:找到它: