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)
情况三:
这种形式我一直在用,而且现在也不会报错,只是在编辑器的时候就会报错
首先 在phpstorm里面设置下php的版本
function前面的 /* 加上’@throws’标签
关闭phpstorm错误提示
/**