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

Review analysis of text strings #314

Merged
merged 3 commits into from
Jan 1, 2017

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Dec 24, 2016

Text strings can be tokenized as either T_CONSTANT_ENCAPSED_STRING or as a T_DOUBLE_QUOTED_STRING.
In the few sniffs which look at text strings, only T_CONSTANT_ENCAPSED_STRINGs 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.

Review checked that text string tokens were dealt with correctly.
@coveralls
Copy link

coveralls commented Dec 24, 2016

Coverage Status

Coverage increased (+0.009%) to 96.734% when pulling bd1a5e1 on jrfnl:feature/review-text-strings into e1af2c3 on wimg:master.

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