TextStrings::getCompleteTextString(): split into three methods#320
Merged
TextStrings::getCompleteTextString(): split into three methods#320
Conversation
This commit splits the `TextStrings::getCompleteTextString()` method into three distinct methods:
* `TextStrings::getCompleteTextString()` will still retrieve the complete text of a potentially multi-line text string (no BC-break).
* `TextStrings::getEndOfCompleteTextString()` can be used to retrieve the last token for a potentially multi-line text string.
This method should be preferred when the sniff wants to "skip over" the additional tokens in the text string as part of its process logic.
* `TextStrings::getEndOfDoubleQuotedString()` to specifically handle the PHPCS bug identified and reported in squizlabs/PHP_CodeSniffer 3604.
This method is useful when a sniff does want to examine each `T_DOUBLE_QUOTED_STRING` token individually as they _should_ have been tokenized and will allow for reporting issues on the correct line, while this would be much more difficult when using the `TextStrings::getCompleteTextString()` method.
Includes:
* Renaming the `GetCompleteTextString3604Test` to `GetEndOfDoubleQuotedStringTest`.
* Additional tests documenting and safeguarding the handling of problem embeds in multi-line text strings.
* Additional tests covering the "new" parts of this code change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit splits the
TextStrings::getCompleteTextString()method into three distinct methods:TextStrings::getCompleteTextString()will still retrieve the complete text of a potentially multi-line text string (no BC-break).TextStrings::getEndOfCompleteTextString()can be used to retrieve the last token for a potentially multi-line text string.This method should be preferred when the sniff wants to "skip over" the additional tokens in the text string as part of its process logic.
TextStrings::getEndOfDoubleQuotedString()to specifically handle the PHPCS bug identified and reported in Tokenizer/PHP: bug fix for double quoted strings using${squizlabs/PHP_CodeSniffer#3604.This method is useful when a sniff does want to examine each
T_DOUBLE_QUOTED_STRINGtoken individually as they should have been tokenized and will allow for reporting issues on the correct line, while this would be much more difficult when using theTextStrings::getCompleteTextString()method.Includes:
GetCompleteTextString3604TesttoGetEndOfDoubleQuotedStringTest.