【发布时间】:2020-11-16 08:10:49
【问题描述】:
我正在尝试捕获自定义异常,但在以下情况下不断收到Exception 'CustomException' is never thrown in the corresponding try block 检查错误:
class CustomException extends Exception { }
class Test {
/**
* @throws CustomException
*/
public function willFail()
{
throw new CustomException('I failed');
}
}
$test = new Test;
try {
$test->willFail();
} catch (CustomException $e) {
echo $e->getMessage();
}
上面的例子工作完全符合预期,除了 PhpStorm 给了我检查错误。
我到处搜索,无法找到如何在不完全禁用检查的情况下解决此问题。任何帮助将不胜感激!
【问题讨论】:
-
在我的盒子上运行良好。 “检查错误”是什么意思?
-
@YvesLeBorg 我已在我的问题中添加了屏幕截图。我希望这会有所帮助。谢谢!
-
无法复制:PhpStorm 2020.1.4、osx、php 7.2.8
-
当然,您遇到的每一个怪人总是有 jetbrains 经典之作。重新索引并重新启动。
-
@YvesLeBorg 感谢您的检查。我刚刚将我的 PhpStorm 版本更新到与您 2020.1.4 相同的版本,我仍然遇到这个问题......奇怪......
标签: php exception phpstorm docblocks