views:

49

answers:

4

Hello,

I have seen the bellow question and was wondering if there is something like it for eclipse.

Also how can I make sure that this kind of errors get's thrown into my trigger error function so that I can write it to a log.

Thank you for any help.

http://stackoverflow.com/questions/2534176/identifying-php-unused-variables-in-emacs

A: 

Have you tried PMD Eclipse yet? According to my colleagues it is a pretty handy tool.

BaumS
PMD is AFAIK only for Java, not PHP but a great tool indeed
DrColossos
+1  A: 

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 sidenote :

  • Unused variables (i.e. variables than get assigned a value, and are never used again) are not a problem in PHP -- so, they are not reported as error nor anything by PHP itself
  • On the other hand, undeclared variables (i.e. variables that are being read from, while no value was assigned to them before) are not that good -- so, they are reported a notices by the PHP engine.

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 :

  • You have to enable error_reporting, and configure it so it report E_NOTICE
  • You can then have those reports either :

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...

Pascal MARTIN
A: 

You may be interessed in http://qualityassuranceinphpprojects.com/pages/tools.html that deals with testing/QA/CI/... and many other topics. PMD, PHP_CodeSniffer that have already been mentioned are as well in there as are many others

DrColossos
A: 

Netbeans IDE (I switched from eclipse pdt last month) identifies and shows warning about unused and uninitialized methods, variables etc.

Osman Üngür