phpStorm升级后,会检查一些异常,这种应该怎么解决 [ 2.0 版本 ]
phpStorm近期升级后,新增了些新的功能,导致打开项目后,有些会有异常提示甚至报错:
情况一:
Unhandled \yii\web\NotFoundHttpException less... (Ctrl+F1 Alt+T)
The inspection reports exceptions which are neither enclosed in a try-catch block nor documented using the '@throws' tag
如图:
看官网上更新说明是这样的:
这种写法有问题吗?
我是自己重写了findModel方法:
/**
* Finds the OrderMain model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return OrderMain the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = OrderMain::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
情况二:
Arbitrary expressions in empty are allowed in PHP 5.5 only less... (Ctrl+F1 Alt+T)
Checks that language features used in the source code correspond the selected language level. (i.e. traits can be used only in PHP 5.4)
情况三:
这种形式我一直在用,而且现在也不会报错,只是在编辑器的时候就会报错
Steven0T 补充于 2017-12-20 09:18
最佳答案
其他 3 个回答
Steven0T 上海
注册时间:2017-09-22
最后登录:2023-07-17
在线时长:28小时32分
最后登录:2023-07-17
在线时长:28小时32分
- 粉丝10
- 金钱2970
- 威望160
- 积分4850