Skip to content

[New Rule] Multiple isset statements SHOULD be combined into one #27

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

Closed
lenaorobei opened this issue Jan 31, 2019 · 3 comments
Closed
Labels
need to discuss Rule requires discussion new rule New feature implementation proposal New rule proposal

Comments

@lenaorobei
Copy link
Contributor

lenaorobei commented Jan 31, 2019

Rule

Multiple isset statements SHOULD be combined into one.

Reason

Just the code style question aimed to make the codebase consistent.

Bad example:

if (isset($a) && isset($b) && isset($c)) {
    // code goes here
}

Good example:

if (isset($a, $b, $c)) {
    // code goes here
}

Implementation

Check for multiple isset statements combined with && inside one condition.

@lenaorobei lenaorobei added proposal New rule proposal need to discuss Rule requires discussion new rule New feature implementation labels Jan 31, 2019
@buskamuza
Copy link

As for me, it's OK to have both styles. There can be use cases with if (isset($a) && empty($b)), and in this case it looks more consistent with the bad example.
If many people vote that this sniff can improve readability of the code, let it be. Otherwise I would not restrict this.

@ravmenon
Copy link

For extensions, this should be only a low severity (style) warning as the first idiom is very common.

@lenaorobei
Copy link
Contributor Author

No updated and votes here, so both styles are ok.
No need to enforce.

sivaschenko added a commit to sivaschenko/magento-coding-standard that referenced this issue Aug 25, 2021
…magento-coding-standard-229

[Imported] AC-939: Create unit test for Magento2\Less\AvoidIdSniff check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need to discuss Rule requires discussion new rule New feature implementation proposal New rule proposal
Projects
None yet
Development

No branches or pull requests

3 participants