简体   繁体   English

@return上的__construct()的PHPStorm Squawks

[英]PHPStorm Squawks on @return void for __construct()

I'm using PHPStorm and trying to figure out how to make it stop squawking when a __construct() has @return void in its PHPDocs... 我正在使用PHPStorm并试图弄清楚当__construct()的PHPDocs中有@return void时如何使其停止叫...

According the PHPDocs, void is valid, or the @return may be omitted. 根据PHPDocs, void是有效的,或者@return可以省略。 That being said, is there a way to fix this or is it a bug? 话虽这么说,有没有办法解决这个问题还是一个错误?

Unfortunately you can not turn off just this one very specific inspection. 不幸的是,您不能仅关闭这一非常具体的检查。 The whole PHPDoc method signature inspection would need to be turned off. 需要关闭整个PHPDoc方法签名检查。 Fortunately you can set the scope of the inspection to be only your own project code, ignoring 3rd party libraries and frameworks. 幸运的是,您可以将检查范围设置为仅属于您自己的项目代码,而无需考虑第三方库和框架。 See the scopes dropdown on the right under the description. 请参阅说明下方右侧的范围下拉菜单。

PHPStorm检查屏幕截图

Also on a case-by-case basis you can turn off the inspection above each PHPDoc comment: 同样,您可以根据情况关闭每个PHPDoc注释上方的检查:

/** @noinspection PhpDocSignatureInspection */
/**
 * @return void
 */
public function __construct() ...

See this document for how to suppress the warning for a statement. 请参阅本文档 ,了解如何取消声明的警告。 You can hover the portion of code and select the option from the drop-down. 您可以将代码部分悬停,然后从下拉菜单中选择选项。 You will have to do this for each affected constructor though. 但是,您将必须为每个受影响的构造函数执行此操作。

I don't see an Inspection Tool option to suppress this warning in a way that won't expose other issues. 我没有看到“检查工具”选项以不会暴露其他问题的方式抑制此警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM