I can’t say this is specific to PHP, but this is another thing I see in code a lot, that kind of drives me nuts.
if ($some_var == 3) {
return TRUE;
} else {
return FALSE;
}
Because the == is a logical operator, the operation returns a boolean value. Boolean expressions like this always return TRUE or FALSE.
Ie, your code could be simplified to:
return ($some_var == 3);
It works with more complex examples as well:
return ( some_fun() && $some_var == 3 || $foo == 'bar');
God, it seems like a lot of my posts are just complaining about the way other people write code. You’d think it’s almost as if I write perfect code. I now must take the time to admit that this is not the case. Also, I can’t claim that coders who write in the style I just called out are wrong. I just don’t like it.

