diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index 6aeeca0..74d0cb2 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -768,7 +768,7 @@ function drupal_get_filename($type, $name, $filename = NULL) {
         }
       }
       try {
-        $file_list = state()->get('system.' . $type . '.files');
+        $file_list = Drupal::state()->get('system.' . $type . '.files');
         if ($file_list && isset($file_list[$name]) && file_exists(DRUPAL_ROOT . '/' . $file_list[$name])) {
           $files[$type][$name] = $file_list[$name];
         }
@@ -2271,21 +2271,6 @@ function module_hook($module, $hook) {
 }
 
 /**
- * Returns the state storage service.
- *
- * Use this to store machine-generated data, local to a specific environment
- * that does not need deploying and does not need human editing; for example,
- * the last time cron was run. Data which needs to be edited by humans and
- * needs to be the same across development, production, etc. environments
- * (for example, the system maintenance message) should use config() instead.
- *
- * @return Drupal\Core\KeyValueStore\KeyValueStoreInterface
- */
-function state() {
-  return drupal_container()->get('keyvalue')->get('state');
-}
-
-/**
  * Returns the test prefix if this is an internal request from SimpleTest.
  *
  * @param string $new_prefix
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 15e672e..a8ad43a 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -2567,7 +2567,7 @@ function drupal_pre_render_styles($elements) {
 function drupal_build_css_cache($css) {
   $data = '';
   $uri = '';
-  $map = state()->get('drupal_css_cache_files') ?: array();
+  $map = Drupal::state()->get('drupal_css_cache_files') ?: array();
   // Create a new array so that only the file names are used to create the hash.
   // This prevents new aggregates from being created unnecessarily.
   $css_data = array();
@@ -2627,7 +2627,7 @@ function drupal_build_css_cache($css) {
     }
     // Save the updated map.
     $map[$key] = $uri;
-    state()->set('drupal_css_cache_files', $map);
+    Drupal::state()->set('drupal_css_cache_files', $map);
   }
   return $uri;
 }
@@ -2792,7 +2792,7 @@ function _drupal_load_stylesheet($matches) {
  * Deletes old cached CSS files.
  */
 function drupal_clear_css_cache() {
-  state()->delete('drupal_css_cache_files');
+  Drupal::state()->delete('drupal_css_cache_files');
   file_scan_directory('public://css', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
 }
 
@@ -4167,7 +4167,7 @@ function drupal_add_tabledrag($table_id, $action, $relationship, $group, $subgro
 function drupal_build_js_cache($files) {
   $contents = '';
   $uri = '';
-  $map = state()->get('system.js_cache_files') ?: array();
+  $map = Drupal::state()->get('system.js_cache_files') ?: array();
   // Create a new array so that only the file names are used to create the hash.
   // This prevents new aggregates from being created unnecessarily.
   $js_data = array();
@@ -4212,7 +4212,7 @@ function drupal_build_js_cache($files) {
       }
     }
     $map[$key] = $uri;
-    state()->set('system.js_cache_files', $map);
+    Drupal::state()->set('system.js_cache_files', $map);
   }
   return $uri;
 }
@@ -4221,8 +4221,8 @@ function drupal_build_js_cache($files) {
  * Deletes old cached JavaScript files and variables.
  */
 function drupal_clear_js_cache() {
-  state()->delete('system.javascript_parsed');
-  state()->delete('system.js_cache_files');
+  Drupal::state()->delete('system.javascript_parsed');
+  Drupal::state()->delete('system.js_cache_files');
   file_scan_directory('public://js', '/.*/', array('callback' => 'drupal_delete_file_if_stale'));
 }
 
@@ -4256,9 +4256,9 @@ function drupal_json_decode($var) {
  *   The private key.
  */
 function drupal_get_private_key() {
-  if (!($key = state()->get('system.private_key'))) {
+  if (!($key = Drupal::state()->get('system.private_key'))) {
     $key = Crypt::randomStringHashed(55);
-    state()->set('system.private_key', $key);
+    Drupal::state()->set('system.private_key', $key);
   }
   return $key;
 }
@@ -4483,7 +4483,7 @@ function drupal_cron_run() {
     }
 
     // Record cron time.
-    state()->set('system.cron_last', REQUEST_TIME);
+    Drupal::state()->set('system.cron_last', REQUEST_TIME);
     watchdog('cron', 'Cron run completed.', array(), WATCHDOG_NOTICE);
 
     // Release cron lock.
diff --git a/core/includes/entity.api.php b/core/includes/entity.api.php
index 1912fe1..8984c96 100644
--- a/core/includes/entity.api.php
+++ b/core/includes/entity.api.php
@@ -91,7 +91,7 @@ function hook_entity_bundle_info_alter(&$bundles) {
 function hook_entity_bundle_create($entity_type, $bundle) {
   // When a new bundle is created, the menu needs to be rebuilt to add the
   // Field UI menu item tabs.
-  state()->set('menu_rebuild_needed', TRUE);
+  Drupal::state()->set('menu_rebuild_needed', TRUE);
 }
 
 /**
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 6263ef0..686facb 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -961,7 +961,7 @@ function install_base_system(&$install_state) {
   // after all the dependencies have been installed.
   $modules[] = drupal_get_profile();
 
-  state()->set('install_profile_modules', array_diff($modules, array('system')));
+  Drupal::state()->set('install_profile_modules', array_diff($modules, array('system')));
   $install_state['database_tables_exist'] = TRUE;
 }
 
@@ -1719,9 +1719,9 @@ function install_bootstrap_full() {
  *   The batch definition.
  */
 function install_profile_modules(&$install_state) {
-  $modules = state()->get('install_profile_modules') ?: array();
+  $modules = Drupal::state()->get('install_profile_modules') ?: array();
   $files = system_rebuild_module_data();
-  state()->delete('install_profile_modules');
+  Drupal::state()->delete('install_profile_modules');
 
   // Always install required modules first. Respect the dependencies between
   // the modules.
diff --git a/core/includes/menu.inc b/core/includes/menu.inc
index cc0e815..6209fac 100644
--- a/core/includes/menu.inc
+++ b/core/includes/menu.inc
@@ -337,7 +337,7 @@ function menu_get_ancestors($parts) {
   $ancestors = array();
   $length =  $number_parts - 1;
   $end = (1 << $number_parts) - 1;
-  $masks = state()->get('menu.masks');
+  $masks = Drupal::state()->get('menu.masks');
   // If the optimized menu.masks array is not available use brute force to get
   // the correct $ancestors and $placeholders returned. Do not use this as the
   // default value of the menu.masks variable to avoid building such a big
@@ -471,7 +471,7 @@ function menu_get_item($path = NULL, $router_item = NULL) {
   if (!isset($router_items[$path])) {
     // Rebuild if we know it's needed, or if the menu masks are missing which
     // occurs rarely, likely due to a race condition of multiple rebuilds.
-    if (state()->get('menu_rebuild_needed') || !state()->get('menu.masks')) {
+    if (Drupal::state()->get('menu_rebuild_needed') || !Drupal::state()->get('menu.masks')) {
       menu_router_rebuild();
     }
     $original_map = arg(NULL, $path);
@@ -1313,7 +1313,7 @@ function menu_tree_page_data($menu_name, $max_depth = NULL, $only_active_trail =
           }
           $parents = $active_trail;
 
-          $expanded = state()->get('menu_expanded');
+          $expanded = Drupal::state()->get('menu_expanded');
           // Check whether the current menu has any links set to be expanded.
           if (!$only_active_trail && $expanded && in_array($menu_name, $expanded)) {
             // Collect all the links set to be expanded, and then add all of
@@ -2698,7 +2698,7 @@ function menu_router_rebuild() {
     menu_cache_clear_all();
     _menu_clear_page_cache();
     // Indicate that the menu has been successfully rebuilt.
-    state()->delete('menu_rebuild_needed');
+    Drupal::state()->delete('menu_rebuild_needed');
   }
   catch (Exception $e) {
     $transaction->rollback();
@@ -2974,7 +2974,7 @@ function _menu_clear_page_cache() {
  */
 function _menu_set_expanded_menus() {
   $names = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name")->fetchCol();
-  state()->set('menu_expanded', $names);
+  Drupal::state()->set('menu_expanded', $names);
 }
 
 /**
@@ -3249,8 +3249,8 @@ function _menu_router_build($callbacks, $save = FALSE) {
     $path_roots = array_values($path_roots);
     // Update the path roots variable and reset the path alias whitelist cache
     // if the list has changed.
-    if ($path_roots != state()->get('menu_path_roots')) {
-      state()->set('menu_path_roots', array_values($path_roots));
+    if ($path_roots != Drupal::state()->get('menu_path_roots')) {
+      Drupal::state()->set('menu_path_roots', array_values($path_roots));
       drupal_container()->get('path.alias_manager')->cacheClear();
     }
     _menu_router_save($menu, $masks);
@@ -3338,7 +3338,7 @@ function _menu_router_save($menu, $masks) {
   // Insert any remaining records.
   $insert->execute();
   // Store the masks.
-  state()->set('menu.masks', $masks);
+  Drupal::state()->set('menu.masks', $masks);
 
   return $menu;
 }
diff --git a/core/includes/module.inc b/core/includes/module.inc
index 46ef196..0d488ca 100644
--- a/core/includes/module.inc
+++ b/core/includes/module.inc
@@ -44,7 +44,7 @@ function system_list($type) {
     //   system.theme.data state will go away entirely as soon as themes have
     //   a proper installation status.
     // @see http://drupal.org/node/1067408
-    $theme_data = state()->get('system.theme.data');
+    $theme_data = Drupal::state()->get('system.theme.data');
     if (empty($theme_data)) {
       // @todo: system_list() may be called from _drupal_bootstrap_code(), in
       // which case system.module is not loaded yet.
@@ -119,7 +119,7 @@ function system_list_reset() {
   // will cause system_list_reset() to be called, but theme data is not
   // necessarily rebuilt afterwards.
   // @todo Obsolete with proper installation status for themes.
-  state()->delete('system.theme.data');
+  Drupal::state()->delete('system.theme.data');
 }
 
 /**
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 54fa410..1af12f1 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -170,7 +170,7 @@ function update_prepare_d8_bootstrap() {
     if ($has_required_schema) {
       if (!db_table_exists('key_value')) {
         $specs = array(
-          'description' => 'Generic key-value storage table. See state() for an example.',
+          'description' => 'Generic key-value storage table. See the state system for an example.',
           'fields' => array(
             'collection' => array(
               'description' => 'A named collection of key and value pairs.',
@@ -468,8 +468,8 @@ function update_prepare_d8_language() {
       $prefixes[$language->language] = $language->prefix;
       $domains[$language->language] = $language->domain;
     }
-    state()->set('locale.translation.plurals', $plurals);
-    state()->set('locale.translation.javascript', $javascript);
+    Drupal::state()->set('locale.translation.plurals', $plurals);
+    Drupal::state()->set('locale.translation.javascript', $javascript);
     config('language.negotiation')
       ->set('url.prefixes', $prefixes)
       ->set('url.domains', $domains)
@@ -1514,7 +1514,7 @@ function update_7_to_8_install_default_config($type, $config_name) {
  * Updates 7.x variables to state records.
  *
  * Provides a generalized method to migrate variables from 7.x to 8.x's
- * state() system.
+ * Drupal::state() system.
  *
  * @param array $variable_map
  *   An associative array that maps old variables names to new state record
@@ -1529,7 +1529,7 @@ function update_7_to_8_install_default_config($type, $config_name) {
 function update_variables_to_state(array $variable_map) {
   foreach ($variable_map as $variable_name => $state_name) {
     if (NULL !== $value = update_variable_get($variable_name)) {
-      state()->set($state_name, $value);
+      Drupal::state()->set($state_name, $value);
     }
   }
 
diff --git a/core/lib/Drupal/Core/Mail/VariableLog.php b/core/lib/Drupal/Core/Mail/VariableLog.php
index 8302d96..c7b5201 100644
--- a/core/lib/Drupal/Core/Mail/VariableLog.php
+++ b/core/lib/Drupal/Core/Mail/VariableLog.php
@@ -21,9 +21,9 @@ class VariableLog extends PhpMail implements MailInterface {
    * Accepts an e-mail message and store it in a variable.
    */
   public function mail(array $message) {
-    $captured_emails = state()->get('system.test_email_collector') ?: array();
+    $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
     $captured_emails[] = $message;
-    state()->set('system.test_email_collector', $captured_emails);
+    \Drupal::state()->set('system.test_email_collector', $captured_emails);
 
     return TRUE;
   }
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php
index e9aac8c..36fcd05 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php
@@ -25,7 +25,7 @@ public static function getInfo() {
   public function testCron() {
     // Create feed and test basic updating on cron.
     global $base_url;
-    $key = state()->get('system.cron_key');
+    $key = \Drupal::state()->get('system.cron_key');
     $this->createSampleNodes();
     $feed = $this->createFeed();
     $this->cronRun();
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
index 46454a6..ebbdd18 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
@@ -61,7 +61,7 @@ function testCachePerRole() {
 
     // Enable our test block. Set some content for it to display.
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
     $this->drupalLogin($this->normal_user);
     $this->drupalGet('');
     $this->assertText($current_content, 'Block content displays.');
@@ -69,7 +69,7 @@ function testCachePerRole() {
     // Change the content, but the cached copy should still be served.
     $old_content = $current_content;
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
     $this->drupalGet('');
     $this->assertText($old_content, 'Block is served from the cache.');
 
@@ -82,7 +82,7 @@ function testCachePerRole() {
     // Test whether the cached data is served for the correct users.
     $old_content = $current_content;
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
     $this->drupalLogout();
     $this->drupalGet('');
     $this->assertNoText($old_content, 'Anonymous user does not see content cached per-role for normal user.');
@@ -106,14 +106,14 @@ function testCachePerRole() {
   function testCacheGlobal() {
     $this->setCacheMode(DRUPAL_CACHE_GLOBAL);
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
 
     $this->drupalGet('');
     $this->assertText($current_content, 'Block content displays.');
 
     $old_content = $current_content;
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
 
     $this->drupalLogout();
     $this->drupalGet('user');
@@ -126,7 +126,7 @@ function testCacheGlobal() {
   function testNoCache() {
     $this->setCacheMode(DRUPAL_NO_CACHE);
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
 
     // If DRUPAL_NO_CACHE has no effect, the next request would be cached.
     $this->drupalGet('');
@@ -134,7 +134,7 @@ function testNoCache() {
 
     // A cached copy should not be served.
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
     $this->drupalGet('');
     $this->assertText($current_content, 'DRUPAL_NO_CACHE prevents blocks from being cached.');
   }
@@ -145,7 +145,7 @@ function testNoCache() {
   function testCachePerUser() {
     $this->setCacheMode(DRUPAL_CACHE_PER_USER);
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
     $this->drupalLogin($this->normal_user);
 
     $this->drupalGet('');
@@ -153,7 +153,7 @@ function testCachePerUser() {
 
     $old_content = $current_content;
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
 
     $this->drupalGet('');
     $this->assertText($old_content, 'Block is served from per-user cache.');
@@ -173,14 +173,14 @@ function testCachePerUser() {
   function testCachePerPage() {
     $this->setCacheMode(DRUPAL_CACHE_PER_PAGE);
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
 
     $this->drupalGet('node');
     $this->assertText($current_content, 'Block content displays on the node page.');
 
     $old_content = $current_content;
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
 
     $this->drupalGet('user');
     $this->assertNoText($old_content, 'Block content cached for the node page does not show up for the user page.');
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
index ed2f280..31bce89 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
@@ -36,7 +36,7 @@ function setUp() {
 
     // Make sure the block has some content so it will appear.
     $current_content = $this->randomName();
-    state()->set('block_test.content', $current_content);
+    \Drupal::state()->set('block_test.content', $current_content);
 
     // Enable our test blocks.
     $this->drupalPlaceBlock('system_menu_block:menu-tools');
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php
index 7ac3648..6562545 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTitleXSSTest.php
@@ -39,7 +39,7 @@ protected function setUp() {
    * Test XSS in title.
    */
   function testXSSInTitle() {
-    state()->set('block_test.content', $this->randomName());
+    \Drupal::state()->set('block_test.content', $this->randomName());
     $this->drupalGet('');
     $this->assertNoRaw('<script>alert("XSS label");</script>', 'The block title was properly sanitized when rendered.');
 
diff --git a/core/modules/block/tests/lib/Drupal/block_test/Plugin/Block/TestCacheBlock.php b/core/modules/block/tests/lib/Drupal/block_test/Plugin/Block/TestCacheBlock.php
index 8dcea55..1bde917 100644
--- a/core/modules/block/tests/lib/Drupal/block_test/Plugin/Block/TestCacheBlock.php
+++ b/core/modules/block/tests/lib/Drupal/block_test/Plugin/Block/TestCacheBlock.php
@@ -38,7 +38,7 @@ public function settings() {
    */
   protected function blockBuild() {
     return array(
-      '#children' => state()->get('block_test.content'),
+      '#children' => \Drupal::state()->get('block_test.content'),
     );
   }
 
diff --git a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php
index 9ddd06a..7dcfb1b 100644
--- a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php
+++ b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php
@@ -110,7 +110,7 @@ function _testColor($theme, $test_values) {
     $config->set('css.preprocess', 1);
     $config->save();
     $this->drupalGet('<front>');
-    $stylesheets = state()->get('drupal_css_cache_files') ?: array();
+    $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array();
     $stylesheet_content = '';
     foreach ($stylesheets as $key => $uri) {
       $stylesheet_content .= join("\n", file(drupal_realpath($uri)));
diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install
index 9640304..0361b50 100644
--- a/core/modules/comment/comment.install
+++ b/core/modules/comment/comment.install
@@ -29,7 +29,7 @@ function comment_uninstall() {
   }
 
   // Remove states.
-  state()->delete('comment.node_comment_statistics_scale');
+  Drupal::state()->delete('comment.node_comment_statistics_scale');
 }
 
 /**
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 9895b1f..0415f3a 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1259,7 +1259,7 @@ function comment_node_update_index(EntityInterface $node, $langcode) {
  */
 function comment_update_index() {
   // Store the maximum possible comments per thread (used for ranking by reply count)
-  state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField()));
+  Drupal::state()->set('comment.node_comment_statistics_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField()));
 }
 
 /**
@@ -1975,7 +1975,7 @@ function comment_ranking() {
       ),
       // Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
       'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))',
-      'arguments' => array(':scale' => state()->get('comment.node_comment_statistics_scale') ?: 0),
+      'arguments' => array(':scale' => Drupal::state()->get('comment.node_comment_statistics_scale') ?: 0),
     ),
   );
 }
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
index 6dec469..0fdbb61 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php
@@ -52,7 +52,7 @@ function setUp() {
     $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
 
     // Enable content language negotiation UI.
-    state()->set('language_test.content_language_type', TRUE);
+    \Drupal::state()->set('language_test.content_language_type', TRUE);
 
     // Set interface language detection to user and content language detection
     // to URL. Disable inheritance from interface language to ensure content
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
index 1847a98..10ff0a7 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php
@@ -202,7 +202,7 @@ function testListUI() {
     $this->drupalPost(NULL, $edit, t('Save'));
 
     // Ensure that the entity's sort method was called.
-    $this->assertTrue(state()->get('config_entity_sort'), 'ConfigTest::sort() was called.');
+    $this->assertTrue(\Drupal::state()->get('config_entity_sort'), 'ConfigTest::sort() was called.');
 
     // Confirm that the user is returned to the listing, and verify that the
     // text of the label and machine name appears in the list (versus elsewhere
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
index e2e910f..a2ff4ee 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php
@@ -191,7 +191,7 @@ function testCRUD() {
     }
 
     // Test config entity prepopulation.
-    state()->set('config_test.prepopulate', TRUE);
+    \Drupal::state()->set('config_test.prepopulate', TRUE);
     $config_test = entity_create('config_test', array('foo' => 'bar'));
     $this->assertEqual($config_test->get('foo'), 'baz', 'Initial value correctly populated');
   }
diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module
index 9949d90..a5426dd 100644
--- a/core/modules/config/tests/config_test/config_test.module
+++ b/core/modules/config/tests/config_test/config_test.module
@@ -142,7 +142,7 @@ function config_test_cache_flush() {
  * Implements hook_ENTITY_TYPE_create().
  */
 function config_test_config_test_create(ConfigTest $config_test) {
-  if (state()->get('config_test.prepopulate')) {
+  if (Drupal::state()->get('config_test.prepopulate')) {
     $config_test->set('foo', 'baz');
   }
 }
diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
index 2337a69..72df0fa 100644
--- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
+++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Plugin/Core/Entity/ConfigTest.php
@@ -97,7 +97,7 @@ public function getExportProperties() {
    * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
    */
   public static function sort($a, $b) {
-    state()->set('config_entity_sort', TRUE);
+    \Drupal::state()->set('config_entity_sort', TRUE);
     return parent::sort($a, $b);
   }
 
diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php
index 1fee823..cc8e3c0 100644
--- a/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php
+++ b/core/modules/editor/lib/Drupal/editor/Tests/EditorManagerTest.php
@@ -113,7 +113,7 @@ function testManager() {
 
     // Case 4: a text editor available associated, but now with its JS settings
     // being altered via hook_editor_js_settings_alter().
-    state()->set('editor_test_js_settings_alter_enabled', TRUE);
+    \Drupal::state()->set('editor_test_js_settings_alter_enabled', TRUE);
     $expected['js'][0]['data']['editor']['formats']['full_html']['editorSettings']['ponyModeEnabled'] = FALSE;
     $this->assertIdentical($expected, $this->editorManager->getAttachments(array('filtered_html', 'full_html')), 'hook_editor_js_settings_alter() works correctly.');
   }
diff --git a/core/modules/editor/tests/modules/editor_test.module b/core/modules/editor/tests/modules/editor_test.module
index b638394..cdaf52e 100644
--- a/core/modules/editor/tests/modules/editor_test.module
+++ b/core/modules/editor/tests/modules/editor_test.module
@@ -31,7 +31,7 @@ function editor_test_editor_default_settings_alter(&$settings, $editor) {
  */
 function editor_test_editor_js_settings_alter(&$settings) {
   // Allow tests to enable or disable this alter hook.
-  if (!state()->get('editor_test_js_settings_alter_enabled', FALSE)) {
+  if (!Drupal::state()->get('editor_test_js_settings_alter_enabled', FALSE)) {
     return;
   }
 
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
index dd093d5..dad0e54 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
@@ -321,7 +321,7 @@ function testFieldInfoCache() {
     // field_test_entity_info(). Ensure the test field is still in the returned
     // array.
     field_info_cache_clear();
-    state()->set('field_test.clear_info_cache_in_hook_entity_info', TRUE);
+    \Drupal::state()->set('field_test.clear_info_cache_in_hook_entity_info', TRUE);
     $fields = field_info_fields();
     $this->assertTrue(isset($fields[$field_name]), 'The test field is found in the array returned by field_info_fields() even if its cache is cleared while being rebuilt.');
   }
diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
index 4aa9613..ae52f2e 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
@@ -82,7 +82,7 @@ function testFieldAvailableLanguages() {
     field_test_entity_info_translatable('test_entity', TRUE);
 
     // Test hook_field_languages() invocation on a translatable field.
-    state()->set('field_test.field_available_languages_alter', TRUE);
+    \Drupal::state()->set('field_test.field_available_languages_alter', TRUE);
     $langcodes = field_content_languages();
     $available_langcodes = field_available_languages($this->entity_type, $this->field);
     foreach ($available_langcodes as $delta => $langcode) {
@@ -381,7 +381,7 @@ function testFieldDisplayLanguage() {
     $this->assertTrue(isset($entity->{$this->field_name}[$langcode]) && $langcode != $requested_langcode, format_string('The display language for the (single) field %field_name is %language.', array('%field_name' => $field_name, '%language' => $langcode)));
 
     // Test field_language() basic behavior without language fallback.
-    state()->set('field_test.language_fallback', FALSE);
+    \Drupal::state()->set('field_test.language_fallback', FALSE);
     $entity->{$this->field_name}[$requested_langcode] = mt_rand(1, 127);
     drupal_static_reset('field_language');
     $display_langcode = field_language($entity, $this->field_name, $requested_langcode);
diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc
index 817986f..d781264 100644
--- a/core/modules/field/tests/modules/field_test/field_test.entity.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc
@@ -14,7 +14,7 @@
 function field_test_entity_info() {
   // If requested, clear the field cache while this is being called. See
   // Drupal\field\Tests\FieldInfoTest::testFieldInfoCache().
-  if (state()->get('field_test.clear_info_cache_in_hook_entity_info')) {
+  if (Drupal::state()->get('field_test.clear_info_cache_in_hook_entity_info')) {
     field_info_cache_clear();
   }
 }
@@ -56,7 +56,7 @@ function field_test_entity_bundle_info_alter(&$bundles) {
   $entity_info = entity_get_info();
   foreach ($bundles as $entity_type => $info) {
     if ($entity_info[$entity_type]['module'] == 'field_test') {
-      $bundles[$entity_type] = state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
+      $bundles[$entity_type] = Drupal::state()->get('field_test_bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
       if ($entity_type == 'test_entity_bundle') {
         $bundles[$entity_type] += array('test_entity_2' => array('label' => 'Test entity 2'));
       }
@@ -90,9 +90,9 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable
  *   name will be used.
  */
 function field_test_create_bundle($bundle, $text = NULL) {
-  $bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
+  $bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
   $bundles += array($bundle => array('label' => $text ? $text : $bundle));
-  state()->set('field_test.bundles', $bundles);
+  Drupal::state()->set('field_test.bundles', $bundles);
 
   $info = entity_get_info();
   foreach ($info as $type => $type_info) {
@@ -111,10 +111,10 @@ function field_test_create_bundle($bundle, $text = NULL) {
  *   The new machine-readable name of the bundle.
  */
 function field_test_rename_bundle($bundle_old, $bundle_new) {
-  $bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
+  $bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
   $bundles[$bundle_new] = $bundles[$bundle_old];
   unset($bundles[$bundle_old]);
-  state()->set('field_test.bundles', $bundles);
+  Drupal::state()->set('field_test.bundles', $bundles);
 
   $info = entity_get_info();
   foreach ($info as $type => $type_info) {
@@ -131,9 +131,9 @@ function field_test_rename_bundle($bundle_old, $bundle_new) {
  *   The machine-readable name of the bundle to delete.
  */
 function field_test_delete_bundle($bundle) {
-  $bundles = state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
+  $bundles = Drupal::state()->get('field_test.bundles') ?: array('test_bundle' => array('label' => 'Test Bundle'));
   unset($bundles[$bundle]);
-  state()->set('field_test.bundles', $bundles);
+  Drupal::state()->set('field_test.bundles', $bundles);
 
   $info = entity_get_info();
   foreach ($info as $type => $type_info) {
diff --git a/core/modules/field/tests/modules/field_test/field_test.module b/core/modules/field/tests/modules/field_test/field_test.module
index 2e62f77..c2070f2 100644
--- a/core/modules/field/tests/modules/field_test/field_test.module
+++ b/core/modules/field/tests/modules/field_test/field_test.module
@@ -106,7 +106,7 @@ function field_test_field_test_op_multiple($entity_type, $entities, $field, $ins
  * Implements hook_field_available_languages_alter().
  */
 function field_test_field_available_languages_alter(&$langcodes, $context) {
-  if (state()->get('field_test.field_available_languages_alter')) {
+  if (Drupal::state()->get('field_test.field_available_languages_alter')) {
     // Add an unavailable language code.
     $langcodes[] = 'xx';
     // Remove an available language code.
@@ -119,7 +119,7 @@ function field_test_field_available_languages_alter(&$langcodes, $context) {
  * Implements hook_field_language_alter().
  */
 function field_test_field_language_alter(&$display_langcode, $context) {
-  if (state()->get('field_test.language_fallback') ?: TRUE) {
+  if (Drupal::state()->get('field_test.language_fallback') ?: TRUE) {
     field_language_fallback($display_langcode, $context['entity'], $context['langcode']);
   }
 }
diff --git a/core/modules/field/tests/modules/field_test/field_test.storage.inc b/core/modules/field/tests/modules/field_test/field_test.storage.inc
index 7705392..d3a7f82 100644
--- a/core/modules/field/tests/modules/field_test/field_test.storage.inc
+++ b/core/modules/field/tests/modules/field_test/field_test.storage.inc
@@ -71,10 +71,10 @@ function field_test_field_storage_details_alter(&$details, $field) {
  */
 function _field_test_storage_data($data = NULL) {
   if (!isset($data)) {
-    return state()->get('field_test.storage_data');
+    return Drupal::state()->get('field_test.storage_data');
   }
   else {
-    state()->set('field_test.storage_data', $data);
+    Drupal::state()->set('field_test.storage_data', $data);
   }
 }
 
diff --git a/core/modules/field_sql_storage/field_sql_storage.install b/core/modules/field_sql_storage/field_sql_storage.install
index 03390a6..8d14ca8 100644
--- a/core/modules/field_sql_storage/field_sql_storage.install
+++ b/core/modules/field_sql_storage/field_sql_storage.install
@@ -77,7 +77,7 @@ function field_sql_storage_update_dependencies() {
  * Renames the 'language' column to 'langcode' in field data tables.
  */
 function field_sql_storage_update_8000(&$sandbox) {
-  // Get field definitions from config, and deleted fields from state().
+  // Get field definitions from config, and deleted fields from state system.
   $config_names = config_get_storage_names_with_prefix('field.field');
   $deleted_fields = Drupal::state()->get('field.field.deleted') ?: array();
   // Ditch UUID keys, we will iterate through deleted fields using a numeric
diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module
index cce8734..51115b8 100644
--- a/core/modules/field_ui/field_ui.module
+++ b/core/modules/field_ui/field_ui.module
@@ -249,7 +249,7 @@ function field_ui_element_info() {
 function field_ui_entity_bundle_create($entity_type, $bundle) {
   // When a new bundle is created, the menu needs to be rebuilt to add our
   // menu item tabs.
-  state()->set('menu_rebuild_needed', TRUE);
+  Drupal::state()->set('menu_rebuild_needed', TRUE);
 }
 
 /**
@@ -258,7 +258,7 @@ function field_ui_entity_bundle_create($entity_type, $bundle) {
 function field_ui_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
   // When a bundle is renamed, the menu needs to be rebuilt to add our
   // menu item tabs.
-  state()->set('menu_rebuild_needed', TRUE);
+  Drupal::state()->set('menu_rebuild_needed', TRUE);
 }
 
 /**
@@ -355,12 +355,12 @@ function field_ui_library_info() {
  * Implements hook_view_mode_presave().
  */
 function field_ui_view_mode_presave(EntityViewModeInterface $view_mode) {
-  state()->set('menu_rebuild_needed', TRUE);
+  Drupal::state()->set('menu_rebuild_needed', TRUE);
 }
 
 /**
  * Implements hook_view_mode_delete().
  */
 function field_ui_view_mode_delete(EntityViewModeInterface $view_mode) {
-  state()->set('menu_rebuild_needed', TRUE);
+  Drupal::state()->set('menu_rebuild_needed', TRUE);
 }
diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
index 925ac7b..68f695b 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
@@ -32,7 +32,7 @@ public static function getInfo() {
   public function setUp() {
     parent::setUp();
     node_access_rebuild();
-    state()->set('node_access_test.private', TRUE);
+    \Drupal::state()->set('node_access_test.private', TRUE);
   }
 
   /**
diff --git a/core/modules/file/tests/file_test/file_test.module b/core/modules/file/tests/file_test/file_test.module
index 8cff297..b5c98eb 100644
--- a/core/modules/file/tests/file_test/file_test.module
+++ b/core/modules/file/tests/file_test/file_test.module
@@ -158,14 +158,14 @@ function file_test_reset() {
     'move' => array(),
     'delete' => array(),
   );
-  state()->set('file_test.results', $results);
+  Drupal::state()->set('file_test.results', $results);
 
   // These hooks will return these values, see file_test_set_return().
   $return = array(
     'validate' => array(),
     'download' => NULL,
   );
-  state()->set('file_test.return', $return);
+  Drupal::state()->set('file_test.return', $return);
 }
 
 /**
@@ -183,7 +183,7 @@ function file_test_reset() {
  * @see file_test_reset()
  */
 function file_test_get_calls($op) {
-  $results = state()->get('file_test.results') ?: array();
+  $results = Drupal::state()->get('file_test.results') ?: array();
   return $results[$op];
 }
 
@@ -196,7 +196,7 @@ function file_test_get_calls($op) {
  *   passed to each call.
  */
 function file_test_get_all_calls() {
-  return state()->get('file_test.results') ?: array();
+  return Drupal::state()->get('file_test.results') ?: array();
 }
 
 /**
@@ -212,9 +212,9 @@ function file_test_get_all_calls() {
  * @see file_test_reset()
  */
 function _file_test_log_call($op, $args) {
-  $results = state()->get('file_test.results') ?: array();
+  $results = Drupal::state()->get('file_test.results') ?: array();
   $results[$op][] = $args;
-  state()->set('file_test.results', $results);
+  Drupal::state()->set('file_test.results', $results);
 }
 
 /**
@@ -230,7 +230,7 @@ function _file_test_log_call($op, $args) {
  * @see file_test_reset()
  */
 function _file_test_get_return($op) {
-  $return = state()->get('file_test.return') ?: array($op => NULL);
+  $return = Drupal::state()->get('file_test.return') ?: array($op => NULL);
   return $return[$op];
 }
 
@@ -246,9 +246,9 @@ function _file_test_get_return($op) {
  * @see file_test_reset()
  */
 function file_test_set_return($op, $value) {
-  $return = state()->get('file_test.return') ?: array();
+  $return = Drupal::state()->get('file_test.return') ?: array();
   $return[$op] = $value;
-  state()->set('file_test.return', $return);
+  Drupal::state()->set('file_test.return', $return);
 }
 
 /**
@@ -320,7 +320,7 @@ function file_test_file_predelete(File $file) {
 function file_test_file_url_alter(&$uri) {
   // Only run this hook when this variable is set. Otherwise, we'd have to add
   // another hidden test module just for this hook.
-  $alter_mode = state()->get('file_test.hook_file_url_alter');
+  $alter_mode = Drupal::state()->get('file_test.hook_file_url_alter');
   if (!$alter_mode) {
     return;
   }
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
index b5d3b39..1491ce2 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
@@ -33,7 +33,7 @@ public static function getInfo() {
   function setUp() {
     parent::setUp();
     node_access_rebuild();
-    state()->set('node_access_test.private', TRUE);
+    \Drupal::state()->set('node_access_test.private', TRUE);
   }
 
   /**
diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index cf4cf63..17bb491 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -273,7 +273,7 @@ function image_form_system_file_system_settings_alter(&$form, &$form_state) {
  */
 function image_system_file_system_settings_submit($form, &$form_state) {
   if ($form['file_public_path']['#default_value'] !== $form_state['values']['file_public_path']) {
-    state()->set('menu_rebuild_needed', TRUE);
+    Drupal::state()->set('menu_rebuild_needed', TRUE);
   }
 }
 
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php
index 7b1b2ed..52d3f4a 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageStylesPathAndUrlTest.php
@@ -123,7 +123,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
     $original_uri = file_unmanaged_copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME);
     // Let the image_module_test module know about this file, so it can claim
     // ownership in hook_file_download().
-    state()->set('image.test_file_download', $original_uri);
+    \Drupal::state()->set('image.test_file_download', $original_uri);
     $this->assertNotIdentical(FALSE, $original_uri, 'Created the generated image file.');
 
     // Get the URL of a file that has not been generated and try to create it.
@@ -170,7 +170,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
 
       // Make sure that access is denied for existing style files if we do not
       // have access.
-      state()->delete('image.test_file_download');
+      \Drupal::state()->delete('image.test_file_download');
       $this->drupalGet($generate_url);
       $this->assertResponse(403, 'Confirmed that access is denied for the private image style.');
 
@@ -211,7 +211,7 @@ function _testImageStyleUrlAndPath($scheme, $clean_url = TRUE, $extra_slash = FA
     $original_uri = file_unmanaged_copy($file->uri, $scheme . '://', FILE_EXISTS_RENAME);
     // Let the image_module_test module know about this file, so it can claim
     // ownership in hook_file_download().
-    state()->set('image.test_file_download', $original_uri);
+    \Drupal::state()->set('image.test_file_download', $original_uri);
 
     // Suppress the security token in the URL, then get the URL of a file that
     // has not been created and try to create it. Check that the security token
diff --git a/core/modules/image/tests/image_module_test.module b/core/modules/image/tests/image_module_test.module
index 2cb078e..7cc6cdd 100644
--- a/core/modules/image/tests/image_module_test.module
+++ b/core/modules/image/tests/image_module_test.module
@@ -6,7 +6,7 @@
  */
 
 function image_module_test_file_download($uri) {
-  $default_uri = state()->get('image.test_file_download') ?: FALSE;
+  $default_uri = Drupal::state()->get('image.test_file_download') ?: FALSE;
   if ($default_uri == $uri) {
     return array('X-Image-Owned-By' => 'image_module_test');
   }
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php
index baef5ca..e580e5c 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php
@@ -43,8 +43,8 @@ function setUp() {
    */
   function testInfoAlterations() {
     // Enable language type/negotiation info alterations.
-    state()->set('language_test.language_types', TRUE);
-    state()->set('language_test.language_negotiation_info', TRUE);
+    \Drupal::state()->set('language_test.language_types', TRUE);
+    \Drupal::state()->set('language_test.language_negotiation_info', TRUE);
     $this->languageNegotiationUpdate();
 
     // Check that fixed language types are properly configured without the need
@@ -53,7 +53,7 @@ function testInfoAlterations() {
 
     // Make the content language type configurable by updating the language
     // negotiation settings with the proper flag enabled.
-    state()->set('language_test.content_language_type', TRUE);
+    \Drupal::state()->set('language_test.content_language_type', TRUE);
     $this->languageNegotiationUpdate();
     $type = Language::TYPE_CONTENT;
     $language_types = variable_get('language_types', language_types_get_default());
@@ -74,7 +74,7 @@ function testInfoAlterations() {
 
     // Remove the interface language negotiation method by updating the language
     // negotiation settings with the proper flag enabled.
-    state()->set('language_test.language_negotiation_info_alter', TRUE);
+    \Drupal::state()->set('language_test.language_negotiation_info_alter', TRUE);
     $this->languageNegotiationUpdate();
     $negotiation = variable_get("language_negotiation_$type", array());
     $this->assertFalse(isset($negotiation[$interface_method_id]), 'Interface language negotiation method removed from the stored settings.');
@@ -94,7 +94,7 @@ function testInfoAlterations() {
 
     // Check language negotiation results.
     $this->drupalGet('');
-    $last = state()->get('language_test.language_negotiation_last');
+    $last = \Drupal::state()->get('language_test.language_negotiation_last');
     foreach (language_types_get_all() as $type) {
       $langcode = $last[$type];
       $value = $type == Language::TYPE_CONTENT || strpos($type, 'test') !== FALSE ? 'it' : 'en';
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
index 0342773..799d8d5 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php
@@ -372,7 +372,7 @@ protected function runTest($test) {
         ->save();
     }
     if (!empty($test['language_test_domain'])) {
-      state()->set('language_test.domain', $test['language_test_domain']);
+      \Drupal::state()->set('language_test.domain', $test['language_test_domain']);
     }
     $this->container->get('language_manager')->reset();
     $this->drupalGet($test['path'], array(), $test['http_header']);
diff --git a/core/modules/language/tests/language_test/language_test.module b/core/modules/language/tests/language_test/language_test.module
index 4877606..150e024 100644
--- a/core/modules/language/tests/language_test/language_test.module
+++ b/core/modules/language/tests/language_test/language_test.module
@@ -24,7 +24,7 @@ function language_test_page_build() {
  * Implements hook_language_types_info().
  */
 function language_test_language_types_info() {
-  if (state()->get('language_test.language_types')) {
+  if (Drupal::state()->get('language_test.language_types')) {
     return array(
       'test_language_type' => array(
         'name' => t('Test'),
@@ -41,7 +41,7 @@ function language_test_language_types_info() {
  * Implements hook_language_types_info_alter().
  */
 function language_test_language_types_info_alter(array &$language_types) {
-  if (state()->get('language_test.content_language_type')) {
+  if (Drupal::state()->get('language_test.content_language_type')) {
     unset($language_types[Language::TYPE_CONTENT]['fixed']);
   }
 }
@@ -50,7 +50,7 @@ function language_test_language_types_info_alter(array &$language_types) {
  * Implements hook_language_negotiation_info().
  */
 function language_test_language_negotiation_info() {
-  if (state()->get('language_test.language_negotiation_info')) {
+  if (Drupal::state()->get('language_test.language_negotiation_info')) {
     $info = array(
       'callbacks' => array(
         'negotiation' => 'language_test_language_negotiation_method',
@@ -77,7 +77,7 @@ function language_test_language_negotiation_info() {
  * Implements hook_language_negotiation_info_alter().
  */
 function language_test_language_negotiation_info_alter(array &$negotiation_info) {
-  if (state()->get('language_test.language_negotiation_info_alter')) {
+  if (Drupal::state()->get('language_test.language_negotiation_info_alter')) {
     unset($negotiation_info[LANGUAGE_NEGOTIATION_INTERFACE]);
   }
 }
@@ -90,7 +90,7 @@ function language_test_store_language_negotiation() {
   foreach (language_types_get_all() as $type) {
     $last[$type] = language($type)->langcode;
   }
-  state()->set('language_test.language_negotiation_last', $last);
+  Drupal::state()->set('language_test.language_negotiation_last', $last);
 }
 
 /**
diff --git a/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php b/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php
index aa32076..991755e 100644
--- a/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php
+++ b/core/modules/language/tests/language_test/lib/Drupal/language_test/LanguageTestManager.php
@@ -19,7 +19,7 @@ class LanguageTestManager extends LanguageManager {
    * Overrides \Drupal\Core\Language\LanguageManager::init().
    */
   public function init() {
-    if ($test_domain = state()->get('language_test.domain')) {
+    if ($test_domain = \Drupal::state()->get('language_test.domain')) {
       $_SERVER['HTTP_HOST'] = $test_domain;
     }
     return parent::init();
diff --git a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php
index 126ee04..66f5b8a 100644
--- a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php
+++ b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php
@@ -156,7 +156,7 @@ function getHeader() {
   function setHeader(PoHeader $header) {
     $this->_header = $header;
     $config = config('locale.settings');
-    $locale_plurals = state()->get('locale.translation.plurals') ?: array();
+    $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
 
     // Check for options.
     $options = $this->getOptions();
@@ -180,7 +180,7 @@ function setHeader(PoHeader $header) {
           'plurals' => $nplurals,
           'formula' => $formula,
         );
-        state()->set('locale.translation.plurals', $locale_plurals);
+        \Drupal::state()->set('locale.translation.plurals', $locale_plurals);
       }
     }
   }
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
index 0392c0f..aef64f4 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
@@ -61,7 +61,7 @@ function testStandalonePoFile() {
     $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 8, '%update' => 0, '%delete' => 0)), t('The translation file was successfully imported.'));
 
     // This import should have saved plural forms to have 2 variants.
-    $locale_plurals = state()->get('locale.translation.plurals') ?: array();
+    $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
     $this->assert($locale_plurals['fr']['plurals'] == 2, t('Plural number initialized.'));
 
     // Ensure we were redirected correctly.
@@ -115,7 +115,7 @@ function testStandalonePoFile() {
     $this->assertText(t('No strings available.'), t('String not overwritten by imported string.'));
 
     // This import should not have changed number of plural forms.
-    $locale_plurals = state()->get('locale.translation.plurals') ?: array();
+    $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
     $this->assert($locale_plurals['fr']['plurals'] == 2, t('Plural numbers untouched.'));
 
     // Try importing a .po file with overriding strings, and ensure existing
@@ -136,7 +136,7 @@ function testStandalonePoFile() {
     $this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
     $this->assertNoText(t('No strings available.'), t('String overwritten by imported string.'));
     // This import should have changed number of plural forms.
-    $locale_plurals = state()->get('locale.translation.plurals') ?: array();
+    $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
     $this->assert($locale_plurals['fr']['plurals'] == 3, t('Plural numbers changed.'));
 
     // Importing a .po file and mark its strings as customized strings.
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
index 1547a72..385c841 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
@@ -259,7 +259,7 @@ function testJavaScriptTranslation() {
     // Trigger JavaScript translation parsing and building.
     _locale_rebuild_js($langcode);
 
-    $locale_javascripts = state()->get('locale.translation.javascript') ?: array();
+    $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
     $js_file = 'public://' . $config->get('javascript.directory') . '/' . $langcode . '_' . $locale_javascripts[$langcode] . '.js';
     $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('not found'))));
 
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
index 85e4b1c..1c5d215 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
@@ -81,7 +81,7 @@ function testUninstallProcess() {
     $this->drupalPost('admin/config/regional/translate', $edit, t('Save translations'));
     _locale_rebuild_js('fr');
     $config = config('locale.settings');
-    $locale_javascripts = state()->get('locale.translation.javascript') ?: array();
+    $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array();
     $js_file = 'public://' . $config->get('javascript.directory') . '/fr_' . $locale_javascripts['fr'] . '.js';
     $this->assertTrue($result = file_exists($js_file), t('JavaScript file created: %file', array('%file' => $result ? $js_file : t('none'))));
 
@@ -133,7 +133,7 @@ function testUninstallProcess() {
     $this->assertFalse(config('language.negotiation')->get('session.parameter'), t('Visit language negotiation method settings cleared.'));
 
     // Check JavaScript parsed.
-    $javascript_parsed_count = count(state()->get('system.javascript_parsed') ?: array());
+    $javascript_parsed_count = count(\Drupal::state()->get('system.javascript_parsed') ?: array());
     $this->assertEqual($javascript_parsed_count, 0, t('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count)));
   }
 }
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php
index 836ee97..3c9d390 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php
@@ -59,9 +59,9 @@ function testInterface() {
     // Drupal core is probably in 8.x, but tests may also be executed with
     // stable releases. As this is an uncontrolled factor in the test, we will
     // ignore Drupal core here and continue with the prepared modules.
-    $status = state()->get('locale.translation_status');
+    $status = \Drupal::state()->get('locale.translation_status');
     unset($status['drupal']);
-    state()->set('locale.translation_status', $status);
+    \Drupal::state()->set('locale.translation_status', $status);
 
     // One language added, all translations up to date.
     $this->drupalGet('admin/reports/status');
@@ -71,9 +71,9 @@ function testInterface() {
     $this->assertText(t('All translations up to date.'), 'Translations up to date');
 
     // Set locale_test_translate module to have a local translation available.
-    $status = state()->get('locale.translation_status');
+    $status = \Drupal::state()->get('locale.translation_status');
     $status['locale_test_translate']['de']->type = 'local';
-    state()->set('locale.translation_status', $status);
+    \Drupal::state()->set('locale.translation_status', $status);
 
     // Check if updates are available for German.
     $this->drupalGet('admin/reports/status');
@@ -84,10 +84,10 @@ function testInterface() {
 
     // Set locale_test_translate module to have a dev release and no
     // translation found.
-    $status = state()->get('locale.translation_status');
+    $status = \Drupal::state()->get('locale.translation_status');
     $status['locale_test_translate']['de']->version = '1.3-dev';
     unset($status['locale_test_translate']['de']->type);
-    state()->set('locale.translation_status', $status);
+    \Drupal::state()->set('locale.translation_status', $status);
 
     // Check if no updates were found.
     $this->drupalGet('admin/reports/status');
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
index e5dccbd..53a4c03 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
@@ -185,7 +185,7 @@ private function setTranslationFiles() {
 
     // A flag is set to let the locale_test module replace the project data with
     // a set of test projects which match the below project files.
-    state()->set('locale.test_projects_alter', TRUE);
+    \Drupal::state()->set('locale.test_projects_alter', TRUE);
 
     // Setup the environment.
     $public_path = variable_get('file_public_path', conf_path() . '/files');
@@ -314,7 +314,7 @@ function testUpdateProjects() {
     // Make the test modules look like a normal custom module. i.e. make the
     // modules not hidden. locale_test_system_info_alter() modifies the project
     // info of the locale_test and locale_test_translate modules.
-    state()->set('locale.test_system_info_alter', TRUE);
+    \Drupal::state()->set('locale.test_system_info_alter', TRUE);
     $this->resetAll();
 
     // Check if interface translation data is collected from hook_info.
@@ -332,7 +332,7 @@ function testUpdateProjectsHidden() {
     $config = config('locale.settings');
 
     // Make the test modules look like a normal custom module.
-    state()->set('locale.test_system_info_alter', TRUE);
+    \Drupal::state()->set('locale.test_system_info_alter', TRUE);
     $this->resetAll();
 
     // Set test condition: include disabled modules when building a project list.
@@ -364,7 +364,7 @@ function testUpdateCheckStatus() {
     $config = config('locale.settings');
     // Set a flag to let the locale_test module replace the project data with a
     // set of test projects.
-    state()->set('locale.test_projects_alter', TRUE);
+    \Drupal::state()->set('locale.test_projects_alter', TRUE);
 
     // Create local and remote translations files.
     $this->setTranslationFiles();
@@ -378,7 +378,7 @@ function testUpdateCheckStatus() {
 
     // Get status of translation sources at local file system.
     $this->drupalGet('admin/reports/translations/check');
-    $result = state()->get('locale.translation_status');
+    $result = \Drupal::state()->get('locale.translation_status');
     $this->assertEqual($result['contrib_module_one']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_one found');
     $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_old, 'Translation timestamp found');
     $this->assertEqual($result['contrib_module_two']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_two found');
@@ -394,7 +394,7 @@ function testUpdateCheckStatus() {
 
     // Get status of translation sources at both local and remote locations.
     $this->drupalGet('admin/reports/translations/check');
-    $result = state()->get('locale.translation_status');
+    $result = \Drupal::state()->get('locale.translation_status');
     $this->assertEqual($result['contrib_module_one']['de']->type, 'remote', 'Translation of contrib_module_one found');
     $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found');
     $this->assertEqual($result['contrib_module_two']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_two found');
@@ -442,7 +442,7 @@ function testUpdateImportSourceRemote() {
     $this->drupalPost('admin/reports/translations', array(), t('Update translations'));
 
     // Check if the translation has been updated, using the status cache.
-    $status = state()->get('locale.translation_status');
+    $status = \Drupal::state()->get('locale.translation_status');
     $this->assertEqual($status['contrib_module_one']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_one found');
     $this->assertEqual($status['contrib_module_two']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_two found');
     $this->assertEqual($status['contrib_module_three']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_three found');
@@ -497,7 +497,7 @@ function testUpdateImportSourceLocal() {
     $this->drupalPost('admin/reports/translations', array(), t('Update translations'));
 
     // Check if the translation has been updated, using the status cache.
-    $status = state()->get('locale.translation_status');
+    $status = \Drupal::state()->get('locale.translation_status');
     $this->assertEqual($status['contrib_module_one']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_one found');
     $this->assertEqual($status['contrib_module_two']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_two found');
     $this->assertEqual($status['contrib_module_three']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_three found');
@@ -553,7 +553,7 @@ function testUpdateImportWithoutDirectory() {
     $this->drupalPost('admin/reports/translations', array(), t('Update translations'));
 
     // Check if the translation has been updated, using the status cache.
-    $status = state()->get('locale.translation_status');
+    $status = \Drupal::state()->get('locale.translation_status');
     $this->assertEqual($status['contrib_module_one']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_one found');
     $this->assertEqual($status['contrib_module_two']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_two found');
     $this->assertEqual($status['contrib_module_three']['de']->type, LOCALE_TRANSLATION_CURRENT, 'Translation of contrib_module_three found');
@@ -660,7 +660,7 @@ function testUpdateImportModeNone() {
    */
   function testEnableDisableModule() {
     // Make the hidden test modules look like a normal custom module.
-    state()->set('locale.test_system_info_alter', TRUE);
+    \Drupal::state()->set('locale.test_system_info_alter', TRUE);
 
     // Check if there is no translation yet.
     $this->assertTranslation('Tuesday', '', 'de');
@@ -703,7 +703,7 @@ function testEnableDisableModule() {
    */
   function testEnableDisableLanguage() {
     // Make the hidden test modules look like a normal custom module.
-    state()->set('locale.test_system_info_alter', TRUE);
+    \Drupal::state()->set('locale.test_system_info_alter', TRUE);
 
     // Enable a module.
     $edit = array(
@@ -747,7 +747,7 @@ function testEnableDisableLanguage() {
    */
   function testEnableCustomLanguage() {
     // Make the hidden test modules look like a normal custom module.
-    state()->set('locale.test_system_info_alter', TRUE);
+    \Drupal::state()->set('locale.test_system_info_alter', TRUE);
 
     // Enable a module.
     $edit = array(
diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc
index 5ec2752..0c53ec3 100644
--- a/core/modules/locale/locale.compare.inc
+++ b/core/modules/locale/locale.compare.inc
@@ -19,7 +19,7 @@
  */
 function locale_translation_flush_projects() {
   // Followup issue: http://drupal.org/node/1842362
-  // Replace {locale_project} table by state() variable(s).
+  // Replace {locale_project} table by Drupal::state() variable(s).
   db_truncate('locale_project')->execute();
 }
 
diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install
index af08d52..04452ac 100644
--- a/core/modules/locale/locale.install
+++ b/core/modules/locale/locale.install
@@ -28,7 +28,7 @@ function locale_uninstall() {
   $locale_js_directory = 'public://' . $config->get('javascript.directory');
 
   if (is_dir($locale_js_directory)) {
-    $locale_javascripts = state()->get('locale.translation.javascript') ?: array();
+    $locale_javascripts = Drupal::state()->get('locale.translation.javascript') ?: array();
     foreach ($locale_javascripts as $langcode => $file_suffix) {
       if (!empty($file_suffix)) {
         file_unmanaged_delete($locale_js_directory . '/' . $langcode . '_' . $file_suffix . '.js');
@@ -41,9 +41,9 @@ function locale_uninstall() {
   }
 
   // Clear variables.
-  state()->delete('system.javascript_parsed');
-  state()->delete('locale.translation.plurals');
-  state()->delete('locale.translation.javascript');
+  Drupal::state()->delete('system.javascript_parsed');
+  Drupal::state()->delete('locale.translation.plurals');
+  Drupal::state()->delete('locale.translation.javascript');
 
   // Remove all node type language variables. Node module might have been
   // enabled, but may be disabled, so use a wildcard delete.
@@ -297,7 +297,7 @@ function locale_requirements($phase) {
 
     if ($languages) {
       // Determine the status of the translation updates per lanuage.
-      $status = state()->get('locale.translation_status');
+      $status = Drupal::state()->get('locale.translation_status');
       if ($status) {
         foreach ($status as $project_id => $project) {
           foreach ($project as $langcode => $project_info) {
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index e778da8..821f40b 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -450,7 +450,7 @@ function locale_get_plural($count, $langcode = NULL) {
   if (!isset($plural_indexes[$langcode][$count])) {
     // Retrieve and statically cache the plural formulas for all languages.
     if (empty($plural_formulas)) {
-      $plural_formulas = state()->get('locale.translation.plurals') ?: array();
+      $plural_formulas = Drupal::state()->get('locale.translation.plurals') ?: array();
     }
     // If there is a plural formula for the language, evaluate it for the given
     // $count and statically cache the result for the combination of language
@@ -604,7 +604,7 @@ function locale_js_alter(&$javascript) {
   $language_interface = language(Language::TYPE_INTERFACE);
 
   $dir = 'public://' . config('local.settings')->get('javascript.directory');
-  $parsed = state()->get('system.javascript_parsed') ?: array();
+  $parsed = Drupal::state()->get('system.javascript_parsed') ?: array();
   $files = $new_files = FALSE;
 
   foreach ($javascript as $item) {
@@ -637,16 +637,16 @@ function locale_js_alter(&$javascript) {
       unset($parsed['refresh:' . $language_interface->langcode]);
     }
     // Store any changes after refresh was attempted.
-    state()->set('system.javascript_parsed', $parsed);
+    Drupal::state()->set('system.javascript_parsed', $parsed);
   }
   // If no refresh was attempted, but we have new source files, we need
   // to store them too. This occurs if current page is in English.
   elseif ($new_files) {
-    state()->set('system.javascript_parsed', $parsed);
+    Drupal::state()->set('system.javascript_parsed', $parsed);
   }
 
   // Add the translation JavaScript file to the page.
-  $locale_javascripts = state()->get('translation.javascript') ?: array();
+  $locale_javascripts = Drupal::state()->get('translation.javascript') ?: array();
   if ($files && !empty($locale_javascripts[$language_interface->langcode])) {
     // Add the translation JavaScript file to the page.
     $file = $dir . '/' . $language_interface->langcode . '_' . $locale_javascripts[$language_interface->langcode] . '.js';
@@ -965,7 +965,7 @@ function locale_translation_status_save($data) {
   // Followup issue: http://drupal.org/node/1842362
   // Split status storage per module/language and expire individually. This will
   // improve performance for large sites.
-  $status = state()->get('locale.translation_status');
+  $status = Drupal::state()->get('locale.translation_status');
   $status = empty($status) ? array() : $status;
 
   // Merge the new data into the existing structured status array.
@@ -975,8 +975,8 @@ function locale_translation_status_save($data) {
     }
   }
 
-  state()->set('locale.translation_status', $status);
-  state()->set('locale.translation_last_checked', REQUEST_TIME);
+  Drupal::state()->set('locale.translation_status', $status);
+  Drupal::state()->set('locale.translation_last_checked', REQUEST_TIME);
 }
 
 /**
@@ -986,7 +986,7 @@ function locale_translation_status_save($data) {
  *   Language code(s) to be deleted from the cache.
  */
 function locale_translation_status_delete_languages($langcodes) {
-  if ($status = state()->get('locale.translation_status')) {
+  if ($status = Drupal::state()->get('locale.translation_status')) {
     foreach ($status as $project => $languages) {
       foreach ($languages as $langcode => $source) {
         if (in_array($langcode, $langcodes)) {
@@ -994,7 +994,7 @@ function locale_translation_status_delete_languages($langcodes) {
         }
       }
     }
-    state()->set('locale.translation_status', $status);
+    Drupal::state()->set('locale.translation_status', $status);
   }
 }
 
@@ -1005,22 +1005,22 @@ function locale_translation_status_delete_languages($langcodes) {
  *   Project name(s) to be deleted from the cache.
  */
 function locale_translation_status_delete_projects($projects) {
-  $status = state()->get('locale.translation_status');
+  $status = Drupal::state()->get('locale.translation_status');
 
   foreach ($status as $project => $languages) {
     if (in_array($project, $projects)) {
       unset($status[$project]);
     }
   }
-  state()->set('locale.translation_status', $status);
+  Drupal::state()->set('locale.translation_status', $status);
 }
 
 /**
  * Clear the translation status cache.
  */
 function locale_translation_clear_status() {
-  state()->delete('locale.translation_status');
-  state()->delete('locale.translation_last_checked');
+  Drupal::state()->delete('locale.translation_status');
+  Drupal::state()->delete('locale.translation_last_checked');
 }
 
 /**
@@ -1219,7 +1219,7 @@ function _locale_parse_js_file($filepath) {
  *   New content of the 'system.javascript_parsed' variable.
  */
 function _locale_invalidate_js($langcode = NULL) {
-  $parsed = state()->get('system.javascript_parsed') ?: array();
+  $parsed = Drupal::state()->get('system.javascript_parsed') ?: array();
 
   if (empty($langcode)) {
     // Invalidate all languages.
@@ -1233,7 +1233,7 @@ function _locale_invalidate_js($langcode = NULL) {
     $parsed['refresh:' . $langcode] = 'waiting';
   }
 
-  state()->set('system.javascript_parsed', $parsed);
+  Drupal::state()->set('system.javascript_parsed', $parsed);
   return $parsed;
 }
 
@@ -1272,7 +1272,7 @@ function _locale_rebuild_js($langcode = NULL) {
   if (!empty($translations)) {
 
     $data = "Drupal.locale = { ";
-    $locale_plurals = state()->get('locale.translation.plurals') ?: array();
+    $locale_plurals = Drupal::state()->get('locale.translation.plurals') ?: array();
     if (!empty($locale_plurals[$language->langcode])) {
       $data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->langcode]['formula']}); }, ";
     }
@@ -1286,7 +1286,7 @@ function _locale_rebuild_js($langcode = NULL) {
   $dir = 'public://' . $config->get('javascript.directory');
 
   // Delete old file, if we have no translations anymore, or a different file to be saved.
-  $locale_javascripts = state()->get('locale.translation.javascript') ?: array();
+  $locale_javascripts = Drupal::state()->get('locale.translation.javascript') ?: array();
   $changed_hash = !isset($locale_javascripts[$language->langcode]) || ($locale_javascripts[$language->langcode] != $data_hash);
   if (!empty($locale_javascripts[$language->langcode]) && (!$data || $changed_hash)) {
     file_unmanaged_delete($dir . '/' . $language->langcode . '_' . $locale_javascripts[$language->langcode] . '.js');
@@ -1330,7 +1330,7 @@ function _locale_rebuild_js($langcode = NULL) {
   // deleted). Act only if some operation was executed that changed the hash
   // code.
   if ($status && $changed_hash) {
-    state()->set('locale.translation.javascript', $locale_javascripts);
+    Drupal::state()->set('locale.translation.javascript', $locale_javascripts);
   }
 
   // Log the operation and return success flag.
diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc
index 691d44d..9ba7b71 100644
--- a/core/modules/locale/locale.pages.inc
+++ b/core/modules/locale/locale.pages.inc
@@ -280,7 +280,7 @@ function locale_translate_edit_form($form, &$form_state) {
   if (isset($langcode)) {
     $strings = locale_translate_filter_load_strings();
 
-    $plural_formulas = state()->get('locale.translation.plurals') ?: array();
+    $plural_formulas = Drupal::state()->get('locale.translation.plurals') ?: array();
 
     foreach ($strings as $string) {
       // Cast into source string, will do for our purposes.
@@ -501,7 +501,7 @@ function locale_translation_status_form($form, &$form_state) {
   $project_data = locale_translation_build_projects();
   $languages = locale_translatable_language_list();
   $projects = locale_translation_get_projects();
-  $status = state()->get('locale.translation_status');
+  $status = Drupal::state()->get('locale.translation_status');
 
   // Prepare information about projects which have available translation
   // updates.
@@ -544,7 +544,7 @@ function locale_translation_status_form($form, &$form_state) {
     uasort($options, 'drupal_sort_title');
   }
 
-  $last_checked = state()->get('locale.translation_last_checked');
+  $last_checked = Drupal::state()->get('locale.translation_last_checked');
   $form['last_checked'] = array(
     '#markup' => '<p>' . theme('locale_translation_last_check', array('last' => $last_checked)) . '</p>',
   );
@@ -621,7 +621,7 @@ function locale_translation_status_form_submit($form, &$form_state) {
   // If the status was updated recently we can immediately start fetching the
   // translation updates. If the status is expired we clear it an run a batch to
   // update the status and then fetch the translation updates.
-  $last_checked = state()->get('locale.translation_last_checked');
+  $last_checked = Drupal::state()->get('locale.translation_last_checked');
   if ($last_checked < REQUEST_TIME - LOCALE_TRANSLATION_STATUS_TTL) {
     locale_translation_clear_status();
     $batch = locale_translation_batch_update_build(array(), $langcodes, $options);
diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc
index 7edf847..7d58315 100644
--- a/core/modules/locale/locale.translation.inc
+++ b/core/modules/locale/locale.translation.inc
@@ -104,7 +104,7 @@ function locale_translation_load_sources($projects = NULL, $langcodes = NULL) {
   $langcodes = $langcodes ? $langcodes : array_keys(locale_translatable_language_list());
 
   // Load source data from locale_translation_status cache.
-  $status = state()->get('locale.translation_status');
+  $status = Drupal::state()->get('locale.translation_status');
 
   // Use only the selected projects and languages for update.
   foreach($projects as $project) {
diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.install b/core/modules/locale/tests/modules/locale_test/locale_test.install
index 3d9dff3..e820b9f 100644
--- a/core/modules/locale/tests/modules/locale_test/locale_test.install
+++ b/core/modules/locale/tests/modules/locale_test/locale_test.install
@@ -10,6 +10,6 @@
  */
 function locale_test_uninstall() {
   // Clear variables.
-  state()->delete('locale.test_system_info_alter');
-  state()->delete('locale.test_projects_alter');
+  Drupal::state()->delete('locale.test_system_info_alter');
+  Drupal::state()->delete('locale.test_projects_alter');
 }
diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.module b/core/modules/locale/tests/modules/locale_test/locale_test.module
index 88e581c..ace4172 100644
--- a/core/modules/locale/tests/modules/locale_test/locale_test.module
+++ b/core/modules/locale/tests/modules/locale_test/locale_test.module
@@ -16,7 +16,7 @@ function locale_test_system_info_alter(&$info, $file, $type) {
   // By default the locale_test modules are hidden and have a project specified.
   // To test the module detection proces by locale_project_list() the
   // test modules should mimic a custom module. I.e. be non-hidden.
-  if (state()->get('locale.test_system_info_alter')) {
+  if (Drupal::state()->get('locale.test_system_info_alter')) {
     if ($file->name == 'locale_test' || $file->name == 'locale_test_translate') {
       // Don't hide the module.
       $info['hidden'] = FALSE;
@@ -37,7 +37,7 @@ function locale_test_system_info_alter(&$info, $file, $type) {
  * test script in order for this hook to take effect.
  */
 function locale_test_locale_translation_projects_alter(&$projects) {
-  if (state()->get('locale.test_projects_alter')) {
+  if (Drupal::state()->get('locale.test_projects_alter')) {
 
     // Instead of the default ftp.drupal.org we use the file system of the test
     // instance to simulate a remote file location.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
index 2037016..adee17d 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
@@ -40,7 +40,7 @@ public function setUp() {
     parent::setUp();
 
     node_access_rebuild();
-    state()->set('node_access_test.private', TRUE);
+    \Drupal::state()->set('node_access_test.private', TRUE);
   }
 
   /**
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
index 8ba7788..7e7c70a 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
@@ -36,7 +36,7 @@ function setUp() {
     node_access_rebuild();
 
     // Enable the private node feature of the node_access_test module.
-    state()->set('node_access_test.private', TRUE);
+    \Drupal::state()->set('node_access_test.private', TRUE);
 
     // Add Hungarian and Catalan.
     $language = new Language(array(
@@ -153,7 +153,7 @@ function testNodeAccessPrivate() {
 
     // Reset the node access cache and turn on our test node_access() code.
     entity_access_controller('node')->resetCache();
-    state()->set('node_access_test_secret_catalan', 1);
+    \Drupal::state()->set('node_access_test_secret_catalan', 1);
 
     // Tests that access is not granted if requested with no language.
     $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user);
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
index 1915dbf..eef7948 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
@@ -45,7 +45,7 @@ function testNodeViewModeChange() {
     $node = $this->drupalGetNodeByTitle($edit["title"]);
 
     // Set the flag to alter the view mode and view the node.
-    state()->set('node_test_change_view_mode', 'teaser');
+    \Drupal::state()->set('node_test_change_view_mode', 'teaser');
     $this->drupalGet('node/' . $node->nid);
 
     // Check that teaser mode is viewed.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
index 03eb4e3..f2b241a 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
@@ -194,7 +194,7 @@ function testNodeQueryAlterOverride() {
     // $account instead of the global $user, we will log in as
     // noAccessUser2.
     $this->drupalLogin($this->noAccessUser2);
-    state()->set('node_access_test.no_access_uid', $this->noAccessUser->uid);
+    \Drupal::state()->set('node_access_test.no_access_uid', $this->noAccessUser->uid);
     drupal_static_reset('node_access_view_all_nodes');
     try {
       $query = db_select('node', 'mytab')
@@ -209,6 +209,6 @@ function testNodeQueryAlterOverride() {
     catch (\Exception $e) {
       $this->fail(t('Altered query is malformed'));
     }
-    state()->delete('node_access_test.no_access_uid');
+    \Drupal::state()->delete('node_access_test.no_access_uid');
   }
 }
diff --git a/core/modules/node/node.install b/core/modules/node/node.install
index a4cc155..1110615 100644
--- a/core/modules/node/node.install
+++ b/core/modules/node/node.install
@@ -530,12 +530,12 @@ function node_uninstall() {
   variable_del('node_rank_recent');
 
   // Delete remaining general module variables.
-  state()->delete('node.node_access_needs_rebuild');
+  Drupal::state()->delete('node.node_access_needs_rebuild');
   variable_del('node_admin_theme');
   variable_del('node_recent_block_count');
 
   // Delete any stored state.
-  state()->delete('node.cron_last');
+  Drupal::state()->delete('node.cron_last');
 }
 
 /**
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 1aebdd5..d4cd961 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1376,7 +1376,7 @@ function node_ranking() {
   );
 
   // Add relevance based on creation or changed date.
-  if ($node_cron_last = state()->get('node.cron_last')) {
+  if ($node_cron_last = Drupal::state()->get('node.cron_last')) {
     $ranking['recent'] = array(
       'title' => t('Recently posted'),
       // Exponential decay with half-life of 6 months, starting at last indexed node
@@ -2180,7 +2180,7 @@ function _node_index_node(EntityInterface $node) {
 
   // Save the changed time of the most recent indexed node, for the search
   // results half-life calculation.
-  state()->set('node.cron_last', $node->changed);
+  Drupal::state()->set('node.cron_last', $node->changed);
 
   $languages = $node->getTranslationLanguages();
 
@@ -2932,13 +2932,13 @@ function _node_access_write_grants(EntityInterface $node, $grants, $realm = NULL
  */
 function node_access_needs_rebuild($rebuild = NULL) {
   if (!isset($rebuild)) {
-    return state()->get('node.node_access_needs_rebuild') ?: FALSE;
+    return Drupal::state()->get('node.node_access_needs_rebuild') ?: FALSE;
   }
   elseif ($rebuild) {
-    state()->set('node.node_access_needs_rebuild', TRUE);
+    Drupal::state()->set('node.node_access_needs_rebuild', TRUE);
   }
   else {
-    state()->delete('node.node_access_needs_rebuild');
+    Drupal::state()->delete('node.node_access_needs_rebuild');
   }
 }
 
diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module
index eb3a2bb..ac25cb2 100644
--- a/core/modules/node/tests/modules/node_access_test/node_access_test.module
+++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module
@@ -22,7 +22,7 @@ function node_access_test_node_grants($account, $op) {
     $grants['node_access_test'] = array(8888, 8889);
   }
 
-  $no_access_uid = state()->get('node_access_test.no_access_uid') ?: 0;
+  $no_access_uid = Drupal::state()->get('node_access_test.no_access_uid') ?: 0;
   if ($op == 'view' && $account->uid == $no_access_uid) {
     $grants['node_access_all'] = array(0);
   }
@@ -35,7 +35,7 @@ function node_access_test_node_grants($account, $op) {
 function node_access_test_node_access_records(EntityInterface $node) {
   $grants = array();
   // For NodeAccessBaseTableTestCase, only set records for private nodes.
-  if (!state()->get('node_access_test.private') || $node->private) {
+  if (!Drupal::state()->get('node_access_test.private') || $node->private) {
     $grants[] = array(
       'realm' => 'node_access_test',
       'gid' => 8888,
@@ -182,8 +182,8 @@ function node_access_entity_test_page() {
  */
 function node_access_test_form_node_form_alter(&$form, $form_state) {
   // Only show this checkbox for NodeAccessBaseTableTestCase.
-  if (state()->get('node_access_test.private')) {
-    $node = $form_state['controller']->getEntity();
+  if (Drupal::state()->get('node_access_test.private')) {
+    $node = $form_state['controller']->getEntity($form_state);
     $form['private'] = array(
       '#type' => 'checkbox',
       '#title' => t('Private'),
@@ -241,7 +241,7 @@ function _node_access_test_node_write(EntityInterface $node) {
  * Implements hook_node_access().
  */
 function node_access_test_node_access($node, $op, $account, $langcode) {
-  $secret_catalan = state()->get('node_access_test_secret_catalan') ?: 0;
+  $secret_catalan = Drupal::state()->get('node_access_test_secret_catalan') ?: 0;
   if ($secret_catalan && $langcode == 'ca') {
     // Make all Catalan content secret.
     return NODE_ACCESS_DENY;
diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module
index d726df5..c2ff3b4 100644
--- a/core/modules/node/tests/modules/node_test/node_test.module
+++ b/core/modules/node/tests/modules/node_test/node_test.module
@@ -160,7 +160,7 @@ function node_test_node_update(EntityInterface $node) {
  */
 function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
   // Only alter the view mode if we are on the test callback.
-  $change_view_mode = state()->get( 'node_test_change_view_mode') ?: '';
+  $change_view_mode = Drupal::state()->get( 'node_test_change_view_mode') ?: '';
   if ($change_view_mode) {
     $view_mode = $change_view_mode;
   }
diff --git a/core/modules/search/search.admin.inc b/core/modules/search/search.admin.inc
index 6f0825f..8b39eb0 100644
--- a/core/modules/search/search.admin.inc
+++ b/core/modules/search/search.admin.inc
@@ -157,7 +157,7 @@ function search_admin_settings_submit($form, &$form_state) {
   if ($config->get('active_modules') != $new_modules) {
     $config->set('active_modules', $new_modules);
     drupal_set_message(t('The active search modules have been changed.'));
-    state()->set('menu_rebuild_needed', TRUE);
+    Drupal::state()->set('menu_rebuild_needed', TRUE);
   }
   $config->save();
 }
diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php
index 3b7a986..49841ff 100644
--- a/core/modules/search/search.api.php
+++ b/core/modules/search/search.api.php
@@ -340,7 +340,7 @@ function hook_update_index() {
 
     // Save the changed time of the most recent indexed node, for the search
     // results half-life calculation.
-    state()->set('node.cron_last', $node->changed);
+    \Drupal::state()->set('node.cron_last', $node->changed);
 
     // Render the node.
     $build = node_view($node, 'search_index');
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
index e5f33d4..b1102be 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
@@ -79,9 +79,9 @@ function __construct($test_id = NULL) {
   protected function setUp() {
     // Copy/prime extension file lists once to avoid filesystem scans.
     if (!isset($this->moduleFiles)) {
-      $this->moduleFiles = state()->get('system.module.files') ?: array();
-      $this->themeFiles = state()->get('system.theme.files') ?: array();
-      $this->themeData = state()->get('system.theme.data') ?: array();
+      $this->moduleFiles = \Drupal::state()->get('system.module.files') ?: array();
+      $this->themeFiles = \Drupal::state()->get('system.theme.files') ?: array();
+      $this->themeData = \Drupal::state()->get('system.theme.data') ?: array();
     }
 
     $this->keyValueFactory = new KeyValueMemoryFactory();
@@ -92,9 +92,9 @@ protected function setUp() {
     // Make sure it survives kernel rebuilds.
     $GLOBALS['conf']['container_bundles'][] = 'Drupal\simpletest\TestBundle';
 
-    state()->set('system.module.files', $this->moduleFiles);
-    state()->set('system.theme.files', $this->themeFiles);
-    state()->set('system.theme.data', $this->themeData);
+    \Drupal::state()->set('system.module.files', $this->moduleFiles);
+    \Drupal::state()->set('system.theme.files', $this->themeFiles);
+    \Drupal::state()->set('system.theme.data', $this->themeData);
 
     // Bootstrap the kernel.
     // No need to dump it; this test runs in-memory.
@@ -163,11 +163,16 @@ public function containerBuild(ContainerBuilder $container) {
       // a kernel is overridden then there's no need to re-register the keyvalue
       // service but when a test is happy with the superminimal container put
       // together here, it still might a keyvalue storage for anything (for
-      // eg. module_enable) using state() -- that's why a memory service was
-      // added in the first place.
+      // eg. module_enable) using \Drupal::state() -- that's why a memory
+      // service was added in the first place.
       $container
         ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory')
         ->addArgument(new Reference('service_container'));
+
+      $container->register('state', 'Drupal\Core\KeyValueStore\KeyValueStoreInterface')
+        ->setFactoryService(new Reference('keyvalue'))
+        ->setFactoryMethod('get')
+        ->addArgument('state');
     }
   }
 
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index f07e249..bcdec81 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -1023,7 +1023,7 @@ protected function tearDown() {
     // log to pick up any fatal errors.
     simpletest_log_read($this->testId, $this->databasePrefix, get_class($this), TRUE);
     if (($container = drupal_container()) && $container->has('keyvalue')) {
-      $captured_emails = state()->get('system.test_email_collector') ?: array();
+      $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
       $emailCount = count($captured_emails);
       if ($emailCount) {
         $message = format_plural($emailCount, '1 e-mail was sent during this test.', '@count e-mails were sent during this test.');
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index acdec6d..da3d893 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1613,7 +1613,7 @@ protected function drupalPostAJAX($path, $edit, $triggering_element, $ajax_path
    * Runs cron in the Drupal installed by Simpletest.
    */
   protected function cronRun() {
-    $this->drupalGet('cron/' . state()->get('system.cron_key'));
+    $this->drupalGet('cron/' . \Drupal::state()->get('system.cron_key'));
   }
 
   /**
@@ -2193,7 +2193,7 @@ protected function drupalGetSettings() {
    *   An array containing e-mail messages captured during the current test.
    */
   protected function drupalGetMails($filter = array()) {
-    $captured_emails = state()->get('system.test_email_collector') ?: array();
+    $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
     $filtered_emails = array();
 
     foreach ($captured_emails as $message) {
@@ -3162,7 +3162,7 @@ protected function assertNoResponse($code, $message = '', $group = 'Browser') {
    *   TRUE on pass, FALSE on fail.
    */
   protected function assertMail($name, $value = '', $message = '', $group = 'E-mail') {
-    $captured_emails = state()->get('system.test_email_collector') ?: array();
+    $captured_emails = \Drupal::state()->get('system.test_email_collector') ?: array();
     $email = end($captured_emails);
     return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, $group);
   }
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
index b778c4f..af45ffd 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsAdminTest.php
@@ -139,7 +139,7 @@ function testExpiredLogs() {
     config('statistics.settings')
       ->set('count_content_views', 1)
       ->save();
-    state()->set('statistics.day_timestamp', 8640000);
+    \Drupal::state()->set('statistics.day_timestamp', 8640000);
 
     $this->drupalGet('node/' . $this->test_node->nid);
     // Manually calling statistics.php, simulating ajax behavior.
diff --git a/core/modules/statistics/statistics.install b/core/modules/statistics/statistics.install
index 6732eb0..5706db3 100644
--- a/core/modules/statistics/statistics.install
+++ b/core/modules/statistics/statistics.install
@@ -10,8 +10,8 @@
  */
 function statistics_uninstall() {
   // Remove states.
-  state()->delete('statistics.node_counter_scale');
-  state()->delete('statistics.day_timestamp');
+  Drupal::state()->delete('statistics.node_counter_scale');
+  Drupal::state()->delete('statistics.day_timestamp');
 }
 
 /**
diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module
index 89986c5..c9b5a3f 100644
--- a/core/modules/statistics/statistics.module
+++ b/core/modules/statistics/statistics.module
@@ -90,14 +90,14 @@ function statistics_menu() {
  * Implements hook_cron().
  */
 function statistics_cron() {
-  $statistics_timestamp = state()->get('statistics.day_timestamp') ?: 0;
+  $statistics_timestamp = Drupal::state()->get('statistics.day_timestamp') ?: 0;
 
   if ((REQUEST_TIME - $statistics_timestamp) >= 86400) {
     // Reset day counts.
     db_update('node_counter')
       ->fields(array('daycount' => 0))
       ->execute();
-    state()->set('statistics.day_timestamp', REQUEST_TIME);
+    Drupal::state()->set('statistics.day_timestamp', REQUEST_TIME);
   }
 }
 
@@ -223,7 +223,7 @@ function statistics_ranking() {
         ),
         // Inverse law that maps the highest view count on the site to 1 and 0 to 0.
         'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * CAST(:scale AS DECIMAL))',
-        'arguments' => array(':scale' => state()->get('statistics.node_counter_scale') ?: 0),
+        'arguments' => array(':scale' => Drupal::state()->get('statistics.node_counter_scale') ?: 0),
       ),
     );
   }
@@ -233,7 +233,7 @@ function statistics_ranking() {
  * Implements hook_update_index().
  */
 function statistics_update_index() {
-  state()->set('statistics.node_counter_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
+  Drupal::state()->set('statistics.node_counter_scale', 1.0 / max(1, db_query('SELECT MAX(totalcount) FROM {node_counter}')->fetchField()));
 }
 
 /**
diff --git a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php
index 117dc1a..f90d2d3 100644
--- a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php
+++ b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php
@@ -28,7 +28,7 @@ public function applies(Route $route) {
    */
   public function access(Route $route, Request $request) {
     $key = $request->attributes->get('key');
-    if ($key != state()->get('system.cron_key')) {
+    if ($key != \Drupal::state()->get('system.cron_key')) {
       watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
       return FALSE;
     }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
index 4244c13..0a457a6 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/JavaScriptTest.php
@@ -371,11 +371,11 @@ function testAggregationOrder() {
     ));
 
     // Store the expected key for the first item in the cache.
-    $cache = array_keys(state()->get('system.js_cache_files') ?: array());
+    $cache = array_keys(\Drupal::state()->get('system.js_cache_files') ?: array());
     $expected_key = $cache[0];
 
     // Reset variables and add a file in a different scope first.
-    state()->delete('system.js_cache_files');
+    \Drupal::state()->delete('system.js_cache_files');
     drupal_static_reset('drupal_add_js');
     drupal_add_library('system', 'drupal');
     drupal_add_js('some/custom/javascript_file.js', array('scope' => 'footer'));
@@ -390,7 +390,7 @@ function testAggregationOrder() {
     ));
 
     // Compare the expected key for the first file to the current one.
-    $cache = array_keys(state()->get('system.js_cache_files') ?: array());
+    $cache = array_keys(\Drupal::state()->get('system.js_cache_files') ?: array());
     $key = $cache[0];
     $this->assertEqual($key, $expected_key, 'JavaScript aggregation is not affected by ordering in different scopes.');
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php
index b31ca74..9bfde63 100644
--- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/ServiceDestructionTest.php
@@ -32,13 +32,13 @@ public function testDestructionUsed() {
     $this->enableModules(array('bundle_test'));
 
     // The service has not been destructed yet.
-    $this->assertNull(state()->get('bundle_test.destructed'));
+    $this->assertNull(\Drupal::state()->get('bundle_test.destructed'));
 
     // Call the class and then terminate the kernel
     $this->container->get('bundle_test_class');
     $response = new Response();
     $this->container->get('kernel')->terminate($this->container->get('request'), $response);
-    $this->assertTrue(state()->get('bundle_test.destructed'));
+    $this->assertTrue(\Drupal::state()->get('bundle_test.destructed'));
   }
 
   /**
@@ -49,12 +49,12 @@ public function testDestructionUnused() {
     $this->enableModules(array('bundle_test'));
 
     // The service has not been destructed yet.
-    $this->assertNull(state()->get('bundle_test.destructed'));
+    $this->assertNull(\Drupal::state()->get('bundle_test.destructed'));
 
     // Terminate the kernel. The test class has not been called, so it should not
     // be destructed.
     $response = new Response();
     $this->container->get('kernel')->terminate($this->container->get('request'), $response);
-    $this->assertNull(state()->get('bundle_test.destructed'));
+    $this->assertNull(\Drupal::state()->get('bundle_test.destructed'));
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
index cb0ea4d..cf7d9cf 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php
@@ -32,7 +32,7 @@ function testEntityInfoChanges() {
 
     // Change the label of the test entity type and make sure changes appear
     // after flushing caches.
-    state()->set('entity_cache_test.label', 'New label.');
+    \Drupal::state()->set('entity_cache_test.label', 'New label.');
     $info = entity_get_info('entity_cache_test');
     $this->assertEqual($info['label'], 'Entity Cache Test', 'Original label appears in cached entity info.');
     $this->resetAll();
@@ -52,7 +52,7 @@ function testEntityInfoChanges() {
    */
   function testEntityInfoCacheWatchdog() {
     module_enable(array('entity_cache_test'));
-    $info = state()->get('entity_cache_test');
+    $info = \Drupal::state()->get('entity_cache_test');
     $this->assertEqual($info['label'], 'Entity Cache Test', 'Entity info label is correct.');
     $this->assertEqual($info['controllers']['storage'], 'Drupal\Core\Entity\DatabaseStorageController', 'Entity controller class info is correct.');
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
index 1cfb1e0..2a6e833 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php
@@ -35,7 +35,7 @@ public static function getInfo() {
   function setUp() {
     parent::setUp();
     // Enable translations for the test entity type.
-    state()->set('entity_test.translation', TRUE);
+    \Drupal::state()->set('entity_test.translation', TRUE);
 
     // Create test languages.
     $this->langcodes = array();
@@ -65,7 +65,7 @@ function testEntityFormLanguage() {
     $edit["body[$langcode][0][value]"] = $this->randomName(16);
 
     $this->drupalGet('node/add/page');
-    $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE;
+    $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE;
     $this->drupalPost(NULL, $edit, t('Save'));
 
     $node = $this->drupalGetNodeByTitle($edit["title"]);
@@ -73,14 +73,14 @@ function testEntityFormLanguage() {
 
     // Edit the node and test the form language.
     $this->drupalGet($this->langcodes[0] . '/node/' . $node->nid . '/edit');
-    $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE;
+    $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE;
     $this->assertTrue($node->langcode == $form_langcode, 'Form language is the same as the entity language.');
 
     // Explicitly set form langcode.
     $langcode = $this->langcodes[0];
     $form_state['langcode'] = $langcode;
     entity_get_form($node, 'default', $form_state);
-    $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE;
+    $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE;
     $this->assertTrue($langcode == $form_langcode, 'Form language is the same as the language parameter.');
 
     // Enable language selector.
@@ -115,7 +115,7 @@ function testEntityFormLanguage() {
     $node->body[$langcode2][0]['value'] = $this->randomName(16);
     $node->save();
     $this->drupalGet($langcode2 . '/node/' . $node->nid . '/edit');
-    $form_langcode = state()->get('entity_test.form_langcode') ?: FALSE;
+    $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE;
     $this->assertTrue($langcode2 == $form_langcode, "Node edit form language is $langcode2.");
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
index 3a9a412..919565c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
@@ -46,7 +46,7 @@ function setUp() {
     entity_test_install();
 
     // Enable translations for the test entity type.
-    state()->set('entity_test.translation', TRUE);
+    \Drupal::state()->set('entity_test.translation', TRUE);
 
     // Create a translatable test field.
     $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php
index ba837d4..7631d4d 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/UrlRewritingTest.php
@@ -35,7 +35,7 @@ function testShippedFileURL()  {
     // Drupal core, a module or a theme, for example a JavaScript file).
 
     // Test alteration of file URLs to use a CDN.
-    state()->set('file_test.hook_file_url_alter', 'cdn');
+    \Drupal::state()->set('file_test.hook_file_url_alter', 'cdn');
     $filepath = 'core/misc/jquery.js';
     $url = file_create_url($filepath);
     $this->assertEqual(FILE_URL_TEST_CDN_1 . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.');
@@ -44,7 +44,7 @@ function testShippedFileURL()  {
     $this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.');
 
     // Test alteration of file URLs to use root-relative URLs.
-    state()->set('file_test.hook_file_url_alter', 'root-relative');
+    \Drupal::state()->set('file_test.hook_file_url_alter', 'root-relative');
     $filepath = 'core/misc/jquery.js';
     $url = file_create_url($filepath);
     $this->assertEqual(base_path() . '/' . $filepath, $url, 'Correctly generated a root-relative URL for a shipped file.');
@@ -53,7 +53,7 @@ function testShippedFileURL()  {
     $this->assertEqual(base_path() . '/' . $filepath, $url, 'Correctly generated a root-relative URL for a shipped file.');
 
     // Test alteration of file URLs to use protocol-relative URLs.
-    state()->set('file_test.hook_file_url_alter', 'protocol-relative');
+    \Drupal::state()->set('file_test.hook_file_url_alter', 'protocol-relative');
     $filepath = 'core/misc/jquery.js';
     $url = file_create_url($filepath);
     $this->assertEqual('/' . base_path() . '/' . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.');
@@ -69,20 +69,20 @@ function testPublicCreatedFileURL() {
     // Test generating an URL to a created file.
 
     // Test alteration of file URLs to use a CDN.
-    state()->set('file_test.hook_file_url_alter', 'cdn');
+    \Drupal::state()->set('file_test.hook_file_url_alter', 'cdn');
     $uri = $this->createUri();
     $url = file_create_url($uri);
     $public_directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
     $this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a CDN URL for a created file.');
 
     // Test alteration of file URLs to use root-relative URLs.
-    state()->set('file_test.hook_file_url_alter', 'root-relative');
+    \Drupal::state()->set('file_test.hook_file_url_alter', 'root-relative');
     $uri = $this->createUri();
     $url = file_create_url($uri);
     $this->assertEqual(base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a root-relative URL for a created file.');
 
     // Test alteration of file URLs to use a protocol-relative URLs.
-    state()->set('file_test.hook_file_url_alter', 'protocol-relative');
+    \Drupal::state()->set('file_test.hook_file_url_alter', 'protocol-relative');
     $uri = $this->createUri();
     $url = file_create_url($uri);
     $this->assertEqual('/' . base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a protocol-relative URL for a created file.');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php
index 1a851c9..aa94a68 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormCacheTest.php
@@ -57,7 +57,7 @@ function testCacheToken() {
     // Test that the form cache isn't loaded when the session/token has changed.
     // Change the private key. (We cannot change the session ID because this
     // will break the parent site test runner batch.)
-    state()->set('system.private_key', 'invalid');
+    \Drupal::state()->set('system.private_key', 'invalid');
     $cached_form_state = form_state_defaults();
     $cached_form = form_get_cache($this->form_build_id, $cached_form_state);
     $this->assertFalse($cached_form, 'No form returned from cache');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php
index 260b2da..5f8e9eb 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php
@@ -94,7 +94,7 @@ function imageTestReset() {
       'crop' => array(),
       'desaturate' => array(),
     );
-    state()->set('image_test.results', $results);
+    \Drupal::state()->set('image_test.results', $results);
   }
 
   /**
@@ -106,6 +106,6 @@ function imageTestReset() {
    *   passed to each call.
    */
   function imageTestGetAllCalls() {
-    return state()->get('image_test.results') ?: array();
+    return \Drupal::state()->get('image_test.results') ?: array();
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
index 3b666a0..eddcce0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
@@ -252,7 +252,7 @@ function testThemeCallbackNoThemeRequested() {
   function testHookCustomTheme() {
     // Trigger hook_custom_theme() to dynamically request the Stark theme for
     // the requested page.
-    state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme);
+    \Drupal::state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme);
     theme_enable(array($this->alternate_theme, $this->admin_theme));
 
     // Visit a page that does not implement a theme callback. The above request
@@ -268,7 +268,7 @@ function testHookCustomTheme() {
   function testThemeCallbackHookCustomTheme() {
     // Trigger hook_custom_theme() to dynamically request the Stark theme for
     // the requested page.
-    state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme);
+    \Drupal::state()->set('menu_test.hook_custom_theme_name', $this->alternate_theme);
     theme_enable(array($this->alternate_theme, $this->admin_theme));
 
     // The menu "theme callback" should take precedence over a value set in
@@ -461,7 +461,7 @@ function testMenuHidden() {
    * Test menu_get_item() with empty ancestors.
    */
   function testMenuGetItemNoAncestors() {
-    state()->set('menu.masks', array());
+    \Drupal::state()->set('menu.masks', array());
     $this->drupalGet('');
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php
index 4677bb5..492c86f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/RebuildTest.php
@@ -38,7 +38,7 @@ function testMenuRebuildByVariable() {
 
     // Now we enable the rebuild variable and send a request to rebuild the menu
     // item. Now 'admin' should exist.
-    state()->set('menu_rebuild_needed', TRUE);
+    \Drupal::state()->set('menu_rebuild_needed', TRUE);
     // The request should trigger the rebuild.
     $this->drupalGet('<front>');
     $admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php
index 3dfd5c7..eb59f94 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php
@@ -67,12 +67,12 @@ function testMenuTreeSetPath() {
     );
 
     // Test the tree generation for the Tools menu.
-    state()->delete('menu_test.menu_tree_set_path');
+    \Drupal::state()->delete('menu_test.menu_tree_set_path');
     $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
 
     // Override the active trail for the Administration tree; it should not
     // affect the Tools tree.
-    state()->set('menu_test.menu_tree_set_path', $test_menu_path);
+    \Drupal::state()->set('menu_test.menu_tree_set_path', $test_menu_path);
     $this->assertBreadcrumb('menu-test/menu-trail', $breadcrumb, t('Menu trail - Case 1'), $tree);
 
     $breadcrumb = $config + array(
@@ -93,12 +93,12 @@ function testMenuTreeSetPath() {
     );
 
     // Test the tree generation for the Administration menu.
-    state()->delete('menu_test.menu_tree_set_path');
+    \Drupal::state()->delete('menu_test.menu_tree_set_path');
     $this->assertBreadcrumb('admin/config/development/menu-trail', $breadcrumb, t('Menu trail - Case 2'), $tree);
 
     // Override the active trail for the Administration tree; it should affect
     // the breadcrumbs and Administration tree.
-    state()->set('menu_test.menu_tree_set_path', $test_menu_path);
+    \Drupal::state()->set('menu_test.menu_tree_set_path', $test_menu_path);
     $this->assertBreadcrumb('admin/config/development/menu-trail', $override_breadcrumb, t('Menu trail - Case 2'), $override_tree);
   }
 
@@ -150,13 +150,13 @@ function testCustom403And404Pages() {
     foreach (array(403, 404) as $status_code) {
       // Before visiting the page, trigger the code in the menu_test module
       // that will record the active trail (so we can check it in this test).
-      state()->set('menu_test.record_active_trail', TRUE);
+      \Drupal::state()->set('menu_test.record_active_trail', TRUE);
       $this->drupalGet($paths[$status_code]);
       $this->assertResponse($status_code);
 
       // Check that the initial trail (during the Drupal bootstrap) matches
       // what we expect.
-      $initial_trail = state()->get('menu_test.active_trail_initial') ?: array();
+      $initial_trail = \Drupal::state()->get('menu_test.active_trail_initial') ?: array();
       $this->assertEqual(count($initial_trail), count($expected_trail[$status_code]['initial']), format_string('The initial active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array(
         '@status_code' => $status_code,
         '@expected' => count($expected_trail[$status_code]['initial']),
@@ -173,7 +173,7 @@ function testCustom403And404Pages() {
 
       // Check that the final trail (after the user has been redirected to the
       // custom 403/404 page) matches what we expect.
-      $final_trail = state()->get('menu_test.active_trail_final') ?: array();
+      $final_trail = \Drupal::state()->get('menu_test.active_trail_final') ?: array();
       $this->assertEqual(count($final_trail), count($expected_trail[$status_code]['final']), format_string('The final active trail for a @status_code page contains the expected number of items (expected: @expected, found: @found).', array(
         '@status_code' => $status_code,
         '@expected' => count($expected_trail[$status_code]['final']),
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
index e561ab7..023f485 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/DependencyTest.php
@@ -132,7 +132,7 @@ function testModuleEnableOrder() {
     module_enable(array('module_test'), FALSE);
     $this->resetAll();
     $this->assertModules(array('module_test'), TRUE);
-    state()->set('module_test.dependency', 'dependency');
+    \Drupal::state()->set('module_test.dependency', 'dependency');
     // module_test creates a dependency chain:
     // - forum depends on taxonomy, comment, history, and ban (via module_test)
     // - taxonomy depends on options
@@ -159,7 +159,7 @@ function testModuleEnableOrder() {
     $this->assertModules(array('forum', 'ban', 'php', 'comment', 'history', 'taxonomy', 'options', 'number'), TRUE);
 
     // Check the actual order which is saved by module_test_modules_enabled().
-    $module_order = state()->get('system_test.module_enable_order') ?: array();
+    $module_order = \Drupal::state()->get('system_test.module_enable_order') ?: array();
     $this->assertIdentical($module_order, $expected_order);
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
index f8aa2b3..8458bc7 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/EnableDisableTest.php
@@ -64,7 +64,7 @@ function testEnableDisable() {
 
     // Set a variable so that the hook implementations in system_test.module
     // will display messages via drupal_set_message().
-    state()->set('system_test.verbose_module_hooks', TRUE);
+    \Drupal::state()->set('system_test.verbose_module_hooks', TRUE);
 
     // Go through each module in the list and try to enable it (unless it was
     // already enabled automatically due to a dependency).
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
index eb9d7d5..a6322b0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
@@ -164,7 +164,7 @@ function testDependencyResolution() {
 
     // First, create a fake missing dependency. Forum depends on ban, which
     // depends on a made-up module, foo. Nothing should be installed.
-    state()->set('module_test.dependency', 'missing dependency');
+    \Drupal::state()->set('module_test.dependency', 'missing dependency');
     drupal_static_reset('system_rebuild_module_data');
     $result = module_enable(array('forum'));
     $this->assertFalse($result, 'module_enable() returns FALSE if dependencies are missing.');
@@ -172,7 +172,7 @@ function testDependencyResolution() {
 
     // Now, fix the missing dependency. Forum module depends on ban, but ban
     // depends on the PHP module. module_enable() should work.
-    state()->set('module_test.dependency', 'dependency');
+    \Drupal::state()->set('module_test.dependency', 'dependency');
     drupal_static_reset('system_rebuild_module_data');
     $result = module_enable(array('forum'));
     $this->assertTrue($result, 'module_enable() returns the correct value.');
@@ -181,7 +181,7 @@ function testDependencyResolution() {
     // Verify that the original module was installed.
     $this->assertTrue(module_exists('forum'), 'Module installation with unlisted dependencies succeeded.');
     // Finally, verify that the modules were enabled in the correct order.
-    $module_order = state()->get('system_test.module_enable_order') ?: array();
+    $module_order = \Drupal::state()->get('system_test.module_enable_order') ?: array();
     $this->assertEqual($module_order, array('php', 'ban', 'forum'), 'Modules were enabled in the correct order by module_enable().');
 
     // Now, disable the PHP module. Both forum and ban should be disabled as
@@ -189,7 +189,7 @@ function testDependencyResolution() {
     module_disable(array('php'));
     $this->assertTrue(!module_exists('forum') && !module_exists('ban'), 'Depedency chain was disabled by module_disable().');
     $this->assertFalse(module_exists('php'), 'Disabling a module with unlisted dependents succeeded.');
-    $disabled_modules = state()->get('module_test.disable_order') ?: array();
+    $disabled_modules = \Drupal::state()->get('module_test.disable_order') ?: array();
     $this->assertEqual($disabled_modules, array('forum', 'ban', 'php'), 'Modules were disabled in the correct order by module_disable().');
 
     // Disable a module that is listed as a dependency by the installation
@@ -201,7 +201,7 @@ function testDependencyResolution() {
     $this->assertTrue(module_exists('comment'), 'Comment module is enabled.');
     module_disable(array('comment'));
     $this->assertFalse(module_exists('comment'), 'Comment module was disabled.');
-    $disabled_modules = state()->get('module_test.disable_order') ?: array();
+    $disabled_modules = \Drupal::state()->get('module_test.disable_order') ?: array();
     $this->assertTrue(in_array('comment', $disabled_modules), 'Comment module is in the list of disabled modules.');
     $this->assertFalse(in_array($profile, $disabled_modules), 'The installation profile is not in the list of disabled modules.');
 
@@ -222,7 +222,7 @@ function testDependencyResolution() {
     foreach (array('forum', 'ban', 'php') as $module) {
       $this->assertEqual(drupal_get_installed_schema_version($module), SCHEMA_UNINSTALLED, format_string('The @module module was uninstalled.', array('@module' => $module)));
     }
-    $uninstalled_modules = state()->get('module_test.uninstall_order') ?: array();
+    $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
     $this->assertEqual($uninstalled_modules, array('forum', 'ban', 'php'), 'Modules were uninstalled in the correct order by module_uninstall().');
 
     // Uninstall the profile module from above, and make sure that the profile
@@ -230,7 +230,7 @@ function testDependencyResolution() {
     $result = module_uninstall(array('comment'));
     $this->assertTrue($result, 'module_uninstall() returns the correct value.');
     $this->assertEqual(drupal_get_installed_schema_version('comment'), SCHEMA_UNINSTALLED, 'Comment module was uninstalled.');
-    $uninstalled_modules = state()->get('module_test.uninstall_order') ?: array();
+    $uninstalled_modules = \Drupal::state()->get('module_test.uninstall_order') ?: array();
     $this->assertTrue(in_array('comment', $uninstalled_modules), 'Comment module is in the list of uninstalled modules.');
     $this->assertFalse(in_array($profile, $uninstalled_modules), 'The installation profile is not in the list of uninstalled modules.');
 
@@ -238,7 +238,7 @@ function testDependencyResolution() {
     // php module. But, this time do it with ban module declaring a dependency
     // on a specific version of php module in its info file. Make sure that
     // module_enable() still works.
-    state()->set('module_test.dependency', 'version dependency');
+    \Drupal::state()->set('module_test.dependency', 'version dependency');
     drupal_static_reset('system_rebuild_module_data');
     $result = module_enable(array('forum'));
     $this->assertTrue($result, 'module_enable() returns the correct value.');
@@ -247,7 +247,7 @@ function testDependencyResolution() {
     // Verify that the original module was installed.
     $this->assertTrue(module_exists('forum'), 'Module installation with version dependencies succeeded.');
     // Finally, verify that the modules were enabled in the correct order.
-    $enable_order = state()->get('system_test.module_enable_order') ?: array();
+    $enable_order = \Drupal::state()->get('system_test.module_enable_order') ?: array();
     $php_position = array_search('php', $enable_order);
     $ban_position = array_search('ban', $enable_order);
     $forum_position = array_search('forum', $enable_order);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php
index 467a395..7998af1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Module/VersionTest.php
@@ -62,7 +62,7 @@ function testModuleVersions() {
       // Testing extra version. Incompatible.
       'common_test (>2.4-rc0)',
     );
-    state()->set('system_test.dependencies', $dependencies);
+    \Drupal::state()->set('system_test.dependencies', $dependencies);
     $n = count($dependencies);
     for ($i = 0; $i < $n; $i++) {
       $this->drupalGet('admin/modules');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php
index ca7ef51..faaa158 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Path/PathUnitTestBase.php
@@ -20,7 +20,7 @@ public function setUp() {
     $this->fixtures = new UrlAliasFixtures();
     // The alias whitelist expects that the menu path roots are set by a
     // menu router rebuild.
-    state()->set('menu_path_roots', array('user', 'admin'));
+    \Drupal::state()->set('menu_path_roots', array('user', 'admin'));
   }
 
   public function tearDown() {
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
index 5def452..67a5993 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
@@ -42,7 +42,7 @@ function testCronRun() {
     $this->assertResponse(403);
 
     // Run cron anonymously with the valid cron key.
-    $key = state()->get('system.cron_key');
+    $key = \Drupal::state()->get('system.cron_key');
     $this->drupalGet('cron/' . $key);
     $this->assertResponse(204);
   }
@@ -58,19 +58,19 @@ function testAutomaticCron() {
     // not passed.
     $cron_last = time();
     $cron_safe_threshold = 100;
-    state()->set('system.cron_last', $cron_last);
+    \Drupal::state()->set('system.cron_last', $cron_last);
     config('system.cron')
       ->set('threshold.autorun', $cron_safe_threshold)
       ->save();
     $this->drupalGet('');
-    $this->assertTrue($cron_last == state()->get('system.cron_last'), 'Cron does not run when the cron threshold is not passed.');
+    $this->assertTrue($cron_last == \Drupal::state()->get('system.cron_last'), 'Cron does not run when the cron threshold is not passed.');
 
     // Test if cron runs when the cron threshold was passed.
     $cron_last = time() - 200;
-    state()->set('system.cron_last', $cron_last);
+    \Drupal::state()->set('system.cron_last', $cron_last);
     $this->drupalGet('');
     sleep(1);
-    $this->assertTrue($cron_last < state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.');
+    $this->assertTrue($cron_last < \Drupal::state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.');
 
     // Disable the cron threshold through the interface.
     $admin_user = $this->drupalCreateUser(array('administer site configuration'));
@@ -81,21 +81,21 @@ function testAutomaticCron() {
 
     // Test if cron does not run when the cron threshold is disabled.
     $cron_last = time() - 200;
-    state()->set('system.cron_last', $cron_last);
+    \Drupal::state()->set('system.cron_last', $cron_last);
     $this->drupalGet('');
-    $this->assertTrue($cron_last == state()->get('system.cron_last'), 'Cron does not run when the cron threshold is disabled.');
+    $this->assertTrue($cron_last == \Drupal::state()->get('system.cron_last'), 'Cron does not run when the cron threshold is disabled.');
   }
 
   /**
    * Make sure exceptions thrown on hook_cron() don't affect other modules.
    */
   function testCronExceptions() {
-    state()->delete('common_test.cron');
+    \Drupal::state()->delete('common_test.cron');
     // The common_test module throws an exception. If it isn't caught, the tests
     // won't finish successfully.
     // The common_test_cron_helper module sets the 'common_test_cron' variable.
     $this->cronRun();
-    $result = state()->get('common_test.cron');
+    $result = \Drupal::state()->get('common_test.cron');
     $this->assertEqual($result, 'success', 'Cron correctly handles exceptions thrown during hook_cron() invocations.');
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php
index 8b98ecf..bbc3fb1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/FrontPageTest.php
@@ -40,7 +40,7 @@ function setUp() {
     // Configure 'node' as front page.
     config('system.site')->set('page.front', 'node')->save();
     // Enable front page logging in system_test.module.
-    state()->set('system_test.front_page_output', 1);
+    \Drupal::state()->set('system_test.front_page_output', 1);
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php
index 7913f96..6aa50b2 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/ModulesDisabledUpgradePathTest.php
@@ -53,6 +53,6 @@ public function testDisabledUpgrade() {
     require_once DRUPAL_ROOT . '/core/includes/install.inc';
     $updates = update_get_update_list();
     $this->assertEqual($updates, array(), 'No pending updates after enabling all modules.');
-    $this->assertTrue(state()->get('update_test_1_update_dependencies_run'), 'Module update dependencies resolved for disabled modules');
+    $this->assertTrue(\Drupal::state()->get('update_test_1_update_dependencies_run'), 'Module update dependencies resolved for disabled modules');
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
index ffa786f..b9a97a5 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
@@ -81,7 +81,7 @@ public function testSystemVariableUpgrade() {
     );
 
     foreach ($expected_state as $name => $data) {
-      $this->assertIdentical(state()->get($name), $data['value']);
+      $this->assertIdentical(\Drupal::state()->get($name), $data['value']);
       $deleted = !db_query('SELECT value FROM {variable} WHERE name = :name', array(':name' => $data['variable_name']))->fetchField();
       $this->assertTrue($deleted, format_string('Variable !name has been deleted.', array('!name' => $data['variable_name'])));
     }
diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php
index 32e4efc..61f1844 100644
--- a/core/modules/system/system.api.php
+++ b/core/modules/system/system.api.php
@@ -113,11 +113,11 @@ function hook_admin_paths_alter(&$paths) {
 function hook_cron() {
   // Short-running operation example, not using a queue:
   // Delete all expired records since the last cron run.
-  $expires = state()->get('mymodule.cron_last_run') ?: REQUEST_TIME;
+  $expires = \Drupal::state()->get('mymodule.cron_last_run') ?: REQUEST_TIME;
   db_delete('mymodule_table')
     ->condition('expires', $expires, '>=')
     ->execute();
-  state()->set('mymodule.cron_last_run', REQUEST_TIME);
+  \Drupal::state()->set('mymodule.cron_last_run', REQUEST_TIME);
 
   // Long-running operation example, leveraging a queue:
   // Fetch feeds from other sites.
@@ -2342,7 +2342,7 @@ function hook_requirements($phase) {
 
   // Report cron status
   if ($phase == 'runtime') {
-    $cron_last = state()->get('system.cron_last');
+    $cron_last = \Drupal::state()->get('system.cron_last');
 
     if (is_numeric($cron_last)) {
       $requirements['cron']['value'] = $t('Last run !time ago', array('!time' => format_interval(REQUEST_TIME - $cron_last)));
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index 766bba6..e7a2a34 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -274,7 +274,7 @@ function system_requirements($phase) {
     $help = $t('For more information, see the online handbook entry for <a href="@cron-handbook">configuring cron jobs</a>.', array('@cron-handbook' => 'http://drupal.org/cron'));
 
     // Determine when cron last ran.
-    $cron_last = state()->get('system.cron_last');
+    $cron_last = Drupal::state()->get('system.cron_last');
     if (!is_numeric($cron_last)) {
       $cron_last = variable_get('install_time', 0);
     }
@@ -296,7 +296,7 @@ function system_requirements($phase) {
     }
 
     $description .= ' ' . $t('You can <a href="@cron">run cron manually</a>.', array('@cron' => url('admin/reports/status/run-cron')));
-    $description .= '<br />' . $t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url('cron/' . state()->get('system.cron_key'), array('absolute' => TRUE))));
+    $description .= '<br />' . $t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url('cron/' . Drupal::state()->get('system.cron_key'), array('absolute' => TRUE))));
 
     $requirements['cron'] = array(
       'title' => $t('Cron maintenance tasks'),
@@ -534,7 +534,7 @@ function system_install() {
 
   // Populate the cron key state variable.
   $cron_key = Crypt::randomStringHashed(55);
-  state()->set('system.cron_key', $cron_key);
+  Drupal::state()->set('system.cron_key', $cron_key);
 }
 
 /**
@@ -642,7 +642,7 @@ function system_schema() {
   );
 
   $schema['key_value'] = array(
-    'description' => 'Generic key-value storage table. See state() for an example.',
+    'description' => 'Generic key-value storage table. See the state system for an example.',
     'fields' => array(
       'collection' => array(
         'description' => 'A named collection of key and value pairs.',
@@ -1697,7 +1697,7 @@ function system_update_8028() {
  */
 function system_update_8029() {
   if ($value = update_variable_get('path_alias_whitelist', FALSE)) {
-    state()->set('system.path_alias_whitelist', $value);
+    Drupal::state()->set('system.path_alias_whitelist', $value);
   }
   update_variable_del('path_alias_whitelist');
 }
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index cf877ac..d891e26 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -2909,7 +2909,7 @@ function system_rebuild_module_data() {
 
     // Store filenames to allow system_list() and drupal_get_filename() to
     // retrieve them without having to rebuild or scan the filesystem.
-    state()->set('system.module.files', $files);
+    Drupal::state()->set('system.module.files', $files);
   }
   return $modules_cache;
 }
@@ -2928,7 +2928,7 @@ function _system_update_bootstrap_status() {
       $bootstrap_modules[$module] = drupal_get_filename('module', $module);
     }
   }
-  state()->set('system.module.bootstrap', $bootstrap_modules);
+  Drupal::state()->set('system.module.bootstrap', $bootstrap_modules);
 }
 
 /**
@@ -3073,11 +3073,11 @@ function system_rebuild_theme_data() {
   }
   // Replace last known theme data state.
   // @todo Obsolete with proper installation status for themes.
-  state()->set('system.theme.data', $themes);
+  Drupal::state()->set('system.theme.data', $themes);
 
   // Store filenames to allow system_list() and drupal_get_filename() to
   // retrieve them without having to rebuild or scan the filesystem.
-  state()->set('system.theme.files', $files);
+  Drupal::state()->set('system.theme.files', $files);
 
   return $themes;
 }
@@ -3648,7 +3648,7 @@ function system_run_automated_cron() {
   // Otherwise it could be triggered prematurely by Ajax requests during
   // installation.
   if (($threshold = config('system.cron')->get('threshold.autorun')) > 0 && variable_get('install_task') == 'done') {
-    $cron_last = state()->get('system.cron_last') ?: NULL;
+    $cron_last = Drupal::state()->get('system.cron_last') ?: NULL;
     if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) {
       drupal_cron_run();
     }
diff --git a/core/modules/system/tests/modules/batch_test/batch_test.module b/core/modules/system/tests/modules/batch_test/batch_test.module
index a5f2995..85ee47c 100644
--- a/core/modules/system/tests/modules/batch_test/batch_test.module
+++ b/core/modules/system/tests/modules/batch_test/batch_test.module
@@ -527,12 +527,12 @@ function _batch_test_theme_callback() {
  */
 function batch_test_stack($data = NULL, $reset = FALSE) {
   if ($reset) {
-    state()->delete('batch_test.stack');
+    Drupal::state()->delete('batch_test.stack');
   }
   if (!isset($data)) {
-    return state()->get('batch_test.stack');
+    return Drupal::state()->get('batch_test.stack');
   }
-  $stack = state()->get('batch_test.stack');
+  $stack = Drupal::state()->get('batch_test.stack');
   $stack[] = $data;
-  state()->set('batch_test.stack', $stack);
+  Drupal::state()->set('batch_test.stack', $stack);
 }
diff --git a/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module b/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module
index e2154ed..ef3ac88 100644
--- a/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module
+++ b/core/modules/system/tests/modules/common_test_cron_helper/common_test_cron_helper.module
@@ -14,5 +14,5 @@
  * @see common_test_cron()
  */
 function common_test_cron_helper_cron() {
-  state()->set('common_test.cron', 'success');
+  Drupal::state()->set('common_test.cron', 'success');
 }
diff --git a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
index 6f23ebb..962114c 100644
--- a/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
+++ b/core/modules/system/tests/modules/entity_cache_test/entity_cache_test.module
@@ -21,6 +21,6 @@ function entity_cache_test_watchdog($log_entry) {
     $info = entity_get_info('entity_cache_test');
     // Store the information in a system variable to analyze it later in the
     // test case.
-    state()->set('entity_cache_test', $info);
+    Drupal::state()->set('entity_cache_test', $info);
   }
 }
diff --git a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module
index 392a03b..f2e9873 100644
--- a/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module
+++ b/core/modules/system/tests/modules/entity_cache_test_dependency/entity_cache_test_dependency.module
@@ -9,5 +9,5 @@
  * Implements hook_entity_info_alter().
  */
 function entity_cache_test_dependency_entity_info_alter(&$info) {
-  $info['entity_cache_test']['label'] = state()->get('entity_cache_test.label') ?: 'Entity Cache Test';
+  $info['entity_cache_test']['label'] = Drupal::state()->get('entity_cache_test.label') ?: 'Entity Cache Test';
 }
diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module
index 9ceab31..3ba9e09 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -57,7 +57,7 @@ function entity_test_entity_types($filter = NULL) {
  */
 function entity_test_entity_info_alter(&$info) {
   // Optionally specify a translation handler for testing translations.
-  if (state()->get('entity_test.translation')) {
+  if (Drupal::state()->get('entity_test.translation')) {
     foreach(entity_test_entity_types() as $entity_type) {
       $info[$entity_type]['translation'][$entity_type] = TRUE;
     }
@@ -217,7 +217,7 @@ function entity_test_menu() {
  */
 function entity_test_form_node_form_alter(&$form, &$form_state, $form_id) {
   $langcode = $form_state['controller']->getFormLangcode($form_state);
-  state()->set('entity_test.form_langcode', $langcode);
+  Drupal::state()->set('entity_test.form_langcode', $langcode);
 }
 
 /**
diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php
index 18f55c6..12ebae7 100644
--- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php
+++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php
@@ -106,9 +106,9 @@ public function desaturate($image) {
    * @see \Drupal\system\Tests\Image\ToolkitTestBase::imageTestGetAllCalls()
    */
   protected function logCall($op, $args) {
-    $results = state()->get('image_test.results') ?: array();
+    $results = \Drupal::state()->get('image_test.results') ?: array();
     $results[$op][] = $args;
-    state()->set('image_test.results', $results);
+    \Drupal::state()->set('image_test.results', $results);
   }
 
   /**
diff --git a/core/modules/system/tests/modules/menu_test/menu_test.module b/core/modules/system/tests/modules/menu_test/menu_test.module
index fec466b..f0a02c5 100644
--- a/core/modules/system/tests/modules/menu_test/menu_test.module
+++ b/core/modules/system/tests/modules/menu_test/menu_test.module
@@ -524,7 +524,7 @@ function menu_test_callback() {
  * Callback that test menu_test_menu_tree_set_path().
  */
 function menu_test_menu_trail_callback() {
-  $menu_path = state()->get('menu_test.menu_tree_set_path') ?: array();
+  $menu_path = Drupal::state()->get('menu_test.menu_tree_set_path') ?: array();
   if (!empty($menu_path)) {
     menu_tree_set_path($menu_path['menu_name'], $menu_path['path']);
   }
@@ -538,8 +538,8 @@ function menu_test_custom_403_404_callback() {
   // When requested by one of the MenuTrailTestCase tests, record the final
   // active trail now that the user has been redirected to the custom 403 or
   // 404 page. See menu_test_init().
-  if (state()->get('menu_test.record_active_trail') ?: FALSE) {
-    state()->set('menu_test.active_trail_final', menu_get_active_trail());
+  if (Drupal::state()->get('menu_test.record_active_trail') ?: FALSE) {
+    Drupal::state()->set('menu_test.active_trail_final', menu_get_active_trail());
   }
 
   return 'This is menu_test_custom_403_404_callback().';
@@ -605,13 +605,13 @@ function menu_test_custom_theme() {
   // When requested by one of the MenuTrailTestCase tests, record the initial
   // active trail during Drupal's bootstrap (before the user is redirected to a
   // custom 403 or 404 page). See menu_test_custom_403_404_callback().
-  if (state()->get('menu_test.record_active_trail') ?: FALSE) {
-    state()->set('menu_test.active_trail_initial', menu_get_active_trail());
+  if (Drupal::state()->get('menu_test.record_active_trail') ?: FALSE) {
+    Drupal::state()->set('menu_test.active_trail_initial', menu_get_active_trail());
   }
   // If an appropriate variable has been set in the database, request the theme
   // that is stored there. Otherwise, do not attempt to dynamically set the
   // theme.
-  if ($theme = state()->get('menu_test.hook_custom_theme_name') ?: FALSE) {
+  if ($theme = Drupal::state()->get('menu_test.hook_custom_theme_name') ?: FALSE) {
     return $theme;
   }
 }
diff --git a/core/modules/system/tests/modules/module_test/module_test.module b/core/modules/system/tests/modules/module_test/module_test.module
index 1d35ea9..39caf92 100644
--- a/core/modules/system/tests/modules/module_test/module_test.module
+++ b/core/modules/system/tests/modules/module_test/module_test.module
@@ -15,7 +15,7 @@ function module_test_permission() {
  * Manipulate module dependencies to test dependency chains.
  */
 function module_test_system_info_alter(&$info, $file, $type) {
-  if (state()->get('module_test.dependency') == 'missing dependency') {
+  if (Drupal::state()->get('module_test.dependency') == 'missing dependency') {
     if ($file->name == 'forum') {
       // Make forum module depend on ban.
       $info['dependencies'][] = 'ban';
@@ -25,7 +25,7 @@ function module_test_system_info_alter(&$info, $file, $type) {
       $info['dependencies'][] = 'foo';
     }
   }
-  elseif (state()->get('module_test.dependency') == 'dependency') {
+  elseif (Drupal::state()->get('module_test.dependency') == 'dependency') {
     if ($file->name == 'forum') {
       // Make the forum module depend on ban.
       $info['dependencies'][] = 'ban';
@@ -35,7 +35,7 @@ function module_test_system_info_alter(&$info, $file, $type) {
       $info['dependencies'][] = 'php';
     }
   }
-  elseif (state()->get('module_test.dependency') == 'version dependency') {
+  elseif (Drupal::state()->get('module_test.dependency') == 'version dependency') {
     if ($file->name == 'forum') {
       // Make the forum module depend on ban.
       $info['dependencies'][] = 'ban';
@@ -155,7 +155,7 @@ function module_test_class_loading() {
 function module_test_modules_enabled($modules) {
   // Record the ordered list of modules that were passed in to this hook so we
   // can check that the modules were enabled in the correct sequence.
-  state()->set('system_test.module_enable_order', $modules);
+  Drupal::state()->set('system_test.module_enable_order', $modules);
 }
 
 /**
@@ -164,7 +164,7 @@ function module_test_modules_enabled($modules) {
 function module_test_modules_disabled($modules) {
   // Record the ordered list of modules that were passed in to this hook so we
   // can check that the modules were disabled in the correct sequence.
-  state()->set('module_test.disable_order', $modules);
+  Drupal::state()->set('module_test.disable_order', $modules);
 }
 
 /**
@@ -173,5 +173,5 @@ function module_test_modules_disabled($modules) {
 function module_test_modules_uninstalled($modules) {
   // Record the ordered list of modules that were passed in to this hook so we
   // can check that the modules were uninstalled in the correct sequence.
-  state()->set('module_test.uninstall_order', $modules);
+  Drupal::state()->set('module_test.uninstall_order', $modules);
 }
diff --git a/core/modules/system/tests/modules/path_test/path_test.module b/core/modules/system/tests/modules/path_test/path_test.module
index dd70498..6f4d580 100644
--- a/core/modules/system/tests/modules/path_test/path_test.module
+++ b/core/modules/system/tests/modules/path_test/path_test.module
@@ -9,14 +9,14 @@
  * Resets the path test results.
  */
 function path_test_reset() {
-  state()->set('path_test.results', array());
+  Drupal::state()->set('path_test.results', array());
 }
 
 /**
  * Implements hook_path_update().
  */
 function path_test_path_update($path) {
-  $results = state()->get('path_test.results') ?: array();
+  $results = Drupal::state()->get('path_test.results') ?: array();
   $results['hook_path_update'] = $path;
-  state()->set('path_test.results', $results);
+  Drupal::state()->set('path_test.results', $results);
 }
diff --git a/core/modules/system/tests/modules/system_test/system_test.module b/core/modules/system/tests/modules/system_test/system_test.module
index 6afb8ac..b73bb5a 100644
--- a/core/modules/system/tests/modules/system_test/system_test.module
+++ b/core/modules/system/tests/modules/system_test/system_test.module
@@ -88,7 +88,7 @@ function system_test_set_header() {
  * Implements hook_modules_installed().
  */
 function system_test_modules_installed($modules) {
-  if (state()->get('system_test.verbose_module_hooks')) {
+  if (Drupal::state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_installed fired for @module', array('@module' => $module)));
     }
@@ -99,7 +99,7 @@ function system_test_modules_installed($modules) {
  * Implements hook_modules_enabled().
  */
 function system_test_modules_enabled($modules) {
-  if (state()->get('system_test.verbose_module_hooks')) {
+  if (Drupal::state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_enabled fired for @module', array('@module' => $module)));
     }
@@ -110,7 +110,7 @@ function system_test_modules_enabled($modules) {
  * Implements hook_modules_disabled().
  */
 function system_test_modules_disabled($modules) {
-  if (state()->get('system_test.verbose_module_hooks')) {
+  if (Drupal::state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_disabled fired for @module', array('@module' => $module)));
     }
@@ -121,7 +121,7 @@ function system_test_modules_disabled($modules) {
  * Implements hook_modules_uninstalled().
  */
 function system_test_modules_uninstalled($modules) {
-  if (state()->get('system_test.verbose_module_hooks')) {
+  if (Drupal::state()->get('system_test.verbose_module_hooks')) {
     foreach ($modules as $module) {
       drupal_set_message(t('hook_modules_uninstalled fired for @module', array('@module' => $module)));
     }
@@ -134,11 +134,11 @@ function system_test_modules_uninstalled($modules) {
 function system_test_system_info_alter(&$info, $file, $type) {
   // We need a static otherwise the last test will fail to alter common_test.
   static $test;
-  if (($dependencies = state()->get('system_test.dependencies')) || $test) {
+  if (($dependencies = Drupal::state()->get('system_test.dependencies')) || $test) {
     if ($file->name == 'module_test') {
       $info['hidden'] = FALSE;
       $info['dependencies'][] = array_shift($dependencies);
-      state()->set('system_test.dependencies', $dependencies);
+      Drupal::state()->set('system_test.dependencies', $dependencies);
       $test = TRUE;
     }
     if ($file->name == 'common_test') {
@@ -210,7 +210,7 @@ function system_test_page_build(&$page) {
     drupal_set_page_content();
   }
   // Used by FrontPageTestCase to get the results of drupal_is_front_page().
-  $frontpage = state()->get('system_test.front_page_output') ?: 0;
+  $frontpage = Drupal::state()->get('system_test.front_page_output') ?: 0;
   if ($frontpage && drupal_is_front_page()) {
     drupal_set_message(t('On front page.'));
   }
diff --git a/core/modules/system/tests/modules/update_test_1/update_test_1.install b/core/modules/system/tests/modules/update_test_1/update_test_1.install
index bf0beb3..3ac73db 100644
--- a/core/modules/system/tests/modules/update_test_1/update_test_1.install
+++ b/core/modules/system/tests/modules/update_test_1/update_test_1.install
@@ -11,7 +11,7 @@
  * @see update_test_2_update_dependencies()
  */
 function update_test_1_update_dependencies() {
-  state()->set('update_test_1_update_dependencies_run', TRUE);
+  Drupal::state()->set('update_test_1_update_dependencies_run', TRUE);
   // These dependencies are used in combination with those declared in
   // update_test_2_update_dependencies() for the sole purpose of testing that
   // the results of hook_update_dependencies() are collected correctly and have
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
index b15efc3..d9db513 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
@@ -32,7 +32,7 @@ public static function getInfo() {
   public function setUp() {
     parent::setUp();
     node_access_rebuild();
-    state()->set('node_access_test.private', TRUE);
+    \Drupal::state()->set('node_access_test.private', TRUE);
   }
 
   /**
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
index aab8d9e..26492f6 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
@@ -222,7 +222,7 @@ function testTrackerCronIndexing() {
     $this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save'));
 
     // Start indexing backwards from node 3.
-    state()->set('tracker.index_nid', 3);
+    \Drupal::state()->set('tracker.index_nid', 3);
 
     // Clear the current tracker tables and rebuild them.
     db_delete('tracker_node')
diff --git a/core/modules/tracker/tracker.install b/core/modules/tracker/tracker.install
index 429b88e..841d74a 100644
--- a/core/modules/tracker/tracker.install
+++ b/core/modules/tracker/tracker.install
@@ -9,7 +9,7 @@
  * Implements hook_uninstall().
  */
 function tracker_uninstall() {
-  state()->delete('tracker.index_nid');
+  Drupal::state()->delete('tracker.index_nid');
 }
 
 /**
@@ -18,7 +18,7 @@ function tracker_uninstall() {
 function tracker_enable() {
   $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
   if ($max_nid != 0) {
-    state()->set('tracker.index_nid', $max_nid);
+    Drupal::state()->set('tracker.index_nid', $max_nid);
     // To avoid timing out while attempting to do a complete indexing, we
     // simply call our cron job to remove stale records and begin the process.
     tracker_cron();
diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module
index 34235b9..629c756 100644
--- a/core/modules/tracker/tracker.module
+++ b/core/modules/tracker/tracker.module
@@ -79,7 +79,7 @@ function tracker_menu() {
  * process, 'tracker.index_nid' will be 0.
  */
 function tracker_cron() {
-  $state = state();
+  $state = Drupal::state();
   $max_nid = $state->get('tracker.index_nid') ?: 0;
   if ($max_nid > 0) {
     $batch_size = config('tracker.settings')->get('cron_index_limit');
diff --git a/core/modules/update/update.fetch.inc b/core/modules/update/update.fetch.inc
index 0d64ca4..96f00f1 100644
--- a/core/modules/update/update.fetch.inc
+++ b/core/modules/update/update.fetch.inc
@@ -189,7 +189,7 @@ function _update_process_fetch_task($project) {
   Drupal::keyValueExpirable('update')->setWithExpire('fetch_failures', $fail, $request_time_difference + (60 * 5));
 
   // Whether this worked or not, we did just (try to) check for updates.
-  state()->set('update.last_check', REQUEST_TIME + $request_time_difference);
+  Drupal::state()->set('update.last_check', REQUEST_TIME + $request_time_difference);
 
   // Now that we processed the fetch task for this project, clear out the
   // record for this task so we're willing to fetch again.
@@ -364,7 +364,7 @@ function _update_cron_notify() {
         // Track when the last mail was successfully sent to avoid sending
         // too many e-mails.
         if ($message['result']) {
-          state()->set('update.last_email_notification', REQUEST_TIME);
+          Drupal::state()->set('update.last_email_notification', REQUEST_TIME);
         }
       }
     }
diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc
index bc84058..fc07b00 100644
--- a/core/modules/update/update.manager.inc
+++ b/core/modules/update/update.manager.inc
@@ -278,7 +278,7 @@ function update_manager_update_form($form, $form_state = array(), $context) {
  */
 function theme_update_manager_update_form($variables) {
   $form = $variables['form'];
-  $last = state()->get('update.last_check') ?: 0;
+  $last = Drupal::state()->get('update.last_check') ?: 0;
   $output = theme('update_last_check', array('last' => $last));
   $output .= drupal_render_children($form);
   return $output;
diff --git a/core/modules/update/update.module b/core/modules/update/update.module
index 7ab2249..83ba194 100644
--- a/core/modules/update/update.module
+++ b/core/modules/update/update.module
@@ -284,7 +284,7 @@ function update_cron() {
   $update_config = config('update.settings');
   $frequency = $update_config->get('check.interval_days');
   $interval = 60 * 60 * 24 * $frequency;
-  $last_check = state()->get('update.last_check') ?: 0;
+  $last_check = Drupal::state()->get('update.last_check') ?: 0;
   if ((REQUEST_TIME - $last_check) > $interval) {
     // If the configured update interval has elapsed, we want to invalidate
     // the data for all projects, attempt to re-fetch, and trigger any
@@ -297,7 +297,7 @@ function update_cron() {
     // missing data, and if so, try to fetch the data.
     update_get_available(TRUE);
   }
-  $last_email_notice = state()->get('update.last_email_notification') ?: 0;
+  $last_email_notice = Drupal::state()->get('update.last_email_notification') ?: 0;
   if ((REQUEST_TIME - $last_email_notice) > $interval) {
     // If configured time between notifications elapsed, send email about
     // updates possibly available.
diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc
index 35677d8..ea778d7 100644
--- a/core/modules/update/update.report.inc
+++ b/core/modules/update/update.report.inc
@@ -17,7 +17,7 @@
 function theme_update_report($variables) {
   $data = $variables['data'];
 
-  $last = state()->get('update.last_check') ?: 0;
+  $last = Drupal::state()->get('update.last_check') ?: 0;
   $output = theme('update_last_check', array('last' => $last));
 
   if (!is_array($data)) {
diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php
index 3f21b88..eb1894e 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayAttachmentTest.php
@@ -41,7 +41,7 @@ protected function setUp() {
    */
   protected function testAttachment() {
     // @todo Remove that once http://drupal.org/node/1828444 got in.
-    state()->set('menu_rebuild_needed', TRUE);
+    \Drupal::state()->set('menu_rebuild_needed', TRUE);
 
     $this->drupalGet('test-display-attachment');
 
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php
index 8c7f071..02ab62d 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewRenderTest.php
@@ -37,14 +37,14 @@ protected function setUp() {
    * Tests render functionality.
    */
   public function testRender() {
-    state()->set('views_render.test', 0);
+    \Drupal::state()->set('views_render.test', 0);
 
     // Make sure that the rendering just calls the preprocess function once.
     $view = views_get_view('test_view_render');
     $output = $view->preview();
     drupal_render($output);
 
-    $this->assertEqual(state()->get('views_render.test'), 1);
+    $this->assertEqual(\Drupal::state()->get('views_render.test'), 1);
   }
 
 }
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
index 9041742..5a00bd7 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestBase.php
@@ -48,8 +48,8 @@ protected function setUp() {
    */
   protected function enableViewsTestModule() {
     // Define the schema and views data variable before enabling the test module.
-    state()->set('views_test_data_schema', $this->schemaDefinition());
-    state()->set('views_test_data_views_data', $this->viewsData());
+    \Drupal::state()->set('views_test_data_schema', $this->schemaDefinition());
+    \Drupal::state()->set('views_test_data_views_data', $this->viewsData());
 
     module_enable(array('views_test_data'));
     $this->resetAll();
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php b/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php
index 134b97a..6127ece 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewUnitTestBase.php
@@ -45,8 +45,8 @@ protected function setUp() {
    */
   protected function setUpFixtures() {
     // Define the schema and views data variable before enabling the test module.
-    state()->set('views_test_data_schema', $this->schemaDefinition());
-    state()->set('views_test_data_views_data', $this->viewsData());
+    \Drupal::state()->set('views_test_data_schema', $this->schemaDefinition());
+    \Drupal::state()->set('views_test_data_views_data', $this->viewsData());
 
     $this->installConfig(array('views', 'views_test_config', 'views_test_data'));
     foreach ($this->schemaDefinition() as $table => $schema) {
diff --git a/core/modules/views/tests/views_test_data/views_test_data.install b/core/modules/views/tests/views_test_data/views_test_data.install
index 520796d..6b1a868 100644
--- a/core/modules/views/tests/views_test_data/views_test_data.install
+++ b/core/modules/views/tests/views_test_data/views_test_data.install
@@ -9,7 +9,7 @@
  * Implements hook_schema().
  */
 function views_test_data_schema() {
-  return state()->get('views_test_data_schema');
+  return Drupal::state()->get('views_test_data_schema');
 }
 
 /**
diff --git a/core/modules/views/tests/views_test_data/views_test_data.module b/core/modules/views/tests/views_test_data/views_test_data.module
index 4dd4386..1adabc7 100644
--- a/core/modules/views/tests/views_test_data/views_test_data.module
+++ b/core/modules/views/tests/views_test_data/views_test_data.module
@@ -60,9 +60,9 @@ function views_test_data_handler_test_access_callback_argument($argument = FALSE
  */
 function views_test_data_preprocess_views_view_table(&$variables) {
   if ($variables['view']->storage->id() == 'test_view_render') {
-    $views_render_test = state()->get('views_render.test');
+    $views_render_test = Drupal::state()->get('views_render.test');
     $views_render_test++;
-    state()->set('views_render.test', $views_render_test);
+    Drupal::state()->set('views_render.test', $views_render_test);
   }
 }
 
diff --git a/core/modules/views/tests/views_test_data/views_test_data.views.inc b/core/modules/views/tests/views_test_data/views_test_data.views.inc
index b0fb4bc..ad5b23f 100644
--- a/core/modules/views/tests/views_test_data/views_test_data.views.inc
+++ b/core/modules/views/tests/views_test_data/views_test_data.views.inc
@@ -30,14 +30,14 @@ function views_test_data_views_data() {
  * Implements hook_views_data_alter().
  */
 function views_test_data_views_data_alter() {
-  state()->set('views_hook_test_views_data_alter', TRUE);
+  Drupal::state()->set('views_hook_test_views_data_alter', TRUE);
 }
 
 /**
  * Implements hook_views_analyze().
  */
 function views_test_data_views_analyze(ViewExecutable $view) {
-  state()->set('views_hook_test_views_analyze', TRUE);
+  Drupal::state()->set('views_hook_test_views_analyze', TRUE);
 
   $ret = array();
 
@@ -52,5 +52,5 @@ function views_test_data_views_analyze(ViewExecutable $view) {
  * Implements hook_views_invalidate_cache().
  */
 function views_test_data_views_invalidate_cache() {
-  state()->set('views_hook_test_views_invalidate_cache', TRUE);
+  Drupal::state()->set('views_hook_test_views_invalidate_cache', TRUE);
 }
diff --git a/core/modules/views/tests/views_test_data/views_test_data.views_execution.inc b/core/modules/views/tests/views_test_data/views_test_data.views_execution.inc
index f37febf..e5a4277 100644
--- a/core/modules/views/tests/views_test_data/views_test_data.views_execution.inc
+++ b/core/modules/views/tests/views_test_data/views_test_data.views_execution.inc
@@ -12,28 +12,28 @@
  * Implements hook_views_query_substitutions().
  */
 function views_test_data_views_query_substitutions(ViewExecutable $view) {
-  state()->set('views_hook_test_views_query_substitutions', TRUE);
+  Drupal::state()->set('views_hook_test_views_query_substitutions', TRUE);
 }
 
 /**
  * Implements hook_views_form_substitutions().
  */
 function views_test_data_views_form_substitutions(ViewExecutable $view) {
-  state()->set('views_hook_test_views_form_substitutions', TRUE);
+  Drupal::state()->set('views_hook_test_views_form_substitutions', TRUE);
 }
 
 /**
  * Implements hook_field_views_data().
  */
 function views_test_data_field_views_data($field) {
-  state()->set('views_hook_test_field_views_data', TRUE);
+  Drupal::state()->set('views_hook_test_field_views_data', TRUE);
 }
 
 /**
  * Implements hook_field_views_data_alter().
  */
 function views_test_data_field_views_data_alter(&$data, $field, $module) {
-  state()->set('views_hook_test_field_views_data_alter', TRUE);
+  Drupal::state()->set('views_hook_test_field_views_data_alter', TRUE);
 }
 
 /**
@@ -43,7 +43,7 @@ function views_test_data_field_views_data_alter(&$data, $field, $module) {
  * @see \Drupal\views\Tests\Plugin\RenderTest
  */
 function views_test_data_views_pre_render(ViewExecutable $view) {
-  state()->set('views_hook_test_views_pre_render', TRUE);
+  Drupal::state()->set('views_hook_test_views_pre_render', TRUE);
 
   if (isset($view) && ($view->storage->id() == 'test_cache_header_storage')) {
     $path = drupal_get_path('module', 'views_test_data');
@@ -58,21 +58,21 @@ function views_test_data_views_pre_render(ViewExecutable $view) {
  * Implements hook_views_post_render().
  */
 function views_test_data_views_post_render(ViewExecutable $view) {
-  state()->set('views_hook_test_views_post_render', TRUE);
+  Drupal::state()->set('views_hook_test_views_post_render', TRUE);
 }
 
 /**
  * Implements hook_views_pre_build().
  */
 function views_test_data_views_pre_build(ViewExecutable $view) {
-  state()->set('views_hook_test_views_pre_build', TRUE);
+  Drupal::state()->set('views_hook_test_views_pre_build', TRUE);
 }
 
 /**
  * Implements hook_views_post_build().
  */
 function views_test_data_views_post_build(ViewExecutable $view) {
-  state()->set('views_hook_test_views_post_build', TRUE);
+  Drupal::state()->set('views_hook_test_views_post_build', TRUE);
 
   if (isset($view) && ($view->storage->id() == 'test_page_display')) {
     if ($view->current_display == 'page_1') {
@@ -88,26 +88,26 @@ function views_test_data_views_post_build(ViewExecutable $view) {
  * Implements hook_views_pre_view().
  */
 function views_test_data_views_pre_view(ViewExecutable $view) {
-  state()->set('views_hook_test_views_pre_view', TRUE);
+  Drupal::state()->set('views_hook_test_views_pre_view', TRUE);
 }
 
 /**
  * Implements hook_views_pre_execute().
  */
 function views_test_data_views_pre_execute(ViewExecutable $view) {
-  state()->set('views_hook_test_views_pre_execute', TRUE);
+  Drupal::state()->set('views_hook_test_views_pre_execute', TRUE);
 }
 
 /**
  * Implements hook_views_post_execute().
  */
 function views_test_data_views_post_execute(ViewExecutable $view) {
-  state()->set('views_hook_test_views_post_execute', TRUE);
+  Drupal::state()->set('views_hook_test_views_post_execute', TRUE);
 }
 
 /**
  * Implements hook_views_query_alter().
  */
 function views_test_data_views_query_alter(ViewExecutable $view) {
-  state()->set('views_hook_test_views_query_alter', TRUE);
+  Drupal::state()->set('views_hook_test_views_query_alter', TRUE);
 }
diff --git a/core/modules/views/views.module b/core/modules/views/views.module
index 945e7d9..2ccf1fa 100644
--- a/core/modules/views/views.module
+++ b/core/modules/views/views.module
@@ -678,7 +678,7 @@ function views_invalidate_cache() {
   Cache::deleteTags(array('content' => TRUE));
 
   // Set the menu as needed to be rebuilt.
-  state()->set('menu_rebuild_needed', TRUE);
+  Drupal::state()->set('menu_rebuild_needed', TRUE);
 
   $module_handler = Drupal::moduleHandler();
 
diff --git a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php
index d4ba19a..637d7a2 100644
--- a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php
+++ b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcMessagesTest.php
@@ -48,12 +48,12 @@ function testSizedMessages() {
    */
   protected function testAlterListMethods() {
     // Ensure xmlrpc_test.alter() is disabled and retrieve regular list of methods.
-    state()->set('xmlrpc_test.alter', FALSE);
+    \Drupal::state()->set('xmlrpc_test.alter', FALSE);
     $url = url('xmlrpc.php', array('absolute' => TRUE));
     $methods1 = xmlrpc($url, array('system.listMethods' => array()));
 
     // Enable the alter hook and retrieve the list of methods again.
-    state()->set('xmlrpc_test.alter', TRUE);
+    \Drupal::state()->set('xmlrpc_test.alter', TRUE);
     $methods2 = xmlrpc($url, array('system.listMethods' => array()));
 
     $diff = array_diff($methods1, $methods2);
diff --git a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module
index 11c86c3..4a772ab 100644
--- a/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module
+++ b/core/modules/xmlrpc/tests/modules/xmlrpc_test/xmlrpc_test.module
@@ -68,7 +68,7 @@ function xmlrpc_test_xmlrpc() {
  * Hide (or not) the system.methodSignature() service depending on a variable.
  */
 function xmlrpc_test_xmlrpc_alter(&$services) {
-  $xmlprc_alter = state()->get('xmlrpc_test.alter') ?: FALSE;
+  $xmlprc_alter = Drupal::state()->get('xmlrpc_test.alter') ?: FALSE;
   if ($xmlprc_alter) {
     $remove = NULL;
     foreach ($services as $key => $value) {
