From 78b48c89ada71ae10857f8cb7aa12c25c9914560 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Fri, 28 Feb 2014 10:43:51 +0000
Subject: [PATCH] Issue #2092095 by tstoeckler, ParisLiakos: Remove
 \Drupal\Component\Utility\MapArray.

---
 core/includes/common.inc                      |  10 --
 core/includes/form.inc                        |  11 +-
 core/includes/theme.inc                       |   4 +-
 core/includes/update.inc                      |   2 +-
 .../Component/Plugin/DefaultPluginBag.php     |   4 +-
 .../lib/Drupal/Component/Utility/MapArray.php |  45 --------
 .../FieldableDatabaseStorageController.php    |   3 +-
 core/lib/Drupal/Core/Utility/ProjectInfo.php  |   2 +-
 .../Drupal/aggregator/FeedFormController.php  |   3 +-
 .../Drupal/aggregator/Form/OpmlFeedAdd.php    |   4 +-
 .../Plugin/Block/AggregatorFeedBlock.php      |   3 +-
 .../aggregator/processor/DefaultProcessor.php |  43 ++-----
 .../block/Tests/CategoryAutocompleteTest.php  |   3 +-
 core/modules/comment/comment.module           |   5 +-
 .../config/Form/ConfigSingleExportForm.php    |   4 +-
 .../lib/Drupal/datetime/DateHelper.php        |   6 +-
 core/modules/dblog/dblog.module               |   6 +-
 .../edit/lib/Drupal/edit/EditController.php   |   3 +-
 .../selection/SelectionBase.php               |   3 +-
 .../Plugin/views/row/EntityReference.php      |   3 +-
 .../Drupal/field/Plugin/views/field/Field.php |  16 ++-
 .../Drupal/field_ui/DisplayOverviewBase.php   |   6 +-
 .../lib/Drupal/field_ui/OverviewBase.php      |   4 +-
 .../lib/Drupal/forum/ForumSettingsForm.php    |   8 +-
 .../forum/Plugin/Block/ForumBlockBase.php     |   3 +-
 .../language/ConfigurableLanguageManager.php  |   3 +-
 core/modules/locale/locale.translation.inc    |   2 +-
 .../Plugin/migrate/source/d6/Variable.php     |   2 +-
 .../Drupal/node/NodeTypeFormController.php    |   4 +-
 .../Drupal/node/Plugin/Search/NodeSearch.php  |   3 +-
 .../Plugin/views/argument_validator/Node.php  |   2 +-
 core/modules/node/node.module                 |   3 +-
 .../FieldFormatter/NumberDecimalFormatter.php |   3 +-
 .../Plugin/Field/FieldType/DecimalItem.php    |   7 +-
 .../modules/options/tests/options_test.module |   7 +-
 .../rest/Plugin/views/style/Serializer.php    |   2 +-
 .../search/SearchPageListController.php       |   4 +-
 .../Plugin/Block/StatisticsPopularBlock.php   |   3 +-
 .../lib/Drupal/system/Form/CronForm.php       |   3 +-
 .../Drupal/system/Form/PerformanceForm.php    |   3 +-
 .../lib/Drupal/system/Form/RssFeedsForm.php   |   3 +-
 .../Tests/Entity/EntityTranslationTest.php    |   3 +-
 .../modules/entity_test/entity_test.module    |   2 +-
 .../tests/modules/form_test/form_test.module  |   4 +-
 .../plugin_test/Plugin/TestPluginBag.php      |   4 +-
 .../selection/UserSelection.php               |   2 +-
 .../views/EventSubscriber/RouteSubscriber.php |   3 +-
 .../views/Plugin/views/argument/String.php    |   2 +-
 .../Drupal/views/Plugin/views/cache/Time.php  |   2 +-
 .../Plugin/views/wizard/WizardPluginBase.php  |   2 +-
 .../Drupal/views/Tests/DefaultViewsTest.php   |   3 +-
 .../Tests/Entity/FilterEntityBundleTest.php   |   4 +-
 .../Drupal/views/Tests/ViewExecutableTest.php |   2 +-
 core/modules/views/lib/Drupal/views/Views.php |   3 +-
 core/modules/views/views.theme.inc            |  10 +-
 .../Tests/Component/Utility/MapArrayTest.php  | 105 ------------------
 56 files changed, 127 insertions(+), 282 deletions(-)
 delete mode 100644 core/lib/Drupal/Component/Utility/MapArray.php
 delete mode 100644 core/tests/Drupal/Tests/Component/Utility/MapArrayTest.php

diff --git a/core/includes/common.inc b/core/includes/common.inc
index 3c03eb71c854..6a2ac0788d8a 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -16,7 +16,6 @@
 use Symfony\Component\Yaml\Parser;
 use Symfony\Component\Yaml\Exception\ParseException;
 use Drupal\Component\PhpStorage\PhpStorageFactory;
-use Drupal\Component\Utility\MapArray;
 use Drupal\Component\Utility\NestedArray;
 use Drupal\Core\Datetime\DrupalDateTime;
 use Drupal\Core\Routing\GeneratorNotInitializedException;
@@ -1290,15 +1289,6 @@ function l($text, $path, array $options = array()) {
   return '<a href="' . $url . '"' . $attributes . '>' . $text . '</a>';
 }
 
