diff --git a/core/lib/Drupal/Component/Utility/DiffArray.php b/core/lib/Drupal/Component/Utility/DiffArray.php index 5159cc9..86b98d3 100644 --- a/core/lib/Drupal/Component/Utility/DiffArray.php +++ b/core/lib/Drupal/Component/Utility/DiffArray.php @@ -15,14 +15,11 @@ class DiffArray { /** * Computes the difference between arrays. * - * This function is the same as array_diff_assoc() but multidimensional arrays - * do not throw notices. Note that as the comparison is made by (string) - * $value1 === (string) $value2 every array element is considered equal. This - * is, again, the same as array_diff_assoc() the only reason Drupal provides - * this function is since PHP 5.4 this casting of arrays to strings throws a - * notice. If you want to use array_diff_assoc() as it was up to PHP 5.3 then - * use this function but consider the consequences -- it should be rare to use - * this function. + * This is just a wrapper around array_diff_assoc(). The only reason Drupal + * provides this function is in since PHP 5.4 casting of arrays to strings + * throws a notice. If you want to use array_diff_assoc() as it was up to PHP + * 5.3, then use this function but consider the consequences -- it should be + * rare to use this function. * * @param array $array1 * The array to compare from. @@ -34,15 +31,7 @@ class DiffArray { * in array2. */ public static function diffAssoc(array $array1, array $array2) { - $difference = array(); - - foreach ($array1 as $key => $value) { - if (!array_key_exists($key, $array2) || ((string) $array2[$key] !== (string) $value)) { - $difference[$key] = $value; - } - } - - return $difference; + return @array_diff_assoc($array1, $array2); } /**