Reputation: 851
I'm looking for a php syntax checker, preferably as an eclipse plugin, preferably be able to sort of compile it(at least find undefined variables in addition to syntax checking. Does such thing exist?
Upvotes: 2
Views: 3694
Reputation: 95354
Our PHP Formatter parses PHP code to an AST, and then prettyprints the results. This can be used as a command-line script. If the source file isn't parsable, the tool exits with with an error (and doesn't prettyprint). So, if you ignore the prettyprint feature, this is precisely a command-line level syntax checker. Easy to launch from Eclipse.
Upvotes: 0
Reputation: 20045
In PHP there is no such thing as an undefined variable. Variables are automatically initialized with null.
Upvotes: 0
Reputation: 142
Of course, look on this: http://www.eclipse.org/pdt/
This IDE using php parser engine to syntax, and is for free :-). But, better do not use the plugin version from update site, but All-In-One Package. At least previous versions from update site did not work too well...
Upvotes: 1
Reputation: 131891
Every better IDE (PhpStorm, Eclipse/PDT, Eclipse/PHPEclipse, Netbeans with PHP-Plugin, and so on) comes with automatic syntax check built-in. At least PhpStorm is able to find undefined variables. The last time I used PDT it didn't support it. PHPEclipse seems to be not maintained anymore, so I assume, that it cannot find undefined variables too, and netbeans ... don't know.
If you just want to check the syntax the quick&dirty way, you can use the php-interpreter itself
php -l filename.php
Upvotes: 2