/**
* Get a user object.
*
* Returns the global {@link User} object, only creating it if it doesn't already exist.
*
* @param integer $id The user to load - Can be an integer or string - If string, it is converted to ID automatically.
*
* @return User object
*
* @see User
* @since 1.7.0
* @deprecated 5.0 Load the user service from the dependency injection container or via $app->getIdentity()
*/
public static function getUser($id = null)
{
@trigger_error(sprintf('%1$s() is deprecated. Load the user from the dependency injection container or via %2$s::getApplication()->getIdentity().', __METHOD__, __CLASS__), E_USER_DEPRECATED);
$instance = self::getApplication()->getSession()->get('user');
if (\is_null($id)) {
if (!$instance instanceof User) {
$instance = User::getInstance();
}
} elseif (!$instance instanceof User || \is_string($id) || $instance->id !== $id) {
$instance = User::getInstance($id);
}
return $instance;
}