SublimeLinter-php is not highlighting correctly
abdullahsalma opened this issue · 1 comments
@abdullahsalma the linter is working as intended.
Let me demonstrate…
Write the following code in a file called “test.php”
:
<!--1.--> <?php
/* 2. */
/* 3. */ $files = sprintf("hello");someerror
/* 4. */
/* 5. */
/* 6. */
Then, open a Terminal and execute this command: php -l test.php
You will notice that the linter that is built into the PHP interpreter will print the following error message:
Parse error: syntax error, unexpected end of file in test.php on line 6
Errors parsing test.php
Notice that it says “line 6” and not “line 3”, which is exactly what SublimeLinter-php reports.
Now, modify the test file to include a semicolon in line 6, like so:
<!--1.--> <?php
/* 2. */
/* 3. */ $files = sprintf("hello");someerror
/* 4. */
/* 5. */
/* 6. */;
Then, execute php -l test.php
one more time.
This time, you will not see any errors. Instead you will see this message:
No syntax errors detected in test.php
At this point, you should understand that PHP doesn’t care about empty lines between an expression and the semicolon character that terminates that expression. In this case, PHP interprets “someerror”
as an expression that continues until line 6, and then it finds that you did not write a semicolon to terminate that expression, so it shows an error saying that you missed something at the end, which is line 6.
I am closing this issue as “working as intended”, but feel free to re-open if you want more information.