What are the best practices for choosing between true/false and null return values in PHP functions for better code readability and maintainability?

When choosing between true/false and null return values in PHP functions, it is important to consider the context in which the function will be used. If the function is expected to return a boolean value indicating success or failure, true/false can be a clear and concise choice. However, if the function may not always have a meaningful boolean result, using null as a return value can provide more flexibility and clarity in the code.

// Example of using true/false return values
function isValidEmail($email) {
    if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
        return true;
    } else {
        return false;
    }
}

// Example of using null return value
function findUserByEmail($email) {
    $user = getUserFromDatabase($email);
    
    if ($user) {
        return $user;
    } else {
        return null;
    }
}