PhpStorm:针对“名称与其类相同的方法将不是构造函数"获取代码检查警告. [英] PhpStorm: get code inspection warnings for "Methods with the same name as their class will not be constructors"

查看:164
本文介绍了PhpStorm:针对“名称与其类相同的方法将不是构造函数"获取代码检查警告.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我终于切换到了PHP7.我的代码有点旧,将被翻新.一些问题是:

Okay I've finally switched to PHP7. My code is a bit old and will be refurbished. Some of the problems are:

class MagicClass
    function MagicClass(){
        //etc
    }

在执行过程中会发出弃用警告:

Which gives an deprecation warning during execution:

已弃用:与类同名的方法将不被使用 PHP的未来版本中的构造函数; MagicClass已弃用

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; MagicClass has a deprecated constructor in

这很好:

class MagicClass
    function __construct(){
        //etc
    }


如何获取PhpStorm代码检查以警告当前代码库中的此类错误?


How can I get PhpStorm code inspection to warn me for such errors in my current codebase?

推荐答案

PhpStorm v10似乎不支持这种特定情况.它具有"PHP 7兼容性"检查,但不会以任何方式标记此代码(无论您选择的PHP语言级别是5.6还是7).

It does not look like PhpStorm v10 supports this specific case. It has "PHP 7 Compatibility" inspection but it does not flag this code in any way (regardless what PHP Language Level you choose -- be it 5.6 or 7).

解决方案是安装"Php检查(EA扩展)"插件-它具有这种检查功能,即使您选择5.x作为PHP语言级别,它也可以使用.

The solution is to install "Php Inspection (EA Extended)" plugin -- it has such inspection and it will work even if you choose 5.x as PHP Language level.

请注意::此插件有很多检查,您可能会认为其中的一些错误/无用等..因此,您可能需要仔细研究此插件提供的其他所有检查,并如果需要,请禁用它.

Please note: this plugin has a lot of inspections, some of which you may consider wrong/useless etc .. so you may have a need to go trough each additional inspection provided by this plugin and disable it if needed.

这篇关于PhpStorm:针对“名称与其类相同的方法将不是构造函数"获取代码检查警告.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