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/PHP: fix handling of "DNF look a likes" with switch/case and alternative control structure syntax #632

Merged
merged 1 commit into from
Oct 24, 2024

Commits on Oct 16, 2024

  1. Tokenizer/PHP: fix handling of "DNF look a likes" with switch/case an…

    …d alternative control structure syntax
    
    Follow up on 461, 507, 508
    
    This commit intends to further improve the determination of whether tokens are part of a (return) type declaration which need special handling for the tokens or not.
    
    It does more strenuous checking on any `T_COLON` encountered before the (potential) type, to try and determine with higher accuracy whether the colon indicates the start of a return type - in contrast to being a colon for a switch-case or a colon for an alternative syntax control structure.
    
    Includes tests.
    The tests also include a test with `goto`. This would currently not trigger this code as the colon is tokenized as part of the goto label, but as the intention is to change that tokenization in PHPCS 4.0 (per issue 185), the test being there should safeguard that the PHPCS 4.0 change will not cause any problems with the DNF related tokenization.
    
    For now, this fixes the bug(s) reported in issue 630, though I think it might be good to revisit the tokenizer control flow in a future major, but as that will be so much easier once JS/CSS no longer needs to be taken into account, that's for the future.
    
    Fixes 630
    jrfnl committed Oct 16, 2024
    Configuration menu
    Copy the full SHA
    0c1f4d5 View commit details
    Browse the repository at this point in the history