diff --git a/core/lib/Drupal/Component/Utility/DiffArray.php b/core/lib/Drupal/Component/Utility/DiffArray.php index 86b98d3..de2846e 100644 --- a/core/lib/Drupal/Component/Utility/DiffArray.php +++ b/core/lib/Drupal/Component/Utility/DiffArray.php @@ -13,28 +13,6 @@ class DiffArray { /** - * Computes the difference between arrays. - * - * 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. - * @param array $array2 - * The array to compare to. - * - * @return array - * Returns an array containing all the values from array1 that are not present - * in array2. - */ - public static function diffAssoc(array $array1, array $array2) { - return @array_diff_assoc($array1, $array2); - } - - /** * Recursively computes the difference of arrays with additional index check. * * This is a version of array_diff_assoc() that supports multidimensional diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/DiffArrayUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/DiffArrayUnitTest.php index dffe30a..a5ae7d2 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/DiffArrayUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/DiffArrayUnitTest.php @@ -47,6 +47,8 @@ function setUp() { 'null' => NULL, 'int_diff' => 1, 'array_diff' => array('same' => 'same', 'array' => array('same' => 'same')), + 'array_compared_to_string' => array('value'), + 'string_compared_to_array' => 'value', 'new' => 'new', ); $this->array2 = array( @@ -56,22 +58,12 @@ function setUp() { 'null' => NULL, 'int_diff' => '1', 'array_diff' => array('same' => 'different', 'array' => array('same' => 'same')), + 'array_compared_to_string' => 'value', + 'string_compared_to_array' => array('value'), ); } /** - * Tests DiffArray::diffAssoc(). - */ - public function testDiffAssoc() { - $expected = array( - 'different' => 'no', - 'new' => 'new', - ); - - $this->assertIdentical(DiffArray::diffAssoc($this->array1, $this->array2), $expected); - } - - /** * Tests DiffArray::diffAssocRecursive(). */ public function testDiffAssocRecursive() { @@ -80,6 +72,8 @@ public function testDiffAssocRecursive() { 'int_diff' => 1, // The 'array' key should not be returned, as it's the same. 'array_diff' => array('same' => 'same'), + 'array_compared_to_string' => array('value'), + 'string_compared_to_array' => 'value', 'new' => 'new', );