maralla / validator.vim

Check syntax on the fly asynchronously.
MIT License
213 stars 14 forks source link

php linter #32

Closed ghost closed 8 years ago

ghost commented 8 years ago

DISCLAIMER: I'm not a python developer, and I've never wrote python code before

I'm just a web developer who really likes this plugin. I've tried to add the support for the php build-in linter (php -l file.php).

I've created a class Php looking at the other linter. Unfortunately, when I open php files in vim (even with obvious syntax error) and nothings happens.

I've tested the regexp online at pythex.org and it seems to work.

// test.php
<?php

echo "GHJK" // missing semicolon

echo $FFFF;

if ($test) {
    echo "YAY" // missing semicolon
    // "php -l file.php" return only the first error found
}

Example of output:

$ php -l test.php
PHP Parse error:  syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in test.php on line 5

Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting ',' or ';' in test.php on line 5

Errors parsing test.php

example of the output at pythex.org

What could be done to make this works?

maralla commented 8 years ago

I tested with your test.php and it works. Maybe the file type is not detected by vim so the linter class may not be loaded. Set the file type manually when you open that php file with :set ft=php and save the file with :w or put //vim:ft=php in the beginning line of test.php and open it again.

ghost commented 8 years ago

It's something related to my vimrc.

I've tried with an empty vimrc and I can confirm it works!