Php s1125 rule SonarLint: remove the literal "true" boolean value same for false?

Hi I am using sonarlint for the project can you please tell me why below is incorrect?
SonarLint: remove the literal “true” boolean value same for false?

    /**
     * @return bool
     */
    public function authenticateUser()
    {
        $user = self::getUser();
        return (empty($user) || $user instanceof Employee) ? true : false;
    }

Your code is equal to:

return condition ? true : false;

but the following code is the same as:

return condition;

It means you unnecessary execute additional operations (ternary operator).

Fixed code:

public function authenticateUser()
{
    $user = self::getUser();
    return empty($user) || $user instanceof Employee
}
2 Likes