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/DisallowLongArraySyntax: improve code coverage #455

Commits on May 14, 2024

  1. Generic/DisallowLongArraySyntax: move an intentional parse error test

    This commit moves an intentional parse error test to its own file. The
    parse error test did not trigger
    DisallowLongArraySyntaxSniff::process() as this sniff listen for
    T_ARRAY and the `array` keyword without parentheses is tokenized by
    PHPCS as T_STRING.
    
    Removing the semicolon fixes that and makes the test effective.
    rodrigoprimo authored and jrfnl committed May 14, 2024
    Configuration menu
    Copy the full SHA
    a0c505e View commit details
    Browse the repository at this point in the history
  2. Generic/DisallowLongArraySyntax: simplify if statement

    This commit uses a single isset() to check if two variables are set
    instead of using two isset() calls.
    rodrigoprimo authored and jrfnl committed May 14, 2024
    Configuration menu
    Copy the full SHA
    8c09939 View commit details
    Browse the repository at this point in the history
  3. Generic/DisallowLongArraySyntax: remove unreachable condition

    A check was added to the top of the file in 8d2a9dd to return an error
    early if the array is missing an opening and/or a closing parenthesis.
    This means that `$opener` can never be null as when the code reaches the
    point where this variable is set,
    `$tokens[$stackPtr]['parenthesis_opener']` cannot be null.
    rodrigoprimo authored and jrfnl committed May 14, 2024
    Configuration menu
    Copy the full SHA
    2000a32 View commit details
    Browse the repository at this point in the history
  4. Generic/DisallowLongArraySyntax: improve code coverage

    This commit adds two safeguard tests that do not trigger the sniff as
    they use the array keyword in a method definition and a method call.
    
    It also updates one of the existing tests to declare an array using
    array in uppercase. This is already handled correctly by PHPCS but it
    was not documented in a test.
    rodrigoprimo authored and jrfnl committed May 14, 2024
    Configuration menu
    Copy the full SHA
    e1f0e46 View commit details
    Browse the repository at this point in the history