Skip to content

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

Development

Successfully merging this pull request may close these issues.

2 participants