4

目前在我的 PhpStorm 上,我启用了以下选项:

File | Settings | Editor | Inspections | Missing @return tag` ->  Marked both options there (Ignore PHPDoc without @param + Ignore PHPDoc with return type hint).
File | Settings | Editor | Inspections | PHPDoc comment matches function/method signature` ->  Mark option about allowing params with typehint.

所以根据这些设置,我的功能应该是这样的:

/**
 * @throws \Exception
 */
public function submit(string $email, string $message): Response
{ 
    throw new \Exception('whatever'); 
}

当我有一个没有 docblock 的函数并且我按下 PhpStorm 为该函数自动生成 docblock 时,它也为已经输入提示的参数生成 docblocks:

所以像这样的函数:

public function submit(string $email, string $message): Response
{ 
    throw new \Exception('whatever'); 
}

将转换为:

/**
 * @param string $email
 * @param string $message
 * @throws \Exception
 */
public function submit(string $email, string $message): Response
{ 
    throw new \Exception('whatever'); 
}

有没有一种方法可以配置我的 PhpStorm只为没有类型提示的参数生成文档块。

请注意,我知道我可以从 PhpStorm 配置模板。我尝试了那个解决方案。

在模板上,您只能告诉 PhpStorm 它是全有或全无。我找不到一种方法来告诉模板只有那些没有类型提示的参数文档块。

4

0 回答 0