SublimeLinter/SublimeLinter-php

Wrong highlight when parentheses in string

CodeBrauer opened this issue · 2 comments

bildschirmfoto 2016-09-30 um 17 26 27
bildschirmfoto 2016-09-30 um 17 30 55

$res_ids_query = str_replace('count(*)', 'DISTINCT field', $query));
//                                   ^ --- shows error here        
//                                           actual error here ---^

This happens only with single quotes ' and not with double quotes "

Unfortunately I am pretty sure the issue here is that php -l doesn't provide any column information for errors that it finds. Thus SublimeLinter-php is making its best guess about where on the line the error occurs. In this case when it gets a message back from php -l that states Parse error: syntax error, unexpected ')' in <file> on line 167 it performs a regular expression match to find ")" on line 167. That is all the information it has to go off of. I am open to suggestions for how to make this better but given those two pieces of information, the line number and "unexpected" string, I am not sure how it can be much better.

@ajmichels Thanks for your feedback!

Thus SublimeLinter-php is making its best guess about where on the line the error occurs.

Wouldn't it be possible to extend the regexp to find the next occurrence that is not in a string?

Edit: This would be an bad idea - maybe it screws up even more functions... But thanks for the explanation - I thought this could be an easy fix.