TextStrings::getCompleteTextString(): split into three methods #320
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_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 theTextStrings::getCompleteTextString()
method.Includes:
GetCompleteTextString3604Test
toGetEndOfDoubleQuotedStringTest
.