Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Apr 19, 2022

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Apr 5, 2022

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.

@jrfnl jrfnl added this to the 2.0.0 milestone Apr 5, 2022
@jrfnl jrfnl added the Type: bug label Apr 5, 2022
…thod

This safeguards and documents the current behaviour of the method.
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.
@jrfnl jrfnl force-pushed the feature/new-test-syntax-error-translatetokens branch from b70c37e to 2c1f747 Compare April 8, 2022 11:44
@jrfnl jrfnl marked this pull request as ready for review April 8, 2022 11:47
@jrfnl jrfnl requested a review from grogy April 8, 2022 11:47
@grogy grogy merged commit a93187e into develop Apr 19, 2022
@grogy grogy deleted the feature/new-test-syntax-error-translatetokens branch April 19, 2022 12:36
@jrfnl jrfnl modified the milestones: 2.0.0, 1.3.x Next Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants