diff --git a/core/includes/common.inc b/core/includes/common.inc
index e523b1b..2bcf981 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -4438,7 +4438,7 @@ function drupal_render_cache_by_query($query, $function, $expire = Cache::PERMAN
  *   $granularity was passed in, more parts are added.
  */
 function drupal_render_cid_parts($granularity = NULL) {
-  global $theme, $base_root, $user;
+  global $theme, $base_root;
 
   $cid_parts[] = $theme;
 
@@ -4455,10 +4455,10 @@ function drupal_render_cid_parts($granularity = NULL) {
     // resource drag for sites with many users, so when a module is being
     // equivocal, we favor the less expensive 'PER_ROLE' pattern.
     if ($granularity & DRUPAL_CACHE_PER_ROLE) {
-      $cid_parts[] = 'r.' . implode(',', $user->getRoles());
+      $cid_parts[] = 'r.' . implode(',', \Drupal::currentUser()->getRoles());
     }
     elseif ($granularity & DRUPAL_CACHE_PER_USER) {
-      $cid_parts[] = 'u.' . $user->id();
+      $cid_parts[] = 'u.' . \Drupal::currentUser()->id();
     }
 
     if ($granularity & DRUPAL_CACHE_PER_PAGE) {
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 0a57f16..760acb1 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -2706,7 +2706,7 @@ function install_configure_form_submit($form, &$form_state) {
   $account->pass = $form_state['values']['account']['pass'];
   $account->name = $form_state['values']['account']['name'];
   $account->save();
-  // Load global $user and perform final login tasks.
+  // Load current user and perform final login tasks.
   $account = user_load(1);
   user_login_finalize($account);
 
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index 3dd8449..8777195 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -84,7 +84,7 @@ function drupal_theme_access($theme) {
  * Initializes the theme system by loading the theme.
  */
 function drupal_theme_initialize() {
-  global $theme, $user, $theme_key;
+  global $theme, $theme_key;
 
   // If $theme is already set, assume the others are set, too, and do nothing
   if (isset($theme)) {
@@ -1750,8 +1750,7 @@ function theme_table($variables) {
  */
 function theme_mark($variables) {
   $type = $variables['status'];
-  global $user;
-  if ($user->isAuthenticated()) {
+  if (\Drupal::currentUser()->isAuthenticated()) {
     if ($type == MARK_NEW) {
       return ' <span class="marker">' . t('new') . '</span>';
     }
diff --git a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
index 5bdf61c..a2aa7d8 100644
--- a/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/AuthenticationSubscriber.php
@@ -78,13 +78,13 @@ public function onException(GetResponseForExceptionEvent $event) {
    * {@inheritdoc}
    *
    * The priority for request must be higher than the highest event subscriber
-   * accessing the global $user.
+   * accessing the current user.
    * The priority for the response must be as low as possible allowing e.g the
    * Cookie provider to send all relevant session data to the user.
    */
   public static function getSubscribedEvents() {
     // Priority must be higher than LanguageRequestSubscriber as LanguageManager
-    // access global $user in case language module enabled.
+    // access current user in case language module enabled.
     $events[KernelEvents::REQUEST][] = array('onKernelRequestAuthenticate', 300);
     $events[KernelEvents::RESPONSE][] = array('onRespond', 0);
     $events[KernelEvents::EXCEPTION][] = array('onException', 0);
diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
index e7012b6..617cba7 100644
--- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php
+++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php
@@ -27,7 +27,7 @@ class MessageFormController extends ContentEntityFormController {
    * Overrides Drupal\Core\Entity\EntityFormController::form().
    */
   public function form(array $form, array &$form_state) {
-    global $user;
+    $user = \Drupal::currentUser();
     $message = $this->entity;
     $form = parent::form($form, $form_state, $message);
     $form['#attributes']['class'][] = 'contact-form';
@@ -138,7 +138,7 @@ public function preview(array $form, array &$form_state) {
    * Overrides Drupal\Core\Entity\EntityFormController::save().
    */
   public function save(array $form, array &$form_state) {
-    global $user;
+    $user = \Drupal::currentUser();
 
     $language_interface = language(Language::TYPE_INTERFACE);
     $message = $this->entity;
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php
index 2ec39ff..13dd6ea 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php
@@ -70,8 +70,6 @@ public function settingsSummary() {
    * {@inheritdoc}
    */
   public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) {
-    global $user;
-
     $entity = $items->getEntity();
 
     // Prepare the autocomplete route parameters.
@@ -95,7 +93,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen
       '#size' => $this->getSetting('size'),
       '#placeholder' => $this->getSetting('placeholder'),
       '#element_validate' => array(array($this, 'elementValidate')),
-      '#autocreate_uid' => ($entity instanceof EntityOwnerInterface) ? $entity->getOwnerId() : $user->id(),
+      '#autocreate_uid' => ($entity instanceof EntityOwnerInterface) ? $entity->getOwnerId() : \Drupal::currentUser()->id(),
     );
 
     return array('target_id' => $element);
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
index a93300e..85159b5 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php
@@ -120,7 +120,7 @@ public function testSort() {
 
     // Test as a non-admin.
     $normal_user = $this->drupalCreateUser(array('access content'));
-    $GLOBALS['user'] = $normal_user;
+    $this->container->set('current_user', $normal_user);
 
     $handler = $this->container->get('plugin.manager.entity_reference.selection')->getSelectionHandler($instance);
 
diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module
index 710c59f..87eda67 100644
--- a/core/modules/filter/filter.module
+++ b/core/modules/filter/filter.module
@@ -519,7 +519,7 @@ function check_markup($text, $format_id = NULL, $langcode = '', $cache = FALSE,
  *   The expanded element.
  */
 function filter_process_format($element) {
-  global $user;
+  $user = \Drupal::currentUser();
 
   // Ensure that children appear as subkeys of this element.
   $element['#tree'] = TRUE;
@@ -692,9 +692,7 @@ function filter_form_access_denied($element) {
  *   - id: Filter ID.
  */
 function _filter_tips($format_id, $long = FALSE) {
-  global $user;
-
-  $formats = filter_formats($user);
+  $formats = filter_formats(\Drupal::currentUser());
 
   $tips = array();
 
diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
index c6c7636..865704d 100644
--- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
+++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
@@ -58,7 +58,7 @@ protected function setUp() {
     // Create a test entity to serialize.
     $this->values = array(
       'name' => $this->randomName(),
-      'user_id' => $GLOBALS['user']->id(),
+      'user_id' => \Drupal::currentUser()->id(),
       'field_test_text' => array(
         'value' => $this->randomName(),
         'format' => 'full_html',
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 5a08f5b..d9d9da9 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -923,8 +923,9 @@ protected function beforePrepareEnvironment() {
    * @see TestBase::beforePrepareEnvironment()
    */
   private function prepareEnvironment() {
-    global $user, $conf;
+    global $conf;
 
+    $user = \Drupal::currentUser();
     // Allow (base) test classes to backup global state information.
     $this->beforePrepareEnvironment();
 
@@ -963,9 +964,6 @@ private function prepareEnvironment() {
     // Ensure that the current session is not changed by the new environment.
     require_once DRUPAL_ROOT . '/' . settings()->get('session_inc', 'core/includes/session.inc');
     drupal_save_session(FALSE);
-    // Run all tests as a anonymous user by default, web tests will replace that
-    // during the test set up.
-    $user = drupal_anonymous_user();
 
     // Save and clean the shutdown callbacks array because it is static cached
     // and will be changed by the test run. Otherwise it will contain callbacks
@@ -1031,7 +1029,10 @@ private function prepareEnvironment() {
 
     $request = Request::create('/');
     $this->container->set('request', $request);
-    $this->container->set('current_user', $GLOBALS['user']);
+
+    // Run all tests as a anonymous user by default, web tests will replace that
+    // during the test set up.
+    $this->container->set('current_user', drupal_anonymous_user());
 
     \Drupal::setContainer($this->container);
 
@@ -1108,9 +1109,9 @@ protected function rebuildContainer() {
     // DrupalKernel replaces the container in \Drupal::getContainer() with a
     // different object, so we need to replace the instance on this test class.
     $this->container = \Drupal::getContainer();
-    // The global $user is set in TestBase::prepareEnvironment().
+    // The current user is set in TestBase::prepareEnvironment().
     $this->container->set('request', $request);
-    $this->container->set('current_user', $GLOBALS['user']);
+    $this->container->set('current_user', \Drupal::currentUser());
   }
 
   /**
@@ -1131,7 +1132,7 @@ protected function tearDown() {
    * @see TestBase::prepareEnvironment()
    */
   private function restoreEnvironment() {
-    global $user, $conf;
+    global $conf;
 
     // Reset all static variables.
     // Unsetting static variables will potentially invoke destruct methods,
@@ -1214,7 +1215,7 @@ private function restoreEnvironment() {
     $callbacks = $this->originalShutdownCallbacks;
 
     // Restore original user session.
-    $user = $this->originalUser;
+    $this->container->set('current_user', $this->originalUser);
     drupal_save_session(TRUE);
   }
 
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index d66d2a9..10aac8b 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -277,7 +277,7 @@ protected function drupalCreateNode(array $settings = array()) {
         $settings['uid'] = $this->loggedInUser->id();
       }
       else {
-        $user = \Drupal::currentUser() ?: $GLOBALS['user'];
+        $user = \Drupal::currentUser() ?: drupal_anonymous_user();
         $settings['uid'] = $user->id();
       }
     }
@@ -605,7 +605,7 @@ protected function checkPermissions(array $permissions, $reset = FALSE) {
    * If a user is already logged in, then the current user is logged out before
    * logging in the specified user.
    *
-   * Please note that neither the global $user nor the passed-in user object is
+   * Please note that neither the current user nor the passed-in user object is
    * populated with data of the logged in user. If you need full access to the
    * user object after logging in, it must be updated manually. If you also need
    * access to the plain-text password of the user (set by drupalCreateUser()),
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
index 4344801..edad64a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php
@@ -32,7 +32,6 @@ function testTokenReplacement() {
     $account = $this->drupalCreateUser();
     $node = $this->drupalCreateNode(array('uid' => $account->id()));
     $node->title = '<blink>Blinking Text</blink>';
-    global $user;
     $language_interface = language(Language::TYPE_INTERFACE);
 
     $source  = '[node:title]';         // Title of the node we passed in
@@ -46,7 +45,7 @@ function testTokenReplacement() {
     $target  = check_plain($node->getTitle());
     $target .= check_plain($account->getUsername());
     $target .= format_interval(REQUEST_TIME - $node->getCreatedTime(), 2, $language_interface->id);
-    $target .= check_plain($user->getUsername());
+    $target .= check_plain(\Drupal::currentUser()->getUsername());
     $target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->id);
 
     // Test that the clear parameter cleans out non-existent tokens.
diff --git a/core/modules/user/lib/Drupal/user/AccountFormController.php b/core/modules/user/lib/Drupal/user/AccountFormController.php
index 6002298..93f8020 100644
--- a/core/modules/user/lib/Drupal/user/AccountFormController.php
+++ b/core/modules/user/lib/Drupal/user/AccountFormController.php
@@ -341,7 +341,7 @@ public function validate(array $form, array &$form_state) {
 
       if ($mail_taken) {
         // Format error message dependent on whether the user is logged in or not.
-        if ($GLOBALS['user']->isAuthenticated()) {
+        if (\Drupal::currentUser()->isAuthenticated()) {
           $this->setFormError('mail', $form_state, $this->t('The e-mail address %email is already taken.', array('%email' => $mail)));
         }
         else {
diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php
index f9db482..0c3519b 100644
--- a/core/modules/user/lib/Drupal/user/Entity/User.php
+++ b/core/modules/user/lib/Drupal/user/Entity/User.php
@@ -121,7 +121,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $
       // user and recreate the current one.
       if ($this->pass->value != $this->original->pass->value) {
         drupal_session_destroy_uid($this->id());
-        if ($this->id() == $GLOBALS['user']->id()) {
+        if ($this->id() == \Drupal::currentUser()->id()) {
           drupal_session_regenerate();
         }
       }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
index b404ba0..75fa5f5 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/Action/CancelUser.php
@@ -60,7 +60,7 @@ public static function create(ContainerInterface $container, array $configuratio
    * {@inheritdoc}
    */
   public function executeMultiple(array $entities) {
-    $this->tempStoreFactory->get('user_user_operations_cancel')->set($GLOBALS['user']->id(), $entities);
+    $this->tempStoreFactory->get('user_user_operations_cancel')->set(\Drupal::currentUser()->id(), $entities);
   }
 
   /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php
index e763bae..f1d987b 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/CurrentUser.php
@@ -10,7 +10,7 @@
 use Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase;
 
 /**
- * Default argument plugin to extract the global $user
+ * Default argument plugin to extract the current user
  *
  * This plugin actually has no options so it odes not need to do a great deal.
  *
@@ -22,8 +22,7 @@
 class CurrentUser extends ArgumentDefaultPluginBase {
 
   public function getArgument() {
-    global $user;
-    return $user->id();
+    return \Drupal::currentUser()->id();
   }
 
 }
diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
index d385236..d7c3701 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_validator/User.php
@@ -109,21 +109,21 @@ public function validateArgument($argument) {
     // However, is_integer() will always fail, since $argument is a string.
     if (is_numeric($argument) && $argument == (int)$argument) {
       if ($type == 'uid' || $type == 'either') {
-        if ($argument == $GLOBALS['user']->id()) {
+        if ($argument == \Drupal::currentUser()->id()) {
           // If you assign an object to a variable in PHP, the variable
           // automatically acts as a reference, not a copy, so we use
           // clone to ensure that we don't actually mess with the
-          // real global $user object.
-          $account = clone $GLOBALS['user'];
+          // real current user object.
+          $account = clone \Drupal::currentUser();
         }
         $condition = 'uid';
       }
     }
     else {
       if ($type == 'name' || $type == 'either') {
-        $name = $GLOBALS['user']->getUserName() ?: \Drupal::config('user.settings')->get('anonymous');
+        $name = \Drupal::currentUser()->getUserName() ?: \Drupal::config('user.settings')->get('anonymous');
         if ($argument == $name) {
-          $account = clone $GLOBALS['user'];
+          $account = clone \Drupal::currentUser();
         }
         $condition = 'name';
       }
diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php
index ba95171..f642b4f 100644
--- a/core/modules/user/lib/Drupal/user/RegisterFormController.php
+++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php
@@ -41,7 +41,7 @@ public function form(array $form, array &$form_state) {
 
     // If we aren't admin but already logged on, go to the user page instead.
     if (!$admin && $user->isAuthenticated()) {
-      return new RedirectResponse(url('user/' . $user->id(), array('absolute' => TRUE)));
+      return new RedirectResponse(url('user/' . \Drupal::currentUser()->id(), array('absolute' => TRUE)));
     }
 
     $form['#attached']['library'][] = array('system', 'jquery.cookie');
diff --git a/core/modules/user/lib/Drupal/user/TempStoreFactory.php b/core/modules/user/lib/Drupal/user/TempStoreFactory.php
index 45f421e..28d4147 100644
--- a/core/modules/user/lib/Drupal/user/TempStoreFactory.php
+++ b/core/modules/user/lib/Drupal/user/TempStoreFactory.php
@@ -61,7 +61,7 @@ function get($collection, $owner = NULL) {
     // Use the currently authenticated user ID or the active user ID unless
     // the owner is overridden.
     if (!isset($owner)) {
-      $owner = $GLOBALS['user']->id() ?: session_id();
+      $owner = \Drupal::currentUser()->id() ?: session_id();
     }
 
     // Store the data for this collection in the database.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
index cc706ba..13172de 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserTokenReplaceTest.php
@@ -57,7 +57,7 @@ function testUserTokenReplacement() {
     $this->drupalLogin($user2);
 
     $account = user_load($user1->id());
-    $global_account = user_load($GLOBALS['user']->id());
+    $global_account = user_load(\Drupal::currentUser()->id());
 
     // Generate and test sanitized tokens.
     $tests = array();
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index 4262403..49c9dea 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -683,7 +683,7 @@ function theme_username($variables) {
  */
 function user_is_anonymous() {
   // Menu administrators can see items for anonymous when administering.
-  return $GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin']);
+  return \Drupal::currentUser()->isAnonymous() || !empty($GLOBALS['menu_admin']);
 }
 
 /**
@@ -695,7 +695,7 @@ function user_is_anonymous() {
  * @deprecated Use \Drupal\Core\Session\UserSession::isAuthenticated().
  */
 function user_is_logged_in() {
-  return $GLOBALS['user']->isAuthenticated();
+  return \Drupal::currentUser()->isAuthenticated();
 }
 
 /**
@@ -913,7 +913,7 @@ function user_uid_only_optional_to_arg($arg) {
  */
 function user_uid_optional_load($uid = NULL) {
   if (!isset($uid)) {
-    $uid = $GLOBALS['user']->id();
+    $uid = \Drupal::currentUser()->id();
   }
   return user_load($uid);
 }
@@ -927,7 +927,7 @@ function user_uid_optional_to_arg($arg) {
   // Give back the current user uid when called from eg. tracker, aka.
   // with an empty arg. Also use the current user uid when called from
   // the menu with a % for the current account link.
-  return empty($arg) || $arg == '%' ? $GLOBALS['user']->id() : $arg;
+  return empty($arg) || $arg == '%' ? \Drupal::currentUser()->id() : $arg;
 }
 
 /**
@@ -937,7 +937,7 @@ function user_uid_optional_to_arg($arg) {
  * authenticated users are expected to see "My account".
  */
 function user_menu_title() {
-  if ($GLOBALS['user']->isAnonymous()) {
+  if (\Drupal::currentUser()->isAnonymous()) {
     switch (current_path()) {
       case 'user' :
       case 'user/login' :
@@ -1138,8 +1138,6 @@ function user_pass_rehash($password, $timestamp, $login) {
  * @see _user_cancel()
  */
 function user_cancel($edit, $uid, $method) {
-  global $user;
-
   $account = user_load($uid);
 
   if (!$account) {
@@ -1172,7 +1170,7 @@ function user_cancel($edit, $uid, $method) {
   );
 
   // After cancelling account, ensure that user is logged out.
-  if ($account->id() == $user->id()) {
+  if ($account->id() == \Drupal::currentUser()->id()) {
     // Batch API stores data in the session, so use the finished operation to
     // manipulate the current user's session id.
     $batch['finished'] = '_user_cancel_session_regenerate';
@@ -1749,8 +1747,6 @@ function user_form_process_password_confirm($element) {
   );
 
   if (\Drupal::config('user.settings')->get('password_strength')) {
-
-    global $user;
     $password_settings['showStrengthIndicator'] = TRUE;
     $password_settings += array(
       'strengthTitle' => t('Password strength:'),
@@ -1765,7 +1761,7 @@ function user_form_process_password_confirm($element) {
       'fair' => t('Fair'),
       'good' => t('Good'),
       'strong' => t('Strong'),
-      'username' => $user->getUsername(),
+      'username' => \Drupal::currentUser()->getUsername(),
     );
   }
 
@@ -1847,7 +1843,7 @@ function user_file_download_access($field, EntityInterface $entity, File $file)
  * Implements hook_toolbar().
  */
 function user_toolbar() {
-  global $user;
+  $user = \Drupal::currentUser();
 
   // Add logout & user account links or login link.
   if ($user->isAuthenticated()) {
@@ -1966,7 +1962,7 @@ function user_library_info() {
  * Logs the current user out.
  */
 function user_logout() {
-  global $user;
+  $user = \Drupal::currentUser();
 
   watchdog('user', 'Session closed for %name.', array('%name' => $user->getUsername()));
 
diff --git a/core/modules/user/user.tokens.inc b/core/modules/user/user.tokens.inc
index 5412a38..e3c22f2 100644
--- a/core/modules/user/user.tokens.inc
+++ b/core/modules/user/user.tokens.inc
@@ -125,7 +125,7 @@ function user_tokens($type, $tokens, array $data = array(), array $options = arr
   }
 
   if ($type == 'current-user') {
-    $account = user_load($GLOBALS['user']->id());
+    $account = user_load(\Drupal::currentUser()->id());
     $replacements += $token_service->generate('user', $tokens, array('user' => $account), $options);
   }
 
diff --git a/core/modules/user/user.views_execution.inc b/core/modules/user/user.views_execution.inc
index 622cdbf..c9a3f1d 100644
--- a/core/modules/user/user.views_execution.inc
+++ b/core/modules/user/user.views_execution.inc
@@ -13,6 +13,5 @@
  * Allow replacement of current userid so we can cache these queries.
  */
 function user_views_query_substitutions(ViewExecutable $view) {
-  global $user;
-  return array('***CURRENT_USER***' => $user->id());
+  return array('***CURRENT_USER***' => \Drupal::currentUser()->id());
 }
