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

Squiz/NonExecutableCode: slew of bug fixes, mostly related to modern PHP #3777

Commits on Mar 14, 2023

  1. Squiz/NonExecutableCode: remove redundant line

    `$prev` is already defined in exactly the same way on line 66. No need to re-define it.
    jrfnl committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    272aa59 View commit details
    Browse the repository at this point in the history

Commits on Mar 15, 2023

  1. Squiz/NonExecutableCode: only ignore inline statements when PHP allow…

    …s them
    
    Aside from `T_EXIT`, PHP (prior to PHP 8.0) does not allow for the inline use of the other tokens this sniff registers.
    While using those tokens inline would result in a parse error, that is not the concern of this sniff.
    
    By ignoring these, the sniff causes false negatives.
    
    This commit makes the sniff more selective and only ignores inline statements for tokens which are allowed in inline statements.
    
    Includes unit test.
    jrfnl committed Mar 15, 2023
    Configuration menu
    Copy the full SHA
    7fc2e87 View commit details
    Browse the repository at this point in the history
  2. Squiz/NonExecutableCode: bug fix - allow for all logic operators

    The sniff, as it was, only allowed for `or` and `||` logical operators before a termination expression, not for `and`, `&&` or `xor`, while PHP allows these too.
    
    See: https://3v4l.org/OWS4n#veol
    
    Fixed now.
    
    Includes unit tests.
    jrfnl committed Mar 15, 2023
    Configuration menu
    Copy the full SHA
    4c094ed View commit details
    Browse the repository at this point in the history
  3. Squiz/NonExecutableCode: bug fix - expressions in ternary

    The `T_EXIT` token can be used in ternaries without affecting code after the ternary expression.
    
    See: https://3v4l.org/oMWuA#veol
    
    Fixed now.
    
    Includes unit test.
    
    Fixes 2857
    jrfnl committed Mar 15, 2023
    Configuration menu
    Copy the full SHA
    2048a01 View commit details
    Browse the repository at this point in the history
  4. Squiz/NonExecutableCode: bug fix - expressions after PHP 7.0/7.4 null…

    … coalesce (equals)
    
    PHP 7.0 introduced the null coalesce operator.
    PHP 7.4 introduced the null coalesce equals operator.
    
    The `T_EXIT` token can be used in combination with those without affecting the code directly following it.
    
    See: https://3v4l.org/C218d#veol
    
    Fixed now.
    
    Includes unit test.
    
    Related to 2857
    jrfnl committed Mar 15, 2023
    Configuration menu
    Copy the full SHA
    b384372 View commit details
    Browse the repository at this point in the history
  5. Squiz/NonExecutableCode: bug fix - expressions in PHP 7.4 arrow funct…

    …ions
    
    PHP 7.4 introduced arrow functions. The `T_EXIT` token can be used in those without affecting the code following it.
    
    See: https://3v4l.org/gSrt4#veol
    
    Fixed now.
    
    Includes unit test.
    jrfnl committed Mar 15, 2023
    Configuration menu
    Copy the full SHA
    c17d7c7 View commit details
    Browse the repository at this point in the history
  6. Squiz/NonExecutableCode: bug fix - PHP 8.0 inline throw expressions

    PHP 8.0 introduced the ability to use `throw` as an expression instead of as a statement.
    Ref: https://wiki.php.net/rfc/throw_expression
    
    When used as an expression, the `throw` does not necessarily affect the code after it.
    
    See: https://3v4l.org/AmMf2
    
    Fixed now.
    
    Includes unit tests.
    
    Fixes 3592
    jrfnl committed Mar 15, 2023
    Configuration menu
    Copy the full SHA
    0f2c50f View commit details
    Browse the repository at this point in the history