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

No unneeded ternary check? #1291

Closed
dingo-d opened this issue Jan 25, 2018 · 2 comments
Closed

No unneeded ternary check? #1291

dingo-d opened this issue Jan 25, 2018 · 2 comments
Assignees
Labels
Focus: Code analysis Sniffs to prevent common mistakes and improve code in general

Comments

@dingo-d
Copy link
Member

dingo-d commented Jan 25, 2018

When using ternary can we have a check that will see if the ternary is needed or not? ESLint uses this rule. This would be thrown when we want to store boolean in a variable. For instance

<?php

$var = 'a';
// Example of an unneeded ternary:
$bla = $var === 'a' ? true : false;

// Can be written as:
$bla = $var === 'a';

Don't know if we have this or not (since I'm not getting warnings I'm guessing we don't have it).

Also, I've stumbled into this: https://www.drupal.org/project/drupal/issues/1838368

Would this be useful to have as a rule?

@jrfnl jrfnl added the Focus: Code analysis Sniffs to prevent common mistakes and improve code in general label Apr 1, 2019
@dingo-d dingo-d self-assigned this Jul 21, 2019
@jrfnl
Copy link
Member

jrfnl commented Jul 22, 2019

Also, I've stumbled into this: https://www.drupal.org/project/drupal/issues/1838368

As stated in various comments in that thread, the memory leak issue which that ticket refers to was fixed in PHP 5.4, so IMO is quite irrelevant.

@dingo-d
Copy link
Member Author

dingo-d commented Dec 9, 2022

We'll move this to the PHPCSExtra ruleset in the future: PHPCSStandards/PHPCSExtra#157

@dingo-d dingo-d closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Focus: Code analysis Sniffs to prevent common mistakes and improve code in general
Projects
None yet
Development

No branches or pull requests

2 participants