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

Generic/DisallowYodaConditions: improve code coverage #465

Merged

Commits on May 13, 2024

  1. Generic/DisallowYodaConditions: various minor cleanup

    * Remove unused variable.
    * Fix typo in code comment.
    * Remove incorrect code comment.
    rodrigoprimo authored and jrfnl committed May 13, 2024
    Configuration menu
    Copy the full SHA
    e0b9580 View commit details
    Browse the repository at this point in the history
  2. Generic/DisallowYodaConditions: improve code coverage

    Includes removing two unreachable conditions
    
    The first condition is unreachable because PHPCS will never call
    DisallowYodaConditionsSniff::process() if there is no non-empty token before a
    comparison token. Even if the file contains a syntax error, there must
    be at least a PHP opening tag before the comparison token for the method
    to be called.
    
    The second condition is unreachable because at this point in the code
    there will always be at least two non-empty tokens before the comparison
    token. If there is only one, it must be a PHP opening tag and, in this
    case, the method will bail before reaching the code that sets the
    `$prevIndex` variable.
    
    This commit also documents why a certain line is uncovered by tests - and cannot be
    covered, nor can it be removed as external sniffs may call
    `DisallowYodaConditionsSniff::isArrayStatic()` directly.
    rodrigoprimo authored and jrfnl committed May 13, 2024
    Configuration menu
    Copy the full SHA
    fd9d74e View commit details
    Browse the repository at this point in the history
  3. Generic/DisallowYodaConditions: rename variable

    This commit renames a variable to use a better name that actually
    matches what the variable contains. The previous name was misleading as
    the variable did not contain the index of the closing parenthesis.
    rodrigoprimo authored and jrfnl committed May 13, 2024
    Configuration menu
    Copy the full SHA
    48a1a43 View commit details
    Browse the repository at this point in the history