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

3.0: Move "interpolated variable" related utilities to dedicated TextStringHelper #2051

Merged
merged 1 commit into from
May 16, 2022

Commits on May 16, 2022

  1. Move "interpolated variable" related utilities to dedicated `TextStri…

    …ngHelper`
    
    The "interpolated variable" related utilities are only used by a small set of sniffs, so are better placed in a dedicated class.
    
    This commit moves the `REGEX_COMPLEX_VARS` constant, the `get_interpolated_variables()` method and the `strip_interpolated_variables()` method to a new `WordPressCS\WordPress\Helpers\TextStringHelper` and starts using that class in the relevant sniffs.
    
    In contrast to some of the other "move methods out of the Sniff class" PRs, these methods have been moved to a class and made `static` - instead of moved to a `trait`.
    The reason for this difference is that the methods in other "moves" are setting properties which the sniff classes would need access to, while these methods are 100% stand-alone.
    
    **Note**:
    It is expected for PHPCSUtils to have dedicated methods for the same at some point in the future. If/when those methods become available, it is recommended for the sniffs to start using the PHPCSUtils methods and for this class to be deprecated and removed in the next major release.
    
    Also note that PHP 8.2 will be making changes to the kind of interpolation supported by PHP. This will need further investigation at a future point in time (probably in PHPCSUtils rather than here), if nothing else to ensure that what was supported in PHP prior to PHP 8.2 is fully supported by these methods (which is probably not the case at this moment).
    Ref: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
    
    Related to 1465
    jrfnl committed May 16, 2022
    Configuration menu
    Copy the full SHA
    76f3376 View commit details
    Browse the repository at this point in the history