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

PHP/NoSilencedErrors: implement PHPCSUtils methods #2162

Merged
merged 2 commits into from
Dec 20, 2022

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 19, 2022

PHP/NoSilencedErrors: add extra test

... to cover a previously uncovered condition (and ensure that the configurable $context_length parameter is handled correctly).

PHP/NoSilencedErrors: implement PHPCSUtils methods

As the methods from GetTokensAsString work slightly differently from the PHPCS native File::getTokensAsString() method, this would result in a "one token longer" code snippet. The -1 in the function call in line 225 has been added to prevent this change in behaviour without the need for people to update the context_length property value in their custom ruleset (which would be an unnecessary BC-break).

Functionally, using the GetTokensAsString::compact() method will result in the code snippet in the error message being "cleaner" as those will no longer contain comments found in the code. The PHPCSUtils method will also "compact" the whitespace, so no need for the str_replace() call anymore.

No additional tests added, the existing tests (line 58) already cover this.

Note: it is still the intention for a similar sniff to become available via PHPCSExtra, but that will be in a later release.

... to cover a previously uncovered condition (and ensure that the configurable `$context_length` parameter is handled correctly).
As the methods from `GetTokensAsString` work slightly differently from the PHPCS native `File::getTokensAsString()` method, this would result in a "one token longer" code snippet. The `-1` in the function call in line 225 has been added to prevent this change in behaviour without the need for people to update the `context_length` property value in their custom ruleset (which would be an unnecessary BC-break).

Functionally, using the `GetTokensAsString::compact()` method will result in the code snippet in the error message being "cleaner" as those will no longer contain comments found in the code. The PHPCSUtils method will also "compact" the whitespace, so no need for the `str_replace()` call anymore.

No additional tests added, the existing tests (line 58) already cover this.

Note: it is still the intention for a similar sniff to become available via PHPCSExtra, but that will be in a later release.
Copy link
Member

@GaryJones GaryJones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dingo-d dingo-d merged commit 169a704 into develop Dec 20, 2022
@dingo-d dingo-d deleted the feature/nosilencederrors-use-phpcsutils branch December 20, 2022 08:49
@jrfnl jrfnl mentioned this pull request Jan 7, 2023
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants