在PHPStorm中查找未使用的公共和受保护的方法 [英] Find unused public and protected methods in PHPStorm

查看:259
本文介绍了在PHPStorm中查找未使用的公共和受保护的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHPStorm具有方便的未使用的私有方法 检查,它可以毫无疑问地检测出未使用的方法.

PHPStorm has a handy unused private method inspection, which detects methods that are without doubt not used.

有时我也会对我的项目进行扫描,以查找未使用的公共/受保护方法.我知道这不是一门精确的科学,它会报告可能在该项目之外使用的方法(例如,在图书馆的情况下),但是需要进行人工审查,这可能非常有用.

I would sometimes be interested to scan my project for unused public/protected methods as well. I'm aware that this is not an exact science, and that would report methods that might be used outside this project (in the case of a library, for example), but subject to a manual review, that would probably be very useful.

PHPStorm目前可以做到这一点吗?

Is this currently possible with PHPStorm?

推荐答案

以前曾提出过此要求,并且自PhpStorm 2019.1 EAP#6起可能实现(请参阅

It was requested previously, and thanfully is possible since PhpStorm 2019.1 EAP #6 (see here for details).

您可以仅使用此检查来创建新的检查配置文件,并使用检查代码... 然后在您的应用中查找所有无效代码.请注意,通过此检查,您可以显式设置是否要报告字段,方法等以及可见性级别,甚至可以设置入口点!

You can create a new inspection profile with only this inspection, and use Inspect code... then to find all dead code in your app. Note that this inspection allows you to explicitly set if you want to report fields, methods etc., with what visibility level, and to even set entry points!

这篇关于在PHPStorm中查找未使用的公共和受保护的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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