tomtom / checksyntax_vim

Check a file's syntax when saving a file (php, ruby, tex ...) with vim
http://www.vim.org/scripts/script.php?script_id=1431
GNU General Public License v3.0
94 stars 9 forks source link

Close issue #7 - duplicate PHP errors #11

Closed fidian closed 12 years ago

fidian commented 12 years ago

Test PHP file: <?php blah(;

php -l test.php works as expected. When you use php -l -d display_errors=1, the warnings get duplicated.

tomtom commented 12 years ago

The display_errors flag was included by artnez (https://github.com/tomtom/checksyntax_vim/commit/a55196c6a866f3710c8a073b6d3dae4c2a28fc93). I don't know the reasons why he added this command line option -- it seems to be the default value for php < 5.2.4 anyway. From what I gather, it causes php to print error messages on stdout. I don't have php accessible, are the error messages also printed on stderr?

It seems the value for this option has changed. Does the problem persist if you run php -l -d display_errors=stdout (php >= 5.2.4)?

fidian commented 12 years ago

Yes, they persist, and yes, they are on both stdout and stderr.

13:28 bay:~$ php -l -d display_errors=stdout test.php PHP Parse error: syntax error, unexpected ';', expecting ')' in test.php on line 2

Parse error: syntax error, unexpected ';', expecting ')' in test.php on line 2

Errors parsing test.php 13:28 bay:~$ php -l -d display_errors=stdout test.php > /dev/null PHP Parse error: syntax error, unexpected ';', expecting ')' in test.php on line 2 13:28 bay:~$ php -l -d display_errors=stdout test.php 2> /dev/null

Parse error: syntax error, unexpected ';', expecting ')' in test.php on line 2

Errors parsing test.php 13:28 bay:~$ php --version PHP 5.3.14-0ppa1p with Suhosin-Patch (cli) (built: Jun 15 2012 21:09:17) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans with test_helpers v1.0.1-dev, Copyright (c) 2009-2010, by Johannes Schlueter, Scott MacVicar, Sebastian Bergmann 13:28 bay:~$

tomtom commented 12 years ago

I think this explains that behaviour: http://stackoverflow.com/questions/10771959/unexpected-error-reporting-behavior-in-cli-binary

fidian commented 12 years ago

In light of the page you found, perhaps you should also add "-d error_log=" (i.e. set error_log to an empty value) so that the messages are never doubled, no matter what type of installation you have?