User tests: Successful: Unsuccessful:
Simple code clean-up. This shouldn't impact Joomla's behaviour in any way.
Code removed was redundant, as the operator already returns either true
or false
.
Labels |
Added:
?
|
I agree that this code doesn't make sense as is and your change works of course.
I wonder if we could leave the brackets there. It's not needed from a technical point but imho would increase readability of code. Like this:
self::$mode_sef = ($router->getMode() == JROUTER_MODE_SEF);
What do you think?
@Bakual @joomdonation Agreed. I even considered leaving the brackets.
Should this apply for every redundant ternary conditional in the code? I'm gonna go ahead and vote no. There are some instances where it's helpful, like when e.g. a function is called and it's not entirely intuitive that it returns a boolean (like: $foo = bar() ? true : false
[and they might not even return booleans] . There are examples like those in the code.
So how about applying this for ternary conditionals that have a conditional operator instead of a function as their condition? Or maybe cast to boolean the result of the function to make it readable and deal with non-boolean results and remove the ternary operator. Thoughts?
For functions type casting to boolean should work imho. So $foo = (bool) bar();
. For functions which already return a boolean I would just use the return value without type casting.
But maybe that is something which could be discussed in the codestyle repo to get more feedback?
Category | ⇒ | Code style |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-05-08 22:04:51 |
Closed_By | ⇒ | clinchergt |
There's actually quite a few of these. I didn't find anything about them in the coding guidelines, so I'm guessing they aren't purposely coded that way.