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.
Text strings can be tokenized as either
T_CONSTANT_ENCAPSED_STRING
or as aT_DOUBLE_QUOTED_STRING
.In the few sniffs which look at text strings, only
T_CONSTANT_ENCAPSED_STRING
s were properly taken into account.This PR fixes that.
The few times the content of the text strings are analysed, we need the pure text - excluding any potential interpolated strings which could be part of a
T_DOUBLE_QUOTED_STRING
-. To that end a new utility function has been introduced which strips variables out of a given string.The new function deals correctly with all but one possible situation, but that specific case will not cause any issues for this PHPCS standard.
PR includes unit tests for the new function containing all possible interpolated variables which will be interpreted by PHP as listed in the manual: http://php.net/manual/en/language.types.string.php
A similar adjustment as is made in this PR for the Mbstring sniff is needed for the PCRE sniff. That will be dealt with in a separate PR once PR #300 has been merged to prevent conflicts.