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

Parentheses: recognize more parentheses owners #215

Merged
merged 1 commit into from
Sep 20, 2020

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 20, 2020

PHPCS natively does not consider isset(), unset(), empty(), exit(), die() and eval() as parentheses owners.

As of now, the methods in the PHPCSUtils Parentheses class will.

If effect, this means you can now check whether an arbitrary token is within an isset(), unset() or empty() call by calling:

if (Parentheses::hasOwner($phpcsFile, $stackPtr, [\T_ISSET, \T_UNSET, \T_EMPTY]) !== false) {
    // Do something.
}

Related issue upstream: squizlabs/PHP_CodeSniffer#3118

PHPCS natively does not consider `isset()`, `unset()`, `empty()`, `exit()`, `die()` and `eval()` as parentheses owners.

As of now, the methods in the PHPCSUtils `Parentheses` class will.

If effect, this means you can now check whether an arbitrary token is within an `isset()`, `unset()` or `empty()` call by calling:
```php
if (Parentheses::hasOwner($phpcsFile, $stackPtr, [\T_ISSET, \T_UNSET, \T_EMPTY]) !== false) {
    // Do something.
}
```

Related issue upstream: squizlabs/PHP_CodeSniffer#3118
@jrfnl jrfnl added this to the 1.0.0-alpha4 milestone Sep 20, 2020
@jrfnl jrfnl merged commit ee7baa5 into develop Sep 20, 2020
@jrfnl jrfnl deleted the parentheses/recognize-more-constructs-as-owners branch September 20, 2020 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant