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

Tokenizer: apply tab replacement to heredoc/nowdoc opener #585

Merged

Commits on Aug 4, 2024

  1. Tokenizer: apply tab replacement to heredoc/nowdoc opener

    _You learn something new every day ;-)_
    
    While probably exceedingly rare to be found in actual codebases, the PHP tokenizer apparently allows for whitespace between the `<<<` and the heredoc/nowdoc identifier. See: https://3v4l.org/NUHZd
    
    Both spaces as well as tabs are allowed. New lines are not allowed. Comments are also not allowed. See: https://3v4l.org/7PIEK
    
    The PHPCS `Tokenizer` did not execute tab replacement on these tokens leading to unexpected `'content'` and incorrect `'length'` values in the `File::$tokens` array, which in turn could lead to incorrect sniff results and incorrect fixes.
    
    This commit adds the `T_START_HEREDOC`/`T_START_NOWDOC` tokens to the array of tokens for which to do tab replacement to make them more consistent with the rest of PHPCS.
    
    Includes unit tests safeguarding this change.
    
    Ref: https://externals.io/message/124462#124518
    jrfnl committed Aug 4, 2024
    Configuration menu
    Copy the full SHA
    51278fd View commit details
    Browse the repository at this point in the history