识别 PHP 未使用的变量
我看到了下面的问题,想知道 Eclipse 是否有类似的东西。
另外,我如何确保这种错误被抛出到我的触发错误函数中,以便我可以将其写入日志。
I have seen the below question and was wondering if there is something like it for Eclipse.
Also, how can I make sure that this kind of errors gets thrown into my trigger error function, so that I can write it to a log.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不确定它是否可以报告未使用的变量,但是 PHP_CodeSniffer 很好用用于检测 PHP 源代码中的问题。
尽管如此,它仍然是一个命令行工具,并且没有集成在 Eclipse PDT 中...
As a side note:
您链接到的帖子讨论的是第二种,而不是第一种。
To get undeclared/uninitialized variables reported by the PHP engine:
error_reporting< /code>
,并对其进行配置,使其报告
E_NOTICE
display_errors
log_errors
但是,这里也没有集成在 Eclipse 中——我从未见过一个可以解析 PHP 错误日志并将通知推送到 Eclipse 的工具...
Not sure it can report unused variables, but PHP_CodeSniffer is nice when it comes to detecting problems in PHP source code.
Still, it's a command-line tool, and it's not integrated in Eclipse PDT...
As a side note:
The post you are linking to is talking about the second kind, and not the first one.
To get undeclared/uninitialized variables reported by the PHP engine:
error_reporting
, and configure it so it reportE_NOTICE
display_errors
log_errors
But, here too, this is not integrated in Eclipse -- and I've never seen a tool that would parse the PHP error log, and push the notices to Eclipse...
NetBeans IDE(我从 Eclipse PDT 上个月)识别并显示有关未使用和未初始化的方法、变量等的警告。
The NetBeans IDE (I switched from Eclipse PDT last month) identifies and shows warning about unused and uninitialized methods, variables, etc.
您尝试过 PMD Eclipse 吗?
据我的同事说,这是一个非常方便的工具。
Have you tried PMD Eclipse yet?
According to my colleagues it is a pretty handy tool.
安装 PDT 扩展。
从 Eclipse (PDT) 主菜单中,选择帮助 → < em>安装新软件。
然后在“使用”编辑框中输入上述 URL。单击添加。选中“PDT 扩展”复选框。单击下一步...
Install PDT Extensions.
From the Eclipse (PDT) main menu, select Help → Install New Software.
Then enter the above URL in the 'Work with' edit box. Click Add. Check the 'PDT Extensions' checkbox. Click Next...