-/**
- * Forms an associative array from a linear array.
- *
- * @see \Drupal\Component\Utility\MapArray::copyValuesToKeys()
- */
-function drupal_map_assoc($array, $callable = NULL) {
-  return MapArray::copyValuesToKeys($array, $callable);
-}
-
 /**
  * Attempts to set the PHP maximum execution time.
  *
diff --git a/core/includes/form.inc b/core/includes/form.inc
index 8636c1a1fb64..62e8f9a5374b 100644
--- a/core/includes/form.inc
+++ b/core/includes/form.inc
@@ -559,7 +559,7 @@ function form_type_checkboxes_value($element, $input = FALSE) {
         unset($input[$key]);
       }
     }
-    return drupal_map_assoc($input);
+    return array_combine($input, $input);
   }
   else {
     return array();
@@ -588,10 +588,11 @@ function form_type_table_value(array $element, $input = FALSE) {
     // @todo D8: Remove this inconsistency.
     if ($input === FALSE) {
       $element += array('#default_value' => array());
-      return drupal_map_assoc(array_keys(array_filter($element['#default_value'])));
+      $value = array_keys(array_filter($element['#default_value']));
+      return array_combine($value, $value);
     }
     else {
-      return is_array($input) ? drupal_map_assoc($input) : array();
+      return is_array($input) ? array_combine($input, $input) : array();
     }
   }
 }
@@ -666,7 +667,7 @@ function form_type_tableselect_value($element, $input = FALSE) {
       return $value;
     }
     else {
-      return is_array($input) ? drupal_map_assoc($input) : array();
+      return is_array($input) ? array_combine($input, $input) : array();
     }
   }
 }
@@ -711,7 +712,7 @@ function form_type_select_value($element, $input = FALSE) {
       // unselected. A disabled multi-select always submits NULL, and the
       // default value should be used.
       if (empty($element['#disabled'])) {
-        return (is_array($input)) ? drupal_map_assoc($input) : array();
+        return (is_array($input)) ? array_combine($input, $input) : array();
       }
       else {
         return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : array();
diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index dad6f65bd625..5064d6eee9e1 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -17,7 +17,6 @@
 use Drupal\Core\Template\RenderWrapper;
 use Drupal\Core\Theme\ThemeSettings;
 use Drupal\Component\Utility\NestedArray;
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Render\Element;
 
 /**
@@ -1291,10 +1290,11 @@ function template_preprocess_links(&$variables) {
       // Use the array key as class name.
       $li_attributes['class'][] = drupal_html_class($key);
 
+      $keys = array('title', 'href', 'route_name', 'route_parameters');
       $link_element = array(
         '#type' => 'link',
         '#title' => $link['title'],
-        '#options' => array_diff_key($link, MapArray::copyValuesToKeys(array('title', 'href', 'route_name', 'route_parameters'))),
+        '#options' => array_diff_key($link, array_combine($keys, $keys)),
         '#href' => $link['href'],
         '#route_name' => $link['route_name'],
         '#route_parameters' => $link['route_parameters'],
diff --git a/core/includes/update.inc b/core/includes/update.inc
index 3431886e473c..5700d385ec82 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -434,7 +434,7 @@ function update_get_update_list() {
         continue;
       }
 
-      $updates = drupal_map_assoc($updates);
+      $updates = array_combine($updates, $updates);
       foreach (array_keys($updates) as $update) {
         if ($update == \Drupal::CORE_MINIMUM_SCHEMA_VERSION) {
           $ret[$module]['warning'] = '<em>' . $module . '</em> module cannot be updated. It contains an update numbered as ' . \Drupal::CORE_MINIMUM_SCHEMA_VERSION . ' which is reserved for the earliest installation of a module in Drupal ' .  \Drupal::CORE_COMPATIBILITY . ', before any updates. In order to update <em>' . $module . '</em> module, you will need to install a version of the module with valid updates.';
diff --git a/core/lib/Drupal/Component/Plugin/DefaultPluginBag.php b/core/lib/Drupal/Component/Plugin/DefaultPluginBag.php
index ba87dfb59202..48a860feae41 100644
--- a/core/lib/Drupal/Component/Plugin/DefaultPluginBag.php
+++ b/core/lib/Drupal/Component/Plugin/DefaultPluginBag.php
@@ -8,7 +8,6 @@
 namespace Drupal\Component\Plugin;
 
 use Drupal\Component\Plugin\Exception\PluginNotFoundException;
-use Drupal\Component\Utility\MapArray;
 
 /**
  * Provides a default plugin bag for a plugin type.
@@ -63,7 +62,8 @@ public function __construct(PluginManagerInterface $manager, array $configuratio
     $this->configurations = $configurations;
 
     if (!empty($configurations)) {
-      $this->instanceIDs = MapArray::copyValuesToKeys(array_keys($configurations));
+      $instance_ids = array_keys($configurations);
+      $this->instanceIDs = array_combine($instance_ids, $instance_ids);
       // Store the original order of the instance IDs for export.
       $this->originalOrder = $this->instanceIDs;
     }
diff --git a/core/lib/Drupal/Component/Utility/MapArray.php b/core/lib/Drupal/Component/Utility/MapArray.php
deleted file mode 100644
index ea91e63ff2d7..000000000000
--- a/core/lib/Drupal/Component/Utility/MapArray.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Component\Utility\MapArray.
- */
-
-namespace Drupal\Component\Utility;
-
-/**
- * Provides generic array mapping helper methods.
- */
-class MapArray {
-
-  /**
-   * Forms an associative array from a linear array.
-   *
-   * This function walks through the provided array and constructs an associative
-   * array out of it. The keys of the resulting array will be the values of the
-   * input array. The values will be the same as the keys unless a function is
-   * specified, in which case the output of the function is used for the values
-   * instead.
-   *
-   * @param array $array
-   *   A linear array.
-   * @param callable $callback
-   *   A name of a function to apply to all values before output.
-   *
-   * @return array
-   *   An associative array.
-   */
-  public static function copyValuesToKeys(array $array, $callable = NULL) {
-    // array_combine() fails with empty arrays:
-    // http://bugs.php.net/bug.php?id=34857.
-    if (!empty($array)) {
-      $array = array_combine($array, $array);
-    }
-    if (is_callable($callable)) {
-      $array = array_map($callable, $array);
-    }
-
-    return $array;
-  }
-
-}
diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php
index 13f0388c6a12..222145f99aa8 100644
--- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php
+++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php
@@ -410,7 +410,8 @@ protected function buildQuery($ids, $revision_id = FALSE) {
 
     if ($this->revisionTable) {
       // Add all fields from the {entity_revision} table.
-      $entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->entityType->getRevisionTable()));
+      $entity_revision_fields = drupal_schema_fields_sql($this->entityType->getRevisionTable());
+      $entity_revision_fields = array_combine($entity_revision_fields, $entity_revision_fields);
       // The ID field is provided by entity, so remove it.
       unset($entity_revision_fields[$this->idKey]);
 
diff --git a/core/lib/Drupal/Core/Utility/ProjectInfo.php b/core/lib/Drupal/Core/Utility/ProjectInfo.php
index 748470ccfb9f..0b5090ec2123 100644
--- a/core/lib/Drupal/Core/Utility/ProjectInfo.php
+++ b/core/lib/Drupal/Core/Utility/ProjectInfo.php
@@ -224,7 +224,7 @@ function filterProjectInfo($info, $additional_whitelist = array()) {
       'version',
     );
     $whitelist = array_merge($whitelist, $additional_whitelist);
