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

New Universal.ControlStructures.DisallowLonelyIf sniff #85

Merged
merged 1 commit into from
Feb 28, 2021

Commits on Feb 28, 2021

  1. ✨ New Universal.ControlStructures.DisallowLonelyIf sniff

    Sniff to disallow `if` statements as the only statement in an `else` block.
    
    Inspired by the [ESLint "no lonely if"](https://eslint.org/docs/rules/no-lonely-if) rule in response to upstream PHPCS issue 3206.
    
    The sniff, as well as the fixer, will handle both curly brace if/else control structures as well as alternative syntax - if/else/endif - control structures correctly.
    Inline control structures, i.e. without curly braces and not using alternative syntax, will be ignored by the sniff.
    
    Note: This sniff will not fix the indentation of the "inner" code. It is strongly recommended to run this sniff together with the `Generic.WhiteSpace.ScopeIndent` sniff to get the correct indentation.
    
    Includes fixer.
    Includes unit tests.
    Includes documentation.
    jrfnl committed Feb 28, 2021
    Configuration menu
    Copy the full SHA
    8fc9ad1 View commit details
    Browse the repository at this point in the history