php-parallel-lint / PHP-Parallel-Lint

This tool check syntax of PHP files faster than serial check with fancier output.
Other
287 stars 21 forks source link

Tests: add dedicated test for the SyntaxError::translateTokens() method + edge case bug fix #117

Closed jrfnl closed 2 years ago

jrfnl commented 2 years ago

Tests: add dedicated test for the SyntaxError::translateTokens() method

This safeguards and documents the current behaviour of the method.

SyntaxError::translateTokens(): prevent double translation

Generally speaking, the $translate parameter for the SyntaxError::getNormalizedMessage() method should only be passed as true when on a PHP version which doesn't do the PHP native token translation yet.

However, in edge cases, it could be possible that tokens could be double "translated", both by PHP itself as well as by the SyntaxError::translateTokens() method.

This minor fix prevents this by not matching token names when surrounded by parentheses.

Includes additional unit tests.