-    return array_intersect_key($info, drupal_map_assoc($whitelist));
+    return array_intersect_key($info, array_combine($whitelist, $whitelist));
   }
 
 }
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
index 469b1944e1f2..2edb0f012a26 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
@@ -23,7 +23,8 @@ class FeedFormController extends ContentEntityFormController {
    */
   public function form(array $form, array &$form_state) {
     $feed = $this->entity;
-    $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+    $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
+    $period = array_map('format_interval', array_combine($intervals, $intervals));
     $period[AGGREGATOR_CLEAR_NEVER] = $this->t('Never');
 
     $form['title'] = array(
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php
index b370063022f0..e80c9b1bf43d 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php
@@ -80,8 +80,8 @@ public function getFormId() {
    * {@inheritdoc}
    */
   public function buildForm(array $form, array &$form_state) {
-    $period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200,
-      64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
+    $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
+    $period = array_map('format_interval', array_combine($intervals, $intervals));
 
     $form['upload'] = array(
       '#type' => 'file',
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php
index 767639e22932..45475275a3a0 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php
@@ -108,11 +108,12 @@ public function blockForm($form, &$form_state) {
       '#default_value' => $this->configuration['feed'],
       '#options' => $options,
     );
+    $range = range(2, 20);
     $form['block_count'] = array(
       '#type' => 'select',
       '#title' => t('Number of news items in block'),
       '#default_value' => $this->configuration['block_count'],
-      '#options' => drupal_map_assoc(range(2, 20)),
+      '#options' => array_combine($range, $range),
     );
     return $form;
   }
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
index 3b892367b755..4eefd7d8f91c 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php
@@ -72,8 +72,12 @@ public static function create(ContainerInterface $container, array $configuratio
   public function buildConfigurationForm(array $form, array &$form_state) {
     $processors = $this->configuration['processors'];
     $info = $this->getPluginDefinition();
-    $items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), array($this, 'formatItems'));
-    $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
+    $counts = array(3, 5, 10, 15, 20, 25);
+    $items = array_map(function ($count) {
+      return format_plural($count, '1 item', '@count items');
+    }, array_combine($counts, $counts));
+    $intervals = array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800);
+    $period = array_map('format_interval', array_combine($intervals, $intervals));
     $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
 
     $form['processors'][$info['id']] = array();
@@ -103,11 +107,16 @@ public function buildConfigurationForm(array $form, array &$form_state) {
       '#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
     );
 
+    $lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000);
+    $options = array_map(function($length) {
+      return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');
+    }, array_combine($lengths, $lengths));
+
     $form['processors'][$info['id']]['aggregator_teaser_length'] = array(
       '#type' => 'select',
       '#title' => t('Length of trimmed description'),
       '#default_value' => $this->configuration['items']['teaser_length'],
-      '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), array($this, 'formatCharacters')),
+      '#options' => $options,
       '#description' => t('The maximum number of characters used in the trimmed version of content.'),
     );
     return $form;
@@ -233,32 +242,4 @@ public function setConfiguration(array $configuration) {
     $config->save();
   }
 
-  /**
-   * Helper function for drupal_map_assoc.
-   *
-   * @param int $count
-   *   Items count.
-   *
-   * @return string
-   *   A string that is plural-formatted as "@count items".
-   */
-  protected function formatItems($count) {
-    return format_plural($count, '1 item', '@count items');
-  }
-
-  /**
-   * Creates display text for teaser length option values.
-   *
-   * Callback for drupal_map_assoc() within settingsForm().
-   *
-   * @param int $length
-   *   The desired length of teaser text, in bytes.
-   *
-   * @return string
-   *   A translated string explaining the teaser string length.
-   */
-  protected function formatCharacters($length) {
-    return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');
-  }
-
 }
diff --git a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php
index 026ad5c72491..5ff93f2657ba 100644
--- a/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php
+++ b/core/modules/block/tests/Drupal/block/Tests/CategoryAutocompleteTest.php
@@ -8,7 +8,6 @@
 namespace Drupal\block\Tests;
 
 use Drupal\block\Controller\CategoryAutocompleteController;
-use Drupal\Component\Utility\MapArray;
 use Drupal\Component\Utility\String;
 use Drupal\Tests\UnitTestCase;
 use Symfony\Component\HttpFoundation\Request;
@@ -63,7 +62,7 @@ public function setUp() {
   public function testAutocompleteSuggestions($string, $suggestions) {
     $suggestions = array_map(function ($suggestion) {
       return String::checkPlain($suggestion);
-    }, MapArray::copyValuesToKeys($suggestions));
+    }, array_combine($suggestions, $suggestions));
     $result = $this->autocompleteController->autocomplete(new Request(array('q' => $string)));
     $this->assertSame($suggestions, json_decode($result->getContent(), TRUE));
   }
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index e5054a46947c..a5fcb8ed0073 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -843,7 +843,7 @@ function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) {
   if ($form['#field']->getType() == 'comment') {
     // We only support posting one comment at the time so it doesn't make sense
     // to let the site builder choose anything else.
-    $form['field']['cardinality_container']['cardinality']['#options'] = drupal_map_assoc(array(1));
+    $form['field']['cardinality_container']['cardinality']['#options'] = array(1 => 1);
     $form['field']['cardinality_container']['#access'] = FALSE;
   }
 }
@@ -1531,7 +1531,8 @@ function template_preprocess_comment_wrapper(&$variables) {
  * Returns an array of "comments per page" values that users can select from.
  */
 function _comment_per_page() {
-  return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
+  $comments_per_page = array(10, 30, 50, 70, 90, 150, 200, 250, 300);
+  return array_combine($comments_per_page, $comments_per_page);
 }
 
 /**
diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php
index cee2fb9530e3..c3b505e52ac8 100644
--- a/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php
+++ b/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\config\Form;
 
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Config\StorageInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\EntityTypeInterface;
@@ -182,7 +181,8 @@ protected function findConfiguration($config_type) {
       }, $this->definitions);
 
       // Find all config, and then filter our anything matching a config prefix.
-      $names = MapArray::copyValuesToKeys($this->configStorage->listAll());
+      $names = $this->configStorage->listAll();
+      $names = array_combine($names, $names);
       foreach ($names as $config_name) {
         foreach ($config_prefixes as $config_prefix) {
           if (strpos($config_name, $config_prefix) === 0) {
diff --git a/core/modules/datetime/lib/Drupal/datetime/DateHelper.php b/core/modules/datetime/lib/Drupal/datetime/DateHelper.php
index 55404460eb47..93827221c36e 100644
--- a/core/modules/datetime/lib/Drupal/datetime/DateHelper.php
+++ b/core/modules/datetime/lib/Drupal/datetime/DateHelper.php
@@ -292,7 +292,8 @@ public static function years($min = 0, $max = 0, $required = FALSE) {
       $max = intval(date('Y', REQUEST_TIME) + 3);
     }
     $none = array('' => '');
-    $range = drupal_map_assoc(range($min, $max));
+    $range = range($min, $max);
+    $range = array_combine($range, $range);
     return !$required ? $none + $range : $range;
   }
 
@@ -323,7 +324,8 @@ public static function days($required = FALSE, $month = NULL, $year = NULL) {
       $max = 31;
     }
     $none = array('' => '');
-    $range = drupal_map_assoc(range(1, $max));
+    $range = range(1, $max);
+    $range = array_combine($range, $range);
     return !$required ? $none + $range : $range;
   }
 
diff --git a/core/modules/dblog/dblog.module b/core/modules/dblog/dblog.module
index cd8e2c082c9e..33f0120a85e1 100644
--- a/core/modules/dblog/dblog.module
+++ b/core/modules/dblog/dblog.module
@@ -11,7 +11,6 @@
  * @see watchdog()
  */
 
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Database\Database;
 
 /**
@@ -123,7 +122,7 @@ function _dblog_get_message_types() {
     $types[] = $object->type;
   }
 
-  return MapArray::copyValuesToKeys($types);
+  return array_combine($types, $types);
 }
 
 /**
@@ -155,11 +154,12 @@ function dblog_watchdog(array $log_entry) {
  * Implements hook_form_FORM_ID_alter() for system_logging_settings().
  */
 function dblog_form_system_logging_settings_alter(&$form, $form_state) {
+  $row_limits = array(100, 1000, 10000, 100000, 1000000);
   $form['dblog_row_limit'] = array(
     '#type' => 'select',
     '#title' => t('Database log messages to keep'),
     '#default_value' => \Drupal::config('dblog.settings')->get('row_limit'),
-    '#options' => array(0 => t('All')) + drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)),
+    '#options' => array(0 => t('All')) + array_combine($row_limits, $row_limits),
     '#description' => t('The maximum number of messages to keep in the database log. Requires a <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status')))
   );
 
diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php
index 2825383b7161..a2f602fc4683 100644
--- a/core/modules/edit/lib/Drupal/edit/EditController.php
+++ b/core/modules/edit/lib/Drupal/edit/EditController.php
@@ -12,7 +12,6 @@
 use Symfony\Component\HttpFoundation\JsonResponse;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Ajax\AjaxResponse;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\field\FieldInfo;
@@ -221,7 +220,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
       // Re-render the updated field for other view modes (i.e. for other
       // instances of the same logical field on the user's page).
       $other_view_mode_ids = $request->request->get('other_view_modes') ?: array();
-      $other_view_modes = MapArray::copyValuesToKeys($other_view_mode_ids, $render_field_in_view_mode);
+      $other_view_modes = array_map($render_field_in_view_mode, array_combine($other_view_mode_ids, $other_view_mode_ids));
 
       $response->addCommand(new FieldFormSavedCommand($output, $other_view_modes));
     }
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php
index a9865cfe6821..5105a202048b 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php
@@ -104,7 +104,8 @@ public static function settingsForm(FieldDefinitionInterface $field_definition)
     if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) {
       // @todo Use Entity::getFieldDefinitions() when all entity types are
       // converted to the new Field API.
-      $fields = drupal_map_assoc(drupal_schema_fields_sql($entity_type->getBaseTable()));
+      $fields = drupal_schema_fields_sql($entity_type->getBaseTable());
+      $fields = array_combine($fields, $fields);
       foreach (field_info_instances($target_type) as $bundle_instances) {
         foreach ($bundle_instances as $instance_name => $instance) {
           foreach ($instance->getField()->getColumns() as $column_name => $column_info) {
diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/row/EntityReference.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/row/EntityReference.php
index 0059b32e8062..b975b0acd021 100644
--- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/row/EntityReference.php
+++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/views/row/EntityReference.php
@@ -52,7 +52,8 @@ public function preRender($row) {
     // Force all fields to be inline by default.
     if (empty($this->options['inline'])) {
       $fields = $this->view->getHandlers('field', $this->displayHandler->display['id']);
-      $this->options['inline'] = drupal_map_assoc(array_keys($fields));
+      $names = array_keys($fields);
+      $this->options['inline'] = array_combine($names, $names);
     }
 
     return parent::preRender($row);
diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
index b5a9fa93d0c2..54657f29755a 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\field\Plugin\views\field;
 
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Entity\EntityStorageControllerInterface;
@@ -414,7 +413,7 @@ public function buildOptionsForm(&$form, &$form_state) {
       $form['click_sort_column'] = array(
         '#type' => 'select',
         '#title' => t('Column used for click sorting'),
-        '#options' => drupal_map_assoc($column_names),
+        '#options' => array_combine($column_names, $column_names),
         '#default_value' => $this->options['click_sort_column'],
         '#description' => t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
       );
@@ -500,7 +499,8 @@ function multiple_options_form(&$form, &$form_state) {
     }
     else {
       $type = 'select';
-      $options = drupal_map_assoc(range(1, $field->getCardinality()));
+      $range = range(1, $field->getCardinality());
+      $options = array_combine($range, $range);
       $size = 1;
     }
     $form['multi_type'] = array(
@@ -599,9 +599,10 @@ public function buildGroupByForm(&$form, &$form_state) {
     // With "field API" fields, the column target of the grouping function
     // and any additional grouping columns must be specified.
 
+    $field_columns = array_keys($this->field_info->getColumns());
     $group_columns = array(
       'entity_id' => t('Entity ID'),
-    ) + MapArray::copyValuesToKeys(array_keys($this->field_info->getColumns()), 'ucfirst');
+    ) + array_map('ucfirst', array_combine($field_columns, $field_columns));
 
     $form['group_column'] = array(
       '#type' => 'select',
@@ -611,8 +612,11 @@ public function buildGroupByForm(&$form, &$form_state) {
       '#options' => $group_columns,
     );
 
-    $options = MapArray::copyValuesToKeys(array('bundle', 'language', 'entity_type'), 'ucfirst');
-
+    $options = array(
+      'bundle' => 'Bundle',
+      'language' => 'Language',
+      'entity_type' => 'Entity_type',
+    );
     // Add on defined fields, noting that they're prefixed with the field name.
     $form['group_columns'] = array(
       '#type' => 'checkboxes',
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
index 5323e4ef474d..5de03d987db7 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php
@@ -258,6 +258,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent
     $display_options = $entity_display->getComponent($field_name);
     $label = $field_definition->getLabel();
 
+    $regions = array_keys($this->getRegions());
     $field_row = array(
       '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
       '#row_type' => 'field',
@@ -282,7 +283,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent
           '#type' => 'select',
           '#title' => $this->t('Label display for @title', array('@title' => $label)),
           '#title_display' => 'invisible',
-          '#options' => drupal_map_assoc(array_keys($this->getRegions())),
+          '#options' => array_combine($regions, $regions),
           '#empty_value' => '',
           '#attributes' => array('class' => array('field-parent')),
           '#parents' => array('fields', $field_name, 'parent'),
@@ -432,6 +433,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent
   protected function buildExtraFieldRow($field_id, $extra_field, EntityDisplayInterface $entity_display) {
     $display_options = $entity_display->getComponent($field_id);
 
+    $regions = array_keys($this->getRegions());
     $extra_field_row = array(
       '#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
       '#row_type' => 'extra_field',
@@ -453,7 +455,7 @@ protected function buildExtraFieldRow($field_id, $extra_field, EntityDisplayInte
           '#type' => 'select',
           '#title' => $this->t('Parents for @title', array('@title' => $extra_field['label'])),
           '#title_display' => 'invisible',
-          '#options' => drupal_map_assoc(array_keys($this->getRegions())),
+          '#options' => array_combine($regions, $regions),
           '#empty_value' => '',
           '#attributes' => array('class' => array('field-parent')),
           '#parents' => array('fields', $field_id, 'parent'),
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
index 5e28958385b2..f4a955bd50ab 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php
@@ -9,6 +9,7 @@
 
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\Form\FormBase;
+use Drupal\Core\Render\Element;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -157,7 +158,8 @@ public function tablePreRender($elements) {
     $trees = array_fill_keys(array_keys($regions), $tree);
 
     $parents = array();
-    $list = drupal_map_assoc(element_children($elements));
+    $children = Element::children($elements);
+    $list = array_combine($children, $children);
 
     // Iterate on rows until we can build a known tree path for all of them.
     while ($list) {
diff --git a/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php b/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php
index e3c31fe57072..055516f95084 100644
--- a/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php
+++ b/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php
@@ -27,20 +27,20 @@ public function getFormId() {
   public function buildForm(array $form, array &$form_state) {
     $config = $this->configFactory->get('forum.settings');
 
-    $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
+    $options = array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500);
     $form['forum_hot_topic'] = array(
       '#type' => 'select',
       '#title' => $this->t('Hot topic threshold'),
       '#default_value' => $config->get('topics.hot_threshold'),
-      '#options' => $number,
+      '#options' => array_combine($options, $options),
       '#description' => $this->t('The number of replies a topic must have to be considered "hot".'),
     );
-    $number = drupal_map_assoc(array(10, 25, 50, 75, 100));
+    $options = array(10, 25, 50, 75, 100);
     $form['forum_per_page'] = array(
       '#type' => 'select',
       '#title' => $this->t('Topics per page'),
       '#default_value' => $config->get('topics.page_limit'),
-      '#options' => $number,
+      '#options' => array_combine($options, $options),
       '#description' => $this->t('Default number of forum topics displayed per page.'),
     );
     $forder = array(
diff --git a/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php b/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php
index c2ad994208ed..f1c2f4e60b7c 100644
--- a/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php
+++ b/core/modules/forum/lib/Drupal/forum/Plugin/Block/ForumBlockBase.php
@@ -39,11 +39,12 @@ public function access(AccountInterface $account) {
    * Overrides \Drupal\block\BlockBase::blockForm().
    */
   public function blockForm($form, &$form_state) {
+    $range = range(2, 20);
     $form['block_count'] = array(
       '#type' => 'select',
       '#title' => t('Number of topics'),
       '#default_value' => $this->configuration['block_count'],
-      '#options' => drupal_map_assoc(range(2, 20)),
+      '#options' => array_combine($range, $range),
     );
     return $form;
   }
diff --git a/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php b/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php
index 3e0da615c2d4..a7fb8f603b45 100644
--- a/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php
+++ b/core/modules/language/lib/Drupal/language/ConfigurableLanguageManager.php
@@ -8,7 +8,6 @@
 namespace Drupal\language;
 
 use Drupal\Component\PhpStorage\PhpStorageFactory;
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Language\Language;
@@ -323,7 +322,7 @@ public function getFallbackCandidates($langcode = NULL, array $context = array()
       // at the end.
       $candidates = array_keys($this->getLanguages());
       $candidates[] = Language::LANGCODE_NOT_SPECIFIED;
-      $candidates = MapArray::copyValuesToKeys($candidates);
+      $candidates = array_combine($candidates, $candidates);
 
       // The first candidate should always be the desired language if specified.
       if (!empty($langcode)) {
diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc
index 5ebe4279264b..fab2a21f279f 100644
--- a/core/modules/locale/locale.translation.inc
+++ b/core/modules/locale/locale.translation.inc
@@ -73,7 +73,7 @@ function locale_translation_get_projects($project_names = array()) {
 
   // Return the requested project names or all projects.
   if ($project_names) {
-    return array_intersect_key($projects, drupal_map_assoc($project_names));
+    return array_intersect_key($projects, array_combine($project_names, $project_names));
   }
   return $projects;
 }
diff --git a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Plugin/migrate/source/d6/Variable.php b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Plugin/migrate/source/d6/Variable.php
index 1f4f816c1ede..e9a24b5b0c2c 100644
--- a/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Plugin/migrate/source/d6/Variable.php
+++ b/core/modules/migrate_drupal/lib/Drupal/migrate_drupal/Plugin/migrate/source/d6/Variable.php
@@ -46,7 +46,7 @@ public function count() {
    * {@inheritdoc}
    */
   public function fields() {
-    return drupal_map_assoc($this->variables);
+    return array_combine($this->variables, $this->variables);
   }
 
   /**
diff --git a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php
index e0a466c11281..dda06828fbc9 100644
--- a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php
@@ -8,7 +8,6 @@
 namespace Drupal\node;
 
 use Drupal\Core\Entity\EntityFormController;
-use Drupal\Component\Utility\MapArray;
 use Drupal\Component\Utility\String;
 
 /**
@@ -32,7 +31,8 @@ public function form(array $form, array &$form_state) {
 
     $node_settings = $type->getModuleSettings('node');
     // Prepare node options to be used for 'checkboxes' form element.
-    $node_settings['options'] = MapArray::copyValuesToKeys(array_keys(array_filter($node_settings['options'])));
+    $keys = array_keys(array_filter($node_settings['options']));
+    $node_settings['options'] = array_combine($keys, $keys);
     $form['name'] = array(
       '#title' => t('Name'),
       '#type' => 'textfield',
diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php
index 6106729ab51d..2c69b9f572c2 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php
@@ -559,7 +559,8 @@ public function buildConfigurationForm(array $form, array &$form_state) {
     );
 
     // Note: reversed to reflect that higher number = higher ranking.
-    $options = drupal_map_assoc(range(0, 10));
+    $range = range(0, 10);
+    $options = array_combine($range, $range);
     foreach ($this->getRankings() as $var => $values) {
       $form['content_ranking']['factors']["rankings_$var"] = array(
         '#title' => $values['title'],
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php b/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php
index fdb3415aa65e..41f49a8fc640 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php
@@ -113,7 +113,7 @@ public function validateArgument($argument) {
           return FALSE;
         }
 
-        $test = drupal_map_assoc($nids->value);
+        $test = array_combine($nids->value, $nids->value);
         $titles = array();
 
         $nodes = node_load_multiple($nids->value);
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index fb29b392825d..b66ba18c5576 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -1264,11 +1264,12 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) {
  * @see node_form_system_site_information_settings_form_submit()
  */
 function node_form_system_site_information_settings_form_alter(&$form, &$form_state, $form_id) {
+  $options = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30);
   $form['front_page']['default_nodes_main'] = array(
     '#type' => 'select',
     '#title' => t('Number of posts on front page'),
     '#default_value' => \Drupal::config('node.settings')->get('items_per_page'),
-    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
+    '#options' => array_combine($options, $options),
     '#access' => (\Drupal::config('system.site')->get('page.front') == 'node'),
     '#description' => t('The maximum number of posts displayed on overview pages such as the front page.'),
   );
diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldFormatter/NumberDecimalFormatter.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldFormatter/NumberDecimalFormatter.php
index 1fe9c72d5294..3b6ac2b5431e 100644
--- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldFormatter/NumberDecimalFormatter.php
+++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldFormatter/NumberDecimalFormatter.php
@@ -44,10 +44,11 @@ public function settingsForm(array $form, array &$form_state) {
       '#default_value' => $this->getSetting('decimal_separator'),
       '#weight' => 5,
     );
+    $range = range(0, 10);
     $elements['scale'] = array(
       '#type' => 'select',
       '#title' => t('Scale', array(), array('decimal places')),
-      '#options' => drupal_map_assoc(range(0, 10)),
+      '#options' => array_combine($range, $range),
       '#default_value' => $this->getSetting('scale'),
       '#description' => t('The number of digits to the right of the decimal.'),
       '#weight' => 6,
diff --git a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php
index bba55918a0b8..305d8b4303e4 100644
--- a/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php
+++ b/core/modules/number/lib/Drupal/number/Plugin/Field/FieldType/DecimalItem.php
@@ -9,7 +9,6 @@
 
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\TypedData\DataDefinition;
-use Drupal\Component\Utility\MapArray;
 
 /**
  * Plugin implementation of the 'number_decimal' field type.
@@ -67,18 +66,20 @@ public function settingsForm(array $form, array &$form_state, $has_data) {
     $element = array();
     $settings = $this->getSettings();
 
+    $range = range(10, 32);
     $element['precision'] = array(
       '#type' => 'select',
       '#title' => t('Precision'),
-      '#options' => MapArray::copyValuesToKeys(range(10, 32)),
+      '#options' => array_combine($range, $range),
       '#default_value' => $settings['precision'],
       '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
       '#disabled' => $has_data,
     );
+    $range = range(0, 10);
     $element['scale'] = array(
       '#type' => 'select',
       '#title' => t('Scale', array(), array('decimal places')),
-      '#options' => MapArray::copyValuesToKeys(range(0, 10)),
+      '#options' => array_combine($range, $range),
       '#default_value' => $settings['scale'],
       '#description' => t('The number of digits to the right of the decimal.'),
       '#disabled' => $has_data,
diff --git a/core/modules/options/tests/options_test.module b/core/modules/options/tests/options_test.module
index 08b533ec6389..1416fa0e6ca9 100644
--- a/core/modules/options/tests/options_test.module
+++ b/core/modules/options/tests/options_test.module
@@ -30,11 +30,12 @@ function options_test_allowed_values_callback(FieldDefinitionInterface $field_de
  */
 function options_test_dynamic_values_callback(FieldDefinitionInterface $field_definition, EntityInterface $entity, &$cacheable) {
   $cacheable = FALSE;
-  // We need the values of the entity as keys.
-  return drupal_map_assoc(array(
+  $values = array(
     $entity->label(),
     $entity->url(),
     $entity->uuid(),
     $entity->bundle(),
-  ));
+  );
+  // We need the values of the entity as keys.
+  return array_combine($values, $values);
 }
diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php b/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php
index 2e7ac89f82ac..1f7e3a539732 100644
--- a/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php
@@ -95,7 +95,7 @@ public function buildOptionsForm(&$form, &$form_state) {
       '#type' => 'checkboxes',
       '#title' => t('Accepted request formats'),
       '#description' => t('Request formats that will be allowed in responses. If none are selected all formats will be allowed.'),
-      '#options' => drupal_map_assoc($this->formats),
+      '#options' => array_combine($this->formats, $this->formats),
       '#default_value' => $this->options['formats'],
     );
   }
diff --git a/core/modules/search/lib/Drupal/search/SearchPageListController.php b/core/modules/search/lib/Drupal/search/SearchPageListController.php
index fbbe6bb09bc3..a4975076770e 100644
--- a/core/modules/search/lib/Drupal/search/SearchPageListController.php
+++ b/core/modules/search/lib/Drupal/search/SearchPageListController.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\search;
 
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Config\ConfigFactoryInterface;
 use Drupal\Core\Config\Entity\DraggableListController;
 use Drupal\Core\Entity\EntityInterface;
@@ -167,7 +166,8 @@ public function buildForm(array $form, array &$form_state) {
       '#submit' => array(array($this, 'searchAdminReindexSubmit')),
     );
 
-    $items = MapArray::copyValuesToKeys(array(10, 20, 50, 100, 200, 500));
+    $items = array(10, 20, 50, 100, 200, 500);
+    $items = array_combine($items, $items);
 
     // Indexing throttle:
     $form['indexing_throttle'] = array(
diff --git a/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php b/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php
index 64f71c4de874..1a1976184894 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Plugin/Block/StatisticsPopularBlock.php
@@ -79,7 +79,8 @@ public function access(AccountInterface $account) {
    */
   public function blockForm($form, &$form_state) {
     // Popular content block settings.
-    $numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
+    $numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40);
+    $numbers = array('0' => t('Disabled')) + array_combine($numbers, $numbers);
     $form['statistics_block_top_day_num'] = array(
      '#type' => 'select',
      '#title' => t("Number of day's top views to display"),
diff --git a/core/modules/system/lib/Drupal/system/Form/CronForm.php b/core/modules/system/lib/Drupal/system/Form/CronForm.php
index f32a4638ad0b..7c81ded1f0f5 100644
--- a/core/modules/system/lib/Drupal/system/Form/CronForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/CronForm.php
@@ -96,12 +96,13 @@ public function buildForm(array $form, array &$form_state) {
       '#type' => 'details',
       '#open' => TRUE,
     );
+    $options = array(3600, 10800, 21600, 43200, 86400, 604800);
     $form['cron']['cron_safe_threshold'] = array(
       '#type' => 'select',
       '#title' => t('Run cron every'),
       '#description' => t('More information about setting up scheduled tasks can be found by <a href="@url">reading the cron tutorial on drupal.org</a>.', array('@url' => url('http://drupal.org/cron'))),
       '#default_value' => $config->get('threshold.autorun'),
-      '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
+      '#options' => array(0 => t('Never')) + array_map('format_interval', array_combine($options, $options)),
     );
 
     return parent::buildForm($form, $form_state);
diff --git a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php
index a123d8b54fbe..6e7d9d666d19 100644
--- a/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/PerformanceForm.php
@@ -80,7 +80,8 @@ public function buildForm(array $form, array &$form_state) {
       '#open' => TRUE,
     );
 
-    $period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
+    $period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
+    $period = array_map('format_interval', array_combine($period, $period));
     $period[0] = '<' . t('none') . '>';
     $form['caching']['page_cache_maximum_age'] = array(
       '#type' => 'select',
diff --git a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php
index dd791ced318e..b18cdfe366cf 100644
--- a/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/RssFeedsForm.php
@@ -32,11 +32,12 @@ public function buildForm(array $form, array &$form_state) {
       '#default_value' => $rss_config->get('channel.description'),
       '#description' => t('Description of your site, included in each feed.')
     );
+    $options = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30);
     $form['feed_default_items'] = array(
       '#type' => 'select',
       '#title' => t('Number of items in each feed'),
       '#default_value' => $rss_config->get('items.limit'),
-      '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
+      '#options' => array_combine($options, $options),
       '#description' => t('Default number of items to include in each feed.')
     );
     $form['feed_item_length'] = array(
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 e819056abd75..286599186c39 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\system\Tests\Entity;
 
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Language\Language;
 use Drupal\entity_test\Entity\EntityTestMulRev;
 
@@ -495,7 +494,7 @@ function testLanguageFallback() {
     $controller = $this->entityManager->getViewBuilder($entity_type);
     $build = $controller->view($entity);
     $this->assertEqual($build['label']['#markup'], $values[$current_langcode]['name'], 'By default the entity is rendered in the current language.');
-    $langcodes = MapArray::copyValuesToKeys($this->langcodes);
+    $langcodes = array_combine($this->langcodes, $this->langcodes);
     // We have no translation for the $langcode2 langauge, hence the expected
     // result is the topmost existing translation, that is $langcode.
     $langcodes[$langcode2] = $langcode;
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 c1d42bf6ca64..9620ef50b572 100644
--- a/core/modules/system/tests/modules/entity_test/entity_test.module
+++ b/core/modules/system/tests/modules/entity_test/entity_test.module
@@ -54,7 +54,7 @@ function entity_test_entity_types($filter = NULL) {
     $types[] = 'entity_test_rev';
   }
   $types[] = 'entity_test_mulrev';
-  return drupal_map_assoc($types);
+  return array_combine($types, $types);
 }
 
 /**
diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module
index e80170829e65..de5c2f037b81 100644
--- a/core/modules/system/tests/modules/form_test/form_test.module
+++ b/core/modules/system/tests/modules/form_test/form_test.module
@@ -140,7 +140,7 @@ function form_test_validate_form_validate(&$form, &$form_state) {
  * @deprecated Use \Drupal\form_test\validateRequiredForm()
  */
 function form_test_validate_required_form($form, &$form_state) {
-  $options = drupal_map_assoc(array('foo', 'bar'));
+  $options = array('foo' => 'foo', 'bar' => 'bar');
   $validate = array('form_test_validate_required_form_element_validate');
 
   $form['textfield'] = array(
@@ -882,7 +882,7 @@ function form_test_select($form, &$form_state) {
 
   $base = array(
     '#type' => 'select',
-    '#options' => drupal_map_assoc(array('one', 'two', 'three')),
+    '#options' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
   );
 
   $form['select'] = $base + array(
diff --git a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/TestPluginBag.php b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/TestPluginBag.php
index c389308cdfa2..9c8c7c093af7 100644
--- a/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/TestPluginBag.php
+++ b/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/TestPluginBag.php
@@ -9,7 +9,6 @@
 
 use Drupal\Component\Plugin\PluginBag;
 use Drupal\Component\Plugin\PluginManagerInterface;
-use Drupal\Component\Utility\MapArray;
 
 /**
  * Defines a plugin bag which uses fruit plugins.
@@ -32,7 +31,8 @@ class TestPluginBag extends PluginBag {
   public function __construct(PluginManagerInterface $manager) {
     $this->manager = $manager;
 
-    $this->instanceIDs = MapArray::copyValuesToKeys(array_keys($this->manager->getDefinitions()));
+    $instance_ids = array_keys($this->manager->getDefinitions());
+    $this->instanceIDs = array_combine($instance_ids, $instance_ids);
   }
 
   /**
diff --git a/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php b/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php
index dc7475f3fdc5..71f0c3f3c98e 100644
--- a/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php
+++ b/core/modules/user/lib/Drupal/user/Plugin/entity_reference/selection/UserSelection.php
@@ -67,7 +67,7 @@ public static function settingsForm(FieldDefinitionInterface $field_definition)
         '#type' => 'checkboxes',
         '#title' => t('Restrict to the selected roles'),
         '#required' => TRUE,
-        '#options' => array_diff_key(user_role_names(TRUE), drupal_map_assoc(array(DRUPAL_AUTHENTICATED_RID))),
+        '#options' => array_diff_key(user_role_names(TRUE), array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID)),
         '#default_value' => $selection_handler_settings['filter']['role'],
       );
     }
diff --git a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php
index 4188c474e2e1..94b3ff4a48d2 100644
--- a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php
+++ b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\views\EventSubscriber;
 
-use Drupal\Component\Utility\MapArray;
 use Drupal\Core\Page\HtmlPage;
 use Drupal\Core\Entity\EntityManagerInterface;
 use Drupal\Core\KeyValueStore\StateInterface;
@@ -104,7 +103,7 @@ protected function getViewsDisplayIDsWithRoute() {
         $id = $view->storage->id();
         $this->viewsDisplayPairs[] = $id . '.' . $display_id;
       }
-      $this->viewsDisplayPairs = MapArray::copyValuesToKeys($this->viewsDisplayPairs);
+      $this->viewsDisplayPairs = array_combine($this->viewsDisplayPairs, $this->viewsDisplayPairs);
     }
     return $this->viewsDisplayPairs;
   }
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/String.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/String.php
index a2dd29b5a7df..af3176bca3e2 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/String.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/String.php
@@ -284,7 +284,7 @@ function title() {
    * Override for specific title lookups.
    */
   public function titleQuery() {
-    return drupal_map_assoc($this->value, '\Drupal\Component\Utility\String::checkPlain');
+    return array_map('\Drupal\Component\Utility\String::checkPlain', array_combine($this->value, $this->value));
   }
 
   public function summaryName($data) {
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php
index 3db6bfabb197..054f545e99ef 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/Time.php
@@ -40,7 +40,7 @@ protected function defineOptions() {
   public function buildOptionsForm(&$form, &$form_state) {
     parent::buildOptionsForm($form, $form_state);
     $options = array(60, 300, 1800, 3600, 21600, 518400);
-    $options = drupal_map_assoc($options, 'format_interval');
+    $options = array_map('format_interval', array_combine($options, $options));
     $options = array(-1 => t('Never cache')) + $options + array('custom' => t('Custom'));
 
     $form['results_lifespan'] = array(
diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
index 1521e2fe81e6..7416f1045f26 100644
--- a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php
@@ -860,7 +860,7 @@ protected function defaultDisplayFiltersUser(array $form, array &$form_state) {
       $handler = $table_data[$bundle_key]['filter']['id'];
       $handler_definition = Views::pluginManager('filter')->getDefinition($handler);
       if ($handler == 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) {
-        $value = drupal_map_assoc(array($form_state['values']['show']['type']));
+        $value = array($form_state['values']['show']['type'] => $form_state['values']['show']['type']);
       }
       // Otherwise, use just a single value.
       else {
diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
index f8b2e4cfeae9..81e692fecf3d 100644
--- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php
@@ -192,7 +192,8 @@ public function testArchiveView() {
     $view = views_get_view('archive');
     $view->setDisplay('page_1');
     $this->executeView($view);
-    $column_map = drupal_map_assoc(array('nid', 'created_year_month', 'num_records'));
+    $columns = array('nid', 'created_year_month', 'num_records');
+    $column_map = array_combine($columns, $columns);
     // Create time of additional nodes created in the setup method.
     $created_year_month = date('Ym', REQUEST_TIME - 3600);
     $expected_result = array(
diff --git a/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php b/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php
index db0022194248..0d7ee5d8d493 100644
--- a/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityBundleTest.php
@@ -95,7 +95,7 @@ public function testFilterEntity() {
       // Test each bundle type.
       $view->initDisplay();
       $filters = $view->display_handler->getOption('filters');
-      $filters['type']['value'] = drupal_map_assoc(array($key));
+      $filters['type']['value'] = array($key => $key);
       $view->display_handler->setOption('filters', $filters);
       $this->executeView($view);
 
@@ -107,7 +107,7 @@ public function testFilterEntity() {
     // Test an invalid bundle type to make sure we have no results.
     $view->initDisplay();
     $filters = $view->display_handler->getOption('filters');
-    $filters['type']['value'] = drupal_map_assoc(array('type_3'));
+    $filters['type']['value'] = array('type_3' => 'type_3');
     $view->display_handler->setOption('filters', $filters);
     $this->executeView($view);
 
diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
index 3d0675866a42..fadc4217bf2d 100644
--- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
+++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php
@@ -309,7 +309,7 @@ public function testPropertyMethods() {
     $this->assertIdentical(spl_object_hash($view->getResponse()), spl_object_hash($new_response), 'New response object correctly set.');
 
     // Test the generateHandlerId() method.
-    $test_ids = drupal_map_assoc(array('test', 'test_1'));
+    $test_ids = array('test' => 'test', 'test_1' => 'test_1');
     $this->assertEqual($view->generateHandlerId('new', $test_ids), 'new');
     $this->assertEqual($view->generateHandlerId('test', $test_ids), 'test_2');
 
diff --git a/core/modules/views/lib/Drupal/views/Views.php b/core/modules/views/lib/Drupal/views/Views.php
index ba45e1768fd3..40c5cd1773b0 100644
--- a/core/modules/views/lib/Drupal/views/Views.php
+++ b/core/modules/views/lib/Drupal/views/Views.php
@@ -7,7 +7,6 @@
 
 namespace Drupal\views;
 
-use Drupal\Component\Utility\MapArray;
 use Drupal\Component\Utility\String;
 
 /**
@@ -150,7 +149,7 @@ public static function getPluginDefinitions() {
   public static function getEnabledDisplayExtenders() {
     $enabled = array_filter((array) \Drupal::config('views.settings')->get('display_extenders'));
 
-    return MapArray::copyValuesToKeys($enabled);
+    return array_combine($enabled, $enabled);
   }
 
   /**
diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index 8a55f4bdbbc7..8cb4cd214f50 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -398,10 +398,11 @@ function template_preprocess_views_view_summary(&$variables) {
     $url_options['query'] = $view->exposed_raw_input;
   }
 
-  $active_urls = drupal_map_assoc(array(
+  $active_urls = array(
     url(current_path(), array('alias' => TRUE)), // force system path
     url(current_path()), // could be an alias
-  ));
+  );
+  $active_urls = array_combine($active_urls, $active_urls);
 
   // Collect all arguments foreach row, to be able to alter them for example
   // by the validator. This is not done per single argument value, because this
@@ -456,12 +457,13 @@ function template_preprocess_views_view_summary_unformatted(&$variables) {
   }
 
   $count = 0;
-  $active_urls = drupal_map_assoc(array(
+  $active_urls = array(
     // Force system path.
     url(current_path(), array('alias' => TRUE)),
     // Could be an alias.
     url(current_path()),
-  ));
+  );
+  $active_urls = array_combine($active_urls, $active_urls);
 
   // Collect all arguments for each row, to be able to alter them for example
   // by the validator. This is not done per single argument value, because
diff --git a/core/tests/Drupal/Tests/Component/Utility/MapArrayTest.php b/core/tests/Drupal/Tests/Component/Utility/MapArrayTest.php
deleted file mode 100644
index 4b833fa41d7e..000000000000
--- a/core/tests/Drupal/Tests/Component/Utility/MapArrayTest.php
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \Drupal\Tests\Component\Utility\MapArrayTest.
- */
-
-namespace Drupal\Tests\Component\Utility;
-
-use Drupal\Tests\UnitTestCase;
-use Drupal\Component\Utility\MapArray;
-
-/**
- * Tests the MapArray system.
- *
- * @see \Drupal\Component\Utility\MapArray
- */
-class MapArrayTest extends UnitTestCase {
-
-  public static function getInfo() {
-    return array(
-      'name' => 'MapArray test',
-      'description' => 'Test that the MapArray functions work properly.',
-      'group' => 'Bootstrap',
-    );
-  }
-
-  /**
-   * Tests MapArray::copyValuesToKey() input against expected output.
-   *
-   * @dataProvider providerCopyValuesToKey
-   *
-   * @param array $input
-   *   The input array for the MapArray::copyValuesToKey() method.
-   * @param array $expected
-   *   The expected output from calling the method.
-   * @param callable $callable
-   *   The optional callable.
-   *
-   * @see \Drupal\Component\Utility\MapArray::copyValuesToKey()
-   * @see \Drupal\Tests\Component\Utility\MapArrayTest::providerCopyValuesToKey()
-   */
-  public function testCopyValuesToKey(array $input, array $expected, $callable = NULL) {
-    $output = MapArray::copyValuesToKeys($input, $callable);
-    $this->assertEquals($expected, $output);
-  }
-
-  /**
-   * Data provider for MapArray::copyValuesToKey().
-   *
-   * @return array
-   *   An array of tests, matching the parameter inputs for testCopyValuesToKey.
-   *
-   * @see \Drupal\Component\Utility\MapArray::copyValuesToKey()
-   * @see \Drupal\Tests\Component\Utility\MapArrayTest::testCopyValuesToKey()
-   */
-  public function providerCopyValuesToKey() {
-    // Test an empty array.
-    $tests[] = array(
-      array(),
-      array()
-    );
-
-    // Tests the creation of an associative array.
-    $tests[] = array(
-      array('foobar'),
-      array('foobar' => 'foobar')
-    );
-
-    // Tests overwriting indexes with their value.
-    $tests[] = array(
-      array('foo' => 'bar'),
-      array('bar' => 'bar')
-    );
-
-    // Tests using the callback function.
-    $tests[] = array(
-      array(1, 2, 3, 4, 5),
-      array(
-        1 => 2,
-        2 => 4,
-        3 => 6,
-        4 => 8,
-        5 => 10,
-      ),
-      'Drupal\Tests\Component\Utility\MapArrayTest::providerCopyValuesToKeyCallback',
-    );
-
-    return $tests;
-  }
-
-  /**
-   * Callback for a test in providerCopyValuesToKey(), which doubles the value.
-   *
-   * @param int $n
-   *   The value passed in from array_map().
-   *
-   * @return int
-   *   The doubled integer value.
-   */
-  public static function providerCopyValuesToKeyCallback($n) {
-     return $n * 2;
-  }
-
-}
-- 
GitLab