谁一开始就是大神?

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

如图:
企业微信截图_15135967806916.png

看官网上更新说明是这样的:
企业微信截图_1513596848842.png

这种写法有问题吗?
我是自己重写了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)

企业微信截图_15135972702537.png

情况三:
TIM截图20171218194206.png

这种形式我一直在用,而且现在也不会报错,只是在编辑器的时候就会报错

首先 在phpstorm里面设置下php的版本
function前面的 /* 加上’@throws’标签
关闭phpstorm错误提示
/**

赞(0) 打赏
未经允许不得转载:菜鸟之家 » phpStorm升级后,会检查一些异常,这种应该怎么解决[2.0]

评论 抢沙发

登录

找回密码

注册