@DOA said:
So there I was browsing through the SVN commits when I noticed the following:
$this->_userLogged = $userAccess->userLoggedIn() ? $userAccess->getUserID() : 0 ;I was overjoyed; not only is my colleague using the ternary operator, but there's also no comparing the result of userLoggedIn(), which returns a boolean, to true or false.
Unfortunately, I then decided to scroll down and find the only place where $this->_userLogged is used...
if ($this->_userLogged) {
//do whatever
}
There's technically nothing wrong with this code. There's no need to compare userLoggedIn() to true/false when that is all it. Is returning, as all comparison operators just evaluate down to a boolean anyway. It's like using a ternary operator to evaluate to a true or false anyway (condition ? true : false). Redundant.
The only "huh" I see here is calling it 'userLogged' instead of loggedUserId or something more specific.
Nope, sorry, you're TRWTF here, calling attention to such a small and harmless bit of logic.