def METHOD_NAME(self, user_id: str, room_id: str, aliases: Collection[str]) -> bool:
    """Tests if this rule matches the given user_id, room_id and aliases.
    Args:
        user_id: The user ID to check.
        room_id: The room ID to check.
        aliases: The associated aliases to the room. Will be a single element
            for testing alias creation, and can be empty for testing room
            publishing.
    Returns:
        True if the rule matches.
    """
    # Note: The regexes are anchored at both ends
    if not self._user_id_regex.match(user_id):
        return False
    if not self._room_id_regex.match(room_id):
        return False
    # We only have alias checks left, so we can short circuit if the alias
    # rule matches everything.
    if self._alias_matches_all:
        return True
    # If we are not given any aliases then this rule only matches if the
    # alias glob matches all aliases, which we checked above.
    if not aliases:
        return False
    # Otherwise, we just need one alias to match
    for alias in aliases:
        if self._alias_regex.match(alias):
            return True
    return False