User choices is separate usernames/email for autocomplete

@param User[] $choices

@return string[]
343965
public function getChoicesAsSeparateEmailUsername(array &$choices)
    {
        $ret = [];
        foreach ($choices as $item) {
            $ret[] = $item->getEmail();
            $ret[] = $item->getUsername();
        }

        return $ret;
    }
1226980
public static function CategorizeUsersList($users) {
        $list = array();
        if (is_array($users) && count($users) > 0) {
            foreach ($users as $user) {
                $userType = $user->user_type();
                $list[$userType][] = $user;
            }
        }
        return $list;
    }
736773
public function loadValuesForChoices(array $choices, $value = null)
    {
        @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1, use the "choice_loader" option instead.', __METHOD__), E_USER_DEPRECATED);

        // Optimize
        $choices = array_filter($choices);
        if (empty($choices)) {
            return [];
        }

        // If no callable is set, choices are the same as values
        if (null === $value) {
            return $choices;
        }

        return $this->loadChoiceList($value)->getValuesForChoices($choices);
    }
165853
public function getAllUsersPreferences(array $preferenceNames)
    {
        Piwik::checkUserHasSuperUserAccess();

        $userPreferences = array();
        foreach($preferenceNames as $preferenceName) {
            $optionNameMatchAllUsers = $this->getPreferenceId('%', $preferenceName);
            $preferences = Option::getLike($optionNameMatchAllUsers);

            foreach($preferences as $optionName => $optionValue) {
                $lastUnderscore = strrpos($optionName, self::OPTION_NAME_PREFERENCE_SEPARATOR);
                $userName = substr($optionName, 0, $lastUnderscore);
                $preference = substr($optionName, $lastUnderscore + 1);
                $userPreferences[$userName][$preference] = $optionValue;
            }
        }
        return $userPreferences;
    }
757119
@Override
	public String[] getRoles(String username) {
		if (user_list.containsKey(username)) {
			return user_list.get(username).toArray(new String[0]);
		} else {
			if (defaultRoles == null) {
				return new String[0];
			} else {
				return defaultRoles;
			}
		}
	}
1278817
public function setChoices(array $choices)
    {
        // Removes old choices
        $oldChoices = array_filter($this->choices->toArray(), function (CellChoice $choice) use ($choices) {
            return !in_array($choice, $choices);
        });
        array_walk($oldChoices, function (CellChoice $choice) {
            $this->removeChoice($choice);
        });

        // Adds new ones
        array_walk($choices, function (CellChoice $choice) {
            $this->addChoice($choice);
        });
    }
1280778
public function getAllUsers($options = [], $filters = [GenerisRdf::PROPERTY_USER_LOGIN => '*'])
    {
        $userClass = new core_kernel_classes_Class(TaoOntology::CLASS_URI_TAO_USER);
		$options = array_merge(['recursive' => true, 'like' => true], $options);

		return (array) $userClass->searchInstances($filters, $options);
    }
526248
protected function parseChoices(array $choices)
    {
        $items = [];

        foreach ($choices as $key => $value) {
            if (is_array($value)) {
                // Handle options groups data.
                $items[] = ['key' => $key, 'value' => '', 'type' => 'group'];
                $items = array_merge($items, $this->parseChoices($value));
            } else {
                $items[] = ['key' => $key, 'value' => $value, 'type' => 'option'];
            }
        }

        return $items;
    }
319322
public function getChoices(Options $options)
    {
        if (!$options['category'] instanceof CategoryInterface) {
            return [];
        }

        if (null === $options['context']) {
            $categories = $this->manager->getAllRootCategories();
        } else {
            $categories = $this->manager->getRootCategoriesForContext($options['context']);
        }

        $choices = [];

        foreach ($categories as $category) {
            $choices[$category->getId()] = sprintf('%s (%s)', $category->getName(), $category->getContext()->getId());

            $this->childWalker($category, $options, $choices);
        }

        return $choices;
    }
1068545
public function options() {
        $options = array();
        foreach ($this->items as $userid => $user) {
            $options[$userid] = fullname($user);
        }

        return $options;
    }
158260
public function listUserPublicKeys(string $username): array
    {
        return $this->getApi()->request($this->getApi()->sprintf('/users/:username/keys', $username));
    }
1354266
protected static function paginateSimpleChoices(array $choices, $startTo, $endTo)
    {
        $paginatedChoices = [];
        $index = 0;

        foreach ($choices as $key => $choice) {
            if ($index >= $startTo && $index < $endTo) {
                $paginatedChoices[$key] = $choice;
            }

            ++$index;
        }

        return $paginatedChoices;
    }
844136
private function _userids($users)
	{
		$db = \App::get('db');

		if (empty($db))
		{
			return false;
		}

		$usernames = array();
		$userids = array();

		if (!is_array($users))
		{
			$users = array($users);
		}

		foreach ($users as $u)
		{
			if (is_numeric($u))
			{
				$userids[] = $u;
			}
			else
			{
				$usernames[] = $db->quote($u);
			}
		}

		if (empty($usernames))
		{
			return $userids;
		}

		$set = implode($usernames, ",");

		$sql = "SELECT id FROM `#__users` WHERE username IN ($set);";

		$db->setQuery($sql);

		$result = $db->loadColumn();

		if (empty($result))
		{
			$result = array();
		}

		$result = array_merge($result, $userids);

		return $result;
	}
1271931
static public function getChoices(array $operators)
    {
        $choices = [];
        foreach ($operators as $operator) {
            $choices[static::getLabel($operator)] = $operator;
        }

        return $choices;
    }
359489
public function getChoices($username = null, $email = null, $or = false, $limit = null)
    {
        $qb = $this->getRepository()->createQueryBuilder('u');
        $qb->orderBy('u.username');
        $method = $or ? 'orWhere' : 'andWhere';
        if ($username) {
            $qb->$method('u.username LIKE :username');
            $qb->setParameter('username', '%' . $username . '%');
        }
        if ($email) {
            $qb->$method('u.email LIKE :email');
            $qb->setParameter('email', '%' . $email . '%');
        }
        if ($limit) {
            $qb->setMaxResults($limit);
        }

        return $qb->getQuery()->getResult();
    }
310636
public function setChoices(array $choices) {
		if (empty($choices)) {
			return false;
		}

		$this->deleteChoices();

		// Ignore access (necessary in case a group admin is editing the poll of another group member)
		$ia = elgg_set_ignore_access(true);

		$i = 0;
		foreach ($choices as $choice) {
			$poll_choice = new ElggObject();
			$poll_choice->owner_guid = $this->owner_guid;
			$poll_choice->container_guid = $this->container_guid;
			$poll_choice->subtype = "poll_choice";
			$poll_choice->text = $choice;
			$poll_choice->display_order = $i*10;
			$poll_choice->access_id = $this->access_id;
			$poll_choice->save();

			add_entity_relationship($poll_choice->guid, 'poll_choice', $this->guid);
			$i += 1;
		}

		elgg_set_ignore_access($ia);
	}
482127
private function getSortFieldChoices(): array
    {
        $choices = [];
        foreach ($this->getSortField() as $label => $value) {
            $choices[$label] = $value;
        }

        return $choices;
    }