Anyone with excess time and skill on their hands? Would be awesome to see a port of jslint to PHP (and Perl / Python / Ruby for that matter). There’s probably some issues with multibyte strings to contend with but browsing the source it looks doable.
It would mean is tools like Simple Test could help validate Javascript on a page they’re. Simple Test comes with it’s own regex-based parsing tools, which I introduced briefly here. Whether regexes are the right way to go though is another question, bearing in mind character encoding issues.
Related posts:
- Are PHP Namespaces Really So Bad? Namespaces have caused a divide amongst developers who either love...
- Server-side JavaScript Will Be as Common as PHP Despite the fact that JavaScript has been typecast as the...
- Introducing php-tracer-weaver php-tracer-weaver is a tool for automatically generating docblock comments, with...
- Free PHP Webinar: How to Increase Performance with Caching Zend are running a free webinar today, with a live...







Okay, JavaScript. But it would be even cooler to have a lint-y thing for PHP, like pychecker for Python, http://pychecker.sourceforge.net/
Anyone up to it, or is there already such a thing?
October 6th, 2004 at 1:59 pm
Kinda cool.. wouldn’t be easy to do.
October 6th, 2004 at 6:37 pm
Since PHP4, there has been the -l (thats a lower case L) flag for the PHP binary, L standing for Lint, it’ll find parse errors.
In PHP5, there is the nice userland function php_check_syntax() [http://www.php.net/manual/en/function.php-check-syntax.php]
- Davey
October 6th, 2004 at 6:55 pm
Why would you want to go to the trouble of creating a checker for PHP? PHP comes with a syntax checker built in…
php -l filename.php
(that’s a lowercase L by the way). The CLI version has a lint command built into it. If you want to create a web based interface for something like SimpleTest, all you need to do is run it as a system command to check for errors.
A multi-language lint would be better. Seeing as php scripts can contain js, php, html, xml, etc, you’d really want the lint check to be able to detect which language it is parsing at the time. I think I’ll just chuck that idea in the too hard basket though.
October 6th, 2004 at 7:16 pm
I’m willing to give it a go when I find some spare time. Good chance for me to finally look at some of the strange OO syntax for JS in a bit more detail.
October 6th, 2004 at 7:33 pm
I was refering to the jslint port, not the uberlint I hinted at before.
October 6th, 2004 at 7:34 pm
There’s a new function in PHP: php_check_syntax.
October 7th, 2004 at 3:20 am
php_check_syntax still has a bug, though. It executes the code as well as checking it, so any errors will still… cause errors.
October 8th, 2004 at 8:20 am
The php -l is also buggy.
For example if you have:
It will return that the syntax is ok. But when you execute that you get the error.
July 25th, 2008 at 6:26 pm