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.
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 theSyntaxError::getNormalizedMessage()
method should only be passed astrue
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.