Is there a static code analyzer [like Lint] for PHP files?

For static analysis, there are php-sat php-ast PHP_Depend and PHP_CodeSniffer that I know of. These are fairly high level tools; You can also dabble in stuff like PHP_Parser or the more primitive token_get_all function. Finally, you can also run php in lint-mode ( php -l FILENAME ), from the command line.It will check the file for valid syntax (eg.

Parse it), but won't execute it.

For static analysis, there are php-sat, php-ast, PHP_Depend and PHP_CodeSniffer, that I know of. These are fairly high level tools; You can also dabble in stuff like PHP_Parser or the more primitive token_get_all function. Finally, you can also run php in lint-mode (php -l FILENAME), from the command line.It will check the file for valid syntax (eg.

Parse it), but won't execute it. There are also some runtime analysis options, which are more useful for some things, because of PHPs dynamic nature. Xdebug has a few nifty features, such as code coverage and function traces.

Just recently, I put a small tool together, using a combined static/dynamic approach, which builds on xdebugs function traces. And of course, there are phpdoc and doxygen, which both perform a kind of code analysis (Doxygen can be configured to render nice inheritance graphs with graphviz) A recent newcomer is xhprof, which can do much of the same things as xdebug, but the extension is more lightweight, making it better suitable for running on a production server, and it includes a nice php-based interface.

PHP_CodeSniffer is easy to install and easy to use. :) – mcandre Aug 1 '11 at 1:30 I know this is an answered question, but still, using php -l like this: find /your/path -name '*. Php' | xargs -r php -l is not working reliably.It often misses files with syntax errors in them.

– dimitko Aug 24 '11 at 10:38 PHP_CodeSniffer looked very nice to me at the start, but I couldn't for the life of me make it NOT show indentations "errors". It seems it ignores the --error-severity option entirely. – dimitko Aug 24 '11 at 10:51.

Online PHP lint PHPLint Unitialized variables check. Link 1 and 2 already seem to do this just fine, though. I can't say I have used any of these intensively, though :).

For completeness -- also check phpCallGraph.

Thanks - Didn't know about that one. – troelskn Dec 19 '08 at 17:20.

There a new tool called nWire for PHP. It is a code exploration plugin for Eclipse PDT and Zend Studio 7.x. It enables real-time code analysis for PHP and provides the following tools: Code visualization - interactive graphical representation of components and associations.

Code navigation - unique navigation view shows all the associations and works with you while you write or read code. Quick search - search as you type for methods, fields, file, etc.

Its not answer for question. Like answer exist netbeans etc.. – Yosef Apr 22 '11 at 12:25.

See Semantic Designs' CloneDR, a "clone detection" tool that finds copy/paste/edited code. It will find exact and near miss code fragments, inspite of whitespace, comments and even variable renamings. A sample detection report for PHP can be found at the wesite.(I'm the author).

1 for "I'm the author" – Flavius Mar 18 '11 at 16:57 Looking at the site, that seems like an incredible tool. I will be taking a closer look later! Thanks for the link (+1 for "I'm the author" as well) – Eric Cope Oct 29 '11 at 17:53.

PHP PMD (project mess detector) and PHP CPD (copy paste detector) as the former part of PHPUnit.

The NetBeans IDE checks for syntax errors, unusued variables and such. It's not automated, but works fine for small or medium projects.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions