[CLEANUP] Move array specific functions to ArrayUtility 71/36371/8
authorGöran Bodenschatz <coding@46halbe.de>
Thu, 29 Jan 2015 16:53:36 +0000 (17:53 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 31 Jan 2015 14:42:20 +0000 (15:42 +0100)
1. Move functions + tests to ArrayUtility class
2. Change function calls throughout Core
3. Deprecate functions in GeneralUtility

Resolves: #62807
Releases: master
Change-Id: Ib5c00b74d2326a377a76a1f24d1b541c33a2d956
Reviewed-on: http://review.typo3.org/36371
Reviewed-by: Mateusz Wojtuła <matw88@gmail.com>
Tested-by: Mateusz Wojtuła <matw88@gmail.com>
Tested-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Zbigniew Jacko <z.jacko@macopedia.pl>
Tested-by: Zbigniew Jacko <z.jacko@macopedia.pl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
22 files changed:
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/backend/Classes/Form/Element/SelectElement.php
typo3/sysext/backend/Classes/Form/FlexFormsHelper.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/User/ExtDirect/BackendUserSettingsDataProvider.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Http/AjaxRequestHandler.php
typo3/sysext/core/Classes/Utility/ArrayUtility.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/extbase/Classes/Mvc/Web/Routing/UriBuilder.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/ContentObject/FlowPlayerContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/Menu/JavaScriptMenuContentObject.php
typo3/sysext/frontend/Classes/ContentObject/QuicktimeObjectContentObject.php
typo3/sysext/frontend/Classes/ContentObject/ShockwaveFlashObjectContentObject.php
typo3/sysext/lowlevel/Classes/View/ConfigurationView.php
typo3/sysext/version/Classes/Controller/VersionModuleController.php
typo3/sysext/version/Classes/Hook/DataHandlerHook.php

index 1ce90a5..f82d0cf 100644 (file)
@@ -1667,7 +1667,7 @@ class InlineElement {
                        $selItems = $this->fObj->addSelectOptionsToItemArray($this->fObj->initItemArray($PA['fieldConf']), $PA['fieldConf'], $this->fObj->setTSconfig($table, $row), $field);
 
                        // Possibly filter some items:
-                       $selItems = GeneralUtility::keepItemsInArray(
+                       $selItems = ArrayUtility::keepItemsInArray(
                                $selItems,
                                $PA['fieldTSConfig']['keepItems'],
                                function ($value) {
index 457c56d..37f58a7 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\Form\Element;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
@@ -149,7 +150,7 @@ class SelectElement extends AbstractFormElement {
                $itemArray = GeneralUtility::trimExplode(',', $PA['itemFormElValue'], TRUE);
 
                // Possibly filter some items:
-               $itemArray = GeneralUtility::keepItemsInArray(
+               $itemArray = ArrayUtility::keepItemsInArray(
                        $itemArray,
                        $PA['fieldTSConfig']['keepItems'],
                        function ($value) {
@@ -294,7 +295,7 @@ class SelectElement extends AbstractFormElement {
                );
 
                // Possibly filter some items:
-               $selectItems = GeneralUtility::keepItemsInArray(
+               $selectItems = ArrayUtility::keepItemsInArray(
                        $selectItems,
                        $PA['fieldTSConfig']['keepItems'],
                        function ($value) {
index 15f11d5..6dc240a 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\Form;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -179,7 +180,7 @@ class FlexFormsHelper extends \TYPO3\CMS\Backend\Form\FormEngine {
                        // Manipulate field
                        if (!empty($field['TCEforms']) && is_array($field['TCEforms'])) {
                                $sheet[$fieldName]['TCEforms'] = $field['TCEforms'];
-                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($sheet[$fieldName]['TCEforms'], $fieldConf);
+                               ArrayUtility::mergeRecursiveWithOverrule($sheet[$fieldName]['TCEforms'], $fieldConf);
                        }
                        // Manipulate only select fields, other field types will stop here
                        if (empty($field['TCEforms']['config']['type']) || $field['TCEforms']['config']['type'] != 'select' || $field['TCEforms']['config']['renderMode'] === 'tree') {
@@ -189,7 +190,7 @@ class FlexFormsHelper extends \TYPO3\CMS\Backend\Form\FormEngine {
                        $selItems = $this->addSelectOptionsToItemArray($this->initItemArray($field['TCEforms']), $field['TCEforms'], $this->setTSconfig($table, $tableRow), $tableField);
 
                        // Possibly filter some items
-                       $selItems = GeneralUtility::keepItemsInArray(
+                       $selItems = ArrayUtility::keepItemsInArray(
                                $selItems,
                                $keepItems,
                                function ($value) {
index 3122f70..8ae0776 100644 (file)
@@ -2478,7 +2478,7 @@ class FormEngine {
                        $imageExtensionList = GeneralUtility::trimExplode(',', strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), TRUE);
                        $imagesOnly = TRUE;
                        foreach ($allowedExtensionList as $allowedExtension) {
-                               if (!GeneralUtility::inArray($imageExtensionList, $allowedExtension)) {
+                               if (!ArrayUtility::inArray($imageExtensionList, $allowedExtension)) {
                                        $imagesOnly = FALSE;
                                        break;
                                }
index cc101e6..e139009 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Backend\User\ExtDirect;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -121,7 +122,7 @@ class BackendUserSettingsDataProvider {
                $list = $this->get($key);
                if (GeneralUtility::inList($list, $value)) {
                        $list = GeneralUtility::trimExplode(',', $list, TRUE);
-                       $list = GeneralUtility::removeArrayEntryByValue($list, $value);
+                       $list = ArrayUtility::removeArrayEntryByValue($list, $value);
                        $this->set($key, implode(',', $list));
                }
        }
@@ -172,4 +173,4 @@ class BackendUserSettingsDataProvider {
                return $subkeys[count($subkeys) - 1];
        }
 
-}
\ No newline at end of file
+}
index 8203391..afa8338 100644 (file)
@@ -1415,7 +1415,7 @@ class BackendUtility {
                        foreach ($groups as $uid => $row) {
                                $groupN = $uid;
                                $set = 0;
-                               if (GeneralUtility::inArray($groupArray, $uid)) {
+                               if (ArrayUtility::inArray($groupArray, $uid)) {
                                        $groupN = $row['title'];
                                        $set = 1;
                                }
index aa0c373..75da6b9 100644 (file)
@@ -1953,7 +1953,7 @@ class DataHandler {
                                                // Traverse the input values and for all input values which match an EXISTING value, remove the existing from $theFileValues array (this will result in an array of all the existing files which should be deleted!)
                                                foreach ($valueArray as $key => $theFile) {
                                                        if ($theFile && !strstr(GeneralUtility::fixWindowsFilePath($theFile), '/')) {
-                                                               $theFileValues = GeneralUtility::removeArrayEntryByValue($theFileValues, $theFile);
+                                                               $theFileValues = ArrayUtility::removeArrayEntryByValue($theFileValues, $theFile);
                                                        }
                                                }
                                                // This array contains the filenames in the uploadfolder that should be deleted:
@@ -7393,7 +7393,7 @@ class DataHandler {
         * @return array
         */
        protected function unsetElementsToBeDeleted(array $elements) {
-               $elements = GeneralUtility::arrayDiffAssocRecursive($elements, $this->getCommandMapElements('delete'));
+               $elements = ArrayUtility::arrayDiffAssocRecursive($elements, $this->getCommandMapElements('delete'));
                foreach ($elements as $key => $value) {
                        if (empty($value)) {
                                unset($elements[$key]);
index e408cef..031c1e0 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Http;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
+
 /**
  * Class to hold all the information about an AJAX call and send
  * the right headers for the request type
@@ -155,7 +157,7 @@ class AjaxRequestHandler {
         * @return void
         */
        public function setContentFormat($format) {
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::inArray(array('plain', 'xml', 'json', 'jsonhead', 'jsonbody', 'javascript'), $format)) {
+               if (ArrayUtility::inArray(array('plain', 'xml', 'json', 'jsonhead', 'jsonbody', 'javascript'), $format)) {
                        $this->contentFormat = $format;
                }
        }
index 430ed56..57bbc6f 100644 (file)
@@ -531,4 +531,153 @@ class ArrayUtility {
                reset($original);
        }
 
+       /**
+        * Check if an string item exists in an array.
+        * Please note that the order of function parameters is reverse compared to the PHP function in_array()!!!
+        *
+        * Comparison to PHP in_array():
+        * -> $array = array(0, 1, 2, 3);
+        * -> variant_a := \TYPO3\CMS\Core\Utility\ArrayUtility::inArray($array, $needle)
+        * -> variant_b := in_array($needle, $array)
+        * -> variant_c := in_array($needle, $array, TRUE)
+        * +---------+-----------+-----------+-----------+
+        * | $needle | variant_a | variant_b | variant_c |
+        * +---------+-----------+-----------+-----------+
+        * | '1a'    | FALSE     | TRUE      | FALSE     |
+        * | ''      | FALSE     | TRUE      | FALSE     |
+        * | '0'     | TRUE      | TRUE      | FALSE     |
+        * | 0       | TRUE      | TRUE      | TRUE      |
+        * +---------+-----------+-----------+-----------+
+        *
+        * @param array $in_array One-dimensional array of items
+        * @param string $item Item to check for
+        * @return bool TRUE if $item is in the one-dimensional array $in_array
+        */
+       static public function inArray(array $in_array, $item) {
+               foreach ($in_array as $val) {
+                       if (!is_array($val) && (string)$val === (string)$item) {
+                               return TRUE;
+                       }
+               }
+               return FALSE;
+       }
+
+       /**
+        * Removes the value $cmpValue from the $array if found there. Returns the modified array
+        *
+        * @param array $array Array containing the values
+        * @param string $cmpValue Value to search for and if found remove array entry where found.
+        * @return array Output array with entries removed if search string is found
+        */
+       static public function removeArrayEntryByValue(array $array, $cmpValue) {
+               foreach ($array as $k => $v) {
+                       if (is_array($v)) {
+                               $array[$k] = self::removeArrayEntryByValue($v, $cmpValue);
+                       } elseif ((string)$v === (string)$cmpValue) {
+                               unset($array[$k]);
+                       }
+               }
+               return $array;
+       }
+
+       /**
+        * Filters an array to reduce its elements to match the condition.
+        * The values in $keepItems can be optionally evaluated by a custom callback function.
+        *
+        * Example (arguments used to call this function):
+        * $array = array(
+        * array('aa' => array('first', 'second'),
+        * array('bb' => array('third', 'fourth'),
+        * array('cc' => array('fifth', 'sixth'),
+        * );
+        * $keepItems = array('third');
+        * $getValueFunc = create_function('$value', 'return $value[0];');
+        *
+        * Returns:
+        * array(
+        * array('bb' => array('third', 'fourth'),
+        * )
+        *
+        * @param array $array The initial array to be filtered/reduced
+        * @param mixed $keepItems The items which are allowed/kept in the array - accepts array or csv string
+        * @param string $getValueFunc (optional) Callback function used to get the value to keep
+        * @return array The filtered/reduced array with the kept items
+        */
+       static public function keepItemsInArray(array $array, $keepItems, $getValueFunc = NULL) {
+               if ($array) {
+                       // Convert strings to arrays:
+                       if (is_string($keepItems)) {
+                               $keepItems = GeneralUtility::trimExplode(',', $keepItems);
+                       }
+                       // Check if valueFunc can be executed:
+                       if (!is_callable($getValueFunc)) {
+                               $getValueFunc = NULL;
+                       }
+                       // Do the filtering:
+                       if (is_array($keepItems) && count($keepItems)) {
+                               foreach ($array as $key => $value) {
+                                       // Get the value to compare by using the callback function:
+                                       $keepValue = isset($getValueFunc) ? call_user_func($getValueFunc, $value) : $value;
+                                       if (!in_array($keepValue, $keepItems)) {
+                                               unset($array[$key]);
+                                       }
+                               }
+                       }
+               }
+               return $array;
+       }
+
+       /**
+        * Rename Array keys with a given mapping table
+        *
+        * @param array $array Array by reference which should be remapped
+        * @param array $mappingTable Array with remap information, array/$oldKey => $newKey)
+        */
+       static public function remapArrayKeys(array &$array, array $mappingTable) {
+               foreach ($mappingTable as $old => $new) {
+                       if ($new && isset($array[$old])) {
+                               $array[$new] = $array[$old];
+                               unset($array[$old]);
+                       }
+               }
+       }
+
+       /**
+        * Filters keys off from first array that also exist in second array. Comparison is done by keys.
+        * This method is a recursive version of php array_diff_assoc()
+        *
+        * @param array $array1 Source array
+        * @param array $array2 Reduce source array by this array
+        * @return array Source array reduced by keys also present in second array
+        */
+       static public function arrayDiffAssocRecursive(array $array1, array $array2) {
+               $differenceArray = array();
+               foreach ($array1 as $key => $value) {
+                       if (!array_key_exists($key, $array2)) {
+                               $differenceArray[$key] = $value;
+                       } elseif (is_array($value)) {
+                               if (is_array($array2[$key])) {
+                                       $differenceArray[$key] = self::arrayDiffAssocRecursive($value, $array2[$key]);
+                               }
+                       }
+               }
+               return $differenceArray;
+       }
+
+       /**
+        * Sorts an array by key recursive - uses natural sort order (aAbB-zZ)
+        *
+        * @param array $array array to be sorted recursively, passed by reference
+        * @return bool always TRUE
+        */
+       static public function naturalKeySortRecursive(array &$array) {
+               uksort($array, 'strnatcasecmp');
+               foreach ($array as $key => &$value) {
+                       if (is_array($value)) {
+                               self::naturalKeySortRecursive($value);
+                       }
+               }
+
+               return TRUE;
+       }
 }
index cbdf974..17d5a5e 100755 (executable)
@@ -1416,7 +1416,7 @@ class GeneralUtility {
         *
         * Comparison to PHP in_array():
         * -> $array = array(0, 1, 2, 3);
-        * -> variant_a := \TYPO3\CMS\Core\Utility\GeneralUtility::inArray($array, $needle)
+        * -> variant_a := \TYPO3\CMS\Core\Utility\ArrayUtility::inArray($array, $needle)
         * -> variant_b := in_array($needle, $array)
         * -> variant_c := in_array($needle, $array, TRUE)
         * +---------+-----------+-----------+-----------+
@@ -1431,14 +1431,11 @@ class GeneralUtility {
         * @param array $in_array One-dimensional array of items
         * @param string $item Item to check for
         * @return bool TRUE if $item is in the one-dimensional array $in_array
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8  - use ArrayUtility::inArray() instead
         */
        static public function inArray(array $in_array, $item) {
-               foreach ($in_array as $val) {
-                       if (!is_array($val) && (string)$val === (string)$item) {
-                               return TRUE;
-                       }
-               }
-               return FALSE;
+               static::logDeprecatedFunction();
+               return ArrayUtility::inArray($in_array, $item);
        }
 
        /**
@@ -1542,16 +1539,11 @@ class GeneralUtility {
         * @param array $array Array containing the values
         * @param string $cmpValue Value to search for and if found remove array entry where found.
         * @return array Output array with entries removed if search string is found
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8  - use ArrayUtility::removeArrayEntryByValue() instead
         */
        static public function removeArrayEntryByValue(array $array, $cmpValue) {
-               foreach ($array as $k => $v) {
-                       if (is_array($v)) {
-                               $array[$k] = self::removeArrayEntryByValue($v, $cmpValue);
-                       } elseif ((string)$v === (string)$cmpValue) {
-                               unset($array[$k]);
-                       }
-               }
-               return $array;
+               static::logDeprecatedFunction();
+               return ArrayUtility::removeArrayEntryByValue($array, $cmpValue);
        }
 
        /**
@@ -1576,29 +1568,11 @@ class GeneralUtility {
         * @param mixed $keepItems The items which are allowed/kept in the array - accepts array or csv string
         * @param string $getValueFunc (optional) Callback function used to get the value to keep
         * @return array The filtered/reduced array with the kept items
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8  - use ArrayUtility::keepItemsInArray() instead
         */
        static public function keepItemsInArray(array $array, $keepItems, $getValueFunc = NULL) {
-               if ($array) {
-                       // Convert strings to arrays:
-                       if (is_string($keepItems)) {
-                               $keepItems = self::trimExplode(',', $keepItems);
-                       }
-                       // Check if valueFunc can be executed:
-                       if (!is_callable($getValueFunc)) {
-                               $getValueFunc = NULL;
-                       }
-                       // Do the filtering:
-                       if (is_array($keepItems) && count($keepItems)) {
-                               foreach ($array as $key => $value) {
-                                       // Get the value to compare by using the callback function:
-                                       $keepValue = isset($getValueFunc) ? call_user_func($getValueFunc, $value) : $value;
-                                       if (!in_array($keepValue, $keepItems)) {
-                                               unset($array[$key]);
-                                       }
-                               }
-                       }
-               }
-               return $array;
+               static::logDeprecatedFunction();
+               return ArrayUtility::keepItemsInArray($array, $keepItems, $getValueFunc);
        }
 
        /**
@@ -1736,16 +1710,11 @@ class GeneralUtility {
         *
         * @param array $array Array by reference which should be remapped
         * @param array $mappingTable Array with remap information, array/$oldKey => $newKey)
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8  - use ArrayUtility::remapArrayKeys() instead
         */
        static public function remapArrayKeys(&$array, $mappingTable) {
-               if (is_array($mappingTable)) {
-                       foreach ($mappingTable as $old => $new) {
-                               if ($new && isset($array[$old])) {
-                                       $array[$new] = $array[$old];
-                                       unset($array[$old]);
-                               }
-                       }
-               }
+               static::logDeprecatedFunction();
+               ArrayUtility::remapArrayKeys($array, $mappingTable);
        }
 
        /**
@@ -1768,19 +1737,11 @@ class GeneralUtility {
         * @param array $array1 Source array
         * @param array $array2 Reduce source array by this array
         * @return array Source array reduced by keys also present in second array
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8  - use ArrayUtility::arrayDiffAssocRecursive() instead
         */
        static public function arrayDiffAssocRecursive(array $array1, array $array2) {
-               $differenceArray = array();
-               foreach ($array1 as $key => $value) {
-                       if (!array_key_exists($key, $array2)) {
-                               $differenceArray[$key] = $value;
-                       } elseif (is_array($value)) {
-                               if (is_array($array2[$key])) {
-                                       $differenceArray[$key] = self::arrayDiffAssocRecursive($value, $array2[$key]);
-                               }
-                       }
-               }
-               return $differenceArray;
+               static::logDeprecatedFunction();
+               return ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
        }
 
        /**
@@ -1825,16 +1786,11 @@ class GeneralUtility {
         *
         * @param array $array array to be sorted recursively, passed by reference
         * @return bool TRUE if param is an array
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8  - use ArrayUtility::naturalKeySortRecursive() instead
         */
        static public function naturalKeySortRecursive(&$array) {
-               if (!is_array($array)) {
-                       return FALSE;
-               }
-               uksort($array, 'strnatcasecmp');
-               foreach ($array as $key => $value) {
-                       self::naturalKeySortRecursive($array[$key]);
-               }
-               return TRUE;
+               static::logDeprecatedFunction();
+               return ArrayUtility::naturalKeySortRecursive($array);
        }
 
        /*************************
index 2ad82f5..b659f91 100644 (file)
@@ -1748,4 +1748,374 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $this->assertEquals($expected, $input1);
        }
 
+       //////////////////////////////////
+       // Tests concerning inArray
+       //////////////////////////////////
+       /**
+        * @test
+        * @dataProvider inArrayDataProvider
+        */
+       public function inArrayChecksStringExistenceWithinArray($array, $item, $expected) {
+               $this->assertEquals($expected, ArrayUtility::inArray($array, $item));
+       }
+
+       /**
+        * Data provider for inArrayChecksStringExistenceWithinArray
+        *
+        * @return array
+        */
+       public function inArrayDataProvider() {
+               return array(
+                       'Empty array' => array(array(), 'search', FALSE),
+                       'One item array no match' => array(array('one'), 'two', FALSE),
+                       'One item array match' => array(array('one'), 'one', TRUE),
+                       'Multiple items array no match' => array(array('one', 2, 'three', 4), 'four', FALSE),
+                       'Multiple items array match' => array(array('one', 2, 'three', 4), 'three', TRUE),
+                       'Integer search items can match string values' => array(array('0', '1', '2'), 1, TRUE),
+                       'Search item is not casted to integer for a match' => array(array(4), '4a', FALSE),
+                       'Empty item won\'t match - in contrast to the php-builtin ' => array(array(0, 1, 2), '', FALSE)
+               );
+       }
+
+       //////////////////////////////////
+       // Tests concerning removeArrayEntryByValue
+       //////////////////////////////////
+       /**
+        * @test
+        */
+       public function checkRemoveArrayEntryByValueRemovesEntriesFromOneDimensionalArray() {
+               $inputArray = array(
+                       '0' => 'test1',
+                       '1' => 'test2',
+                       '2' => 'test3',
+                       '3' => 'test2'
+               );
+               $compareValue = 'test2';
+               $expectedResult = array(
+                       '0' => 'test1',
+                       '2' => 'test3'
+               );
+               $actualResult = ArrayUtility::removeArrayEntryByValue($inputArray, $compareValue);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function checkRemoveArrayEntryByValueRemovesEntriesFromMultiDimensionalArray() {
+               $inputArray = array(
+                       '0' => 'foo',
+                       '1' => array(
+                               '10' => 'bar'
+                       ),
+                       '2' => 'bar'
+               );
+               $compareValue = 'bar';
+               $expectedResult = array(
+                       '0' => 'foo',
+                       '1' => array()
+               );
+               $actualResult = ArrayUtility::removeArrayEntryByValue($inputArray, $compareValue);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function checkRemoveArrayEntryByValueRemovesEntryWithEmptyString() {
+               $inputArray = array(
+                       '0' => 'foo',
+                       '1' => '',
+                       '2' => 'bar'
+               );
+               $compareValue = '';
+               $expectedResult = array(
+                       '0' => 'foo',
+                       '2' => 'bar'
+               );
+               $actualResult = ArrayUtility::removeArrayEntryByValue($inputArray, $compareValue);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       //////////////////////////////////
+       // Tests concerning keepItemsInArray
+       //////////////////////////////////
+       /**
+        * @test
+        * @dataProvider keepItemsInArrayWorksWithOneArgumentDataProvider
+        */
+       public function keepItemsInArrayWorksWithOneArgument($search, $array, $expected) {
+               $this->assertEquals($expected, ArrayUtility::keepItemsInArray($array, $search));
+       }
+
+       /**
+        * Data provider for keepItemsInArrayWorksWithOneArgument
+        *
+        * @return array
+        */
+       public function keepItemsInArrayWorksWithOneArgumentDataProvider() {
+               $array = array(
+                       'one' => 'one',
+                       'two' => 'two',
+                       'three' => 'three'
+               );
+               return array(
+                       'Empty argument will match "all" elements' => array(NULL, $array, $array),
+                       'No match' => array('four', $array, array()),
+                       'One match' => array('two', $array, array('two' => 'two')),
+                       'Multiple matches' => array('two,one', $array, array('one' => 'one', 'two' => 'two')),
+                       'Argument can be an array' => array(array('three'), $array, array('three' => 'three'))
+               );
+       }
+
+       /**
+        * Shows the exmaple from the doc comment where
+        * a function is used to reduce the sub arrays to one item which
+        * is then used for the matching.
+        *
+        * @test
+        */
+       public function keepItemsInArrayCanUseCallbackOnSearchArray() {
+               $array = array(
+                       'aa' => array('first', 'second'),
+                       'bb' => array('third', 'fourth'),
+                       'cc' => array('fifth', 'sixth')
+               );
+               $expected = array('bb' => array('third', 'fourth'));
+               $keepItems = 'third';
+               $getValueFunc = create_function('$value', 'return $value[0];');
+               $match = ArrayUtility::keepItemsInArray($array, $keepItems, $getValueFunc);
+               $this->assertEquals($expected, $match);
+       }
+
+       /**
+        * Similar to keepItemsInArrayCanUseCallbackOnSearchArray(),
+        * but uses a closure instead of create_function()
+        *
+        * @test
+        */
+       public function keepItemsInArrayCanUseClosure() {
+               $array = array(
+                       'aa' => array('first', 'second'),
+                       'bb' => array('third', 'fourth'),
+                       'cc' => array('fifth', 'sixth')
+               );
+               $expected = array('bb' => array('third', 'fourth'));
+               $keepItems = 'third';
+               $match = ArrayUtility::keepItemsInArray(
+                       $array,
+                       $keepItems,
+                       function ($value) {
+                               return $value[0];
+                       }
+               );
+               $this->assertEquals($expected, $match);
+       }
+
+       //////////////////////////////////
+       // Tests concerning remapArrayKeys
+       //////////////////////////////////
+       /**
+        * @test
+        */
+       public function remapArrayKeysExchangesKeysWithGivenMapping() {
+               $array = array(
+                       'one' => 'one',
+                       'two' => 'two',
+                       'three' => 'three'
+               );
+               $keyMapping = array(
+                       'one' => '1',
+                       'two' => '2'
+               );
+               $expected = array(
+                       '1' => 'one',
+                       '2' => 'two',
+                       'three' => 'three'
+               );
+               ArrayUtility::remapArrayKeys($array, $keyMapping);
+               $this->assertEquals($expected, $array);
+       }
+
+       //////////////////////////////////////
+       // Tests concerning arrayDiffAssocRecursive
+       //////////////////////////////////////
+       /**
+        * @test
+        */
+       public function arrayDiffAssocRecursiveHandlesOneDimensionalArrays() {
+               $array1 = array(
+                       'key1' => 'value1',
+                       'key2' => 'value2',
+                       'key3' => 'value3'
+               );
+               $array2 = array(
+                       'key1' => 'value1',
+                       'key3' => 'value3'
+               );
+               $expectedResult = array(
+                       'key2' => 'value2'
+               );
+               $actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function arrayDiffAssocRecursiveHandlesMultiDimensionalArrays() {
+               $array1 = array(
+                       'key1' => 'value1',
+                       'key2' => array(
+                               'key21' => 'value21',
+                               'key22' => 'value22',
+                               'key23' => array(
+                                       'key231' => 'value231',
+                                       'key232' => 'value232'
+                               )
+                       )
+               );
+               $array2 = array(
+                       'key1' => 'value1',
+                       'key2' => array(
+                               'key21' => 'value21',
+                               'key23' => array(
+                                       'key231' => 'value231'
+                               )
+                       )
+               );
+               $expectedResult = array(
+                       'key2' => array(
+                               'key22' => 'value22',
+                               'key23' => array(
+                                       'key232' => 'value232'
+                               )
+                       )
+               );
+               $actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       /**
+        * @test
+        */
+       public function arrayDiffAssocRecursiveHandlesMixedArrays() {
+               $array1 = array(
+                       'key1' => array(
+                               'key11' => 'value11',
+                               'key12' => 'value12'
+                       ),
+                       'key2' => 'value2',
+                       'key3' => 'value3'
+               );
+               $array2 = array(
+                       'key1' => 'value1',
+                       'key2' => array(
+                               'key21' => 'value21'
+                       )
+               );
+               $expectedResult = array(
+                       'key3' => 'value3'
+               );
+               $actualResult = ArrayUtility::arrayDiffAssocRecursive($array1, $array2);
+               $this->assertEquals($expectedResult, $actualResult);
+       }
+
+       //////////////////////////////////////
+       // Tests concerning naturalKeySortRecursive
+       //////////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function naturalKeySortRecursiveSortsOneDimensionalArrayByNaturalOrder() {
+               $testArray = array(
+                       'bb' => 'bb',
+                       'ab' => 'ab',
+                       '123' => '123',
+                       'aaa' => 'aaa',
+                       'abc' => 'abc',
+                       '23' => '23',
+                       'ba' => 'ba',
+                       'bad' => 'bad',
+                       '2' => '2',
+                       'zap' => 'zap',
+                       '210' => '210'
+               );
+               $expectedResult = array(
+                       '2',
+                       '23',
+                       '123',
+                       '210',
+                       'aaa',
+                       'ab',
+                       'abc',
+                       'ba',
+                       'bad',
+                       'bb',
+                       'zap'
+               );
+               ArrayUtility::naturalKeySortRecursive($testArray);
+               $this->assertEquals($expectedResult, array_values($testArray));
+       }
+
+       /**
+        * @test
+        */
+       public function naturalKeySortRecursiveSortsMultiDimensionalArrayByNaturalOrder() {
+               $testArray = array(
+                       '2' => '2',
+                       'bb' => 'bb',
+                       'ab' => 'ab',
+                       '23' => '23',
+                       'aaa' => array(
+                               'bb' => 'bb',
+                               'ab' => 'ab',
+                               '123' => '123',
+                               'aaa' => 'aaa',
+                               '2' => '2',
+                               'abc' => 'abc',
+                               'ba' => 'ba',
+                               '23' => '23',
+                               'bad' => array(
+                                       'bb' => 'bb',
+                                       'ab' => 'ab',
+                                       '123' => '123',
+                                       'aaa' => 'aaa',
+                                       'abc' => 'abc',
+                                       '23' => '23',
+                                       'ba' => 'ba',
+                                       'bad' => 'bad',
+                                       '2' => '2',
+                                       'zap' => 'zap',
+                                       '210' => '210'
+                               ),
+                               '210' => '210',
+                               'zap' => 'zap'
+                       ),
+                       'abc' => 'abc',
+                       'ba' => 'ba',
+                       '210' => '210',
+                       'bad' => 'bad',
+                       '123' => '123',
+                       'zap' => 'zap'
+               );
+               $expectedResult = array(
+                       '2',
+                       '23',
+                       '123',
+                       '210',
+                       'aaa',
+                       'ab',
+                       'abc',
+                       'ba',
+                       'bad',
+                       'bb',
+                       'zap'
+               );
+               ArrayUtility::naturalKeySortRecursive($testArray);
+               $this->assertEquals($expectedResult, array_values(array_keys($testArray['aaa']['bad'])));
+               $this->assertEquals($expectedResult, array_values(array_keys($testArray['aaa'])));
+               $this->assertEquals($expectedResult, array_values(array_keys($testArray)));
+       }
 }
index 6b55f52..ca2e25f 100644 (file)
@@ -978,35 +978,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        //////////////////////////////////
-       // Tests concerning inArray
-       //////////////////////////////////
-       /**
-        * @test
-        * @dataProvider inArrayDataProvider
-        */
-       public function inArrayChecksStringExistenceWithinArray($array, $item, $expected) {
-               $this->assertEquals($expected, Utility\GeneralUtility::inArray($array, $item));
-       }
-
-       /**
-        * Data provider for inArrayChecksStringExistenceWithinArray
-        *
-        * @return array
-        */
-       public function inArrayDataProvider() {
-               return array(
-                       'Empty array' => array(array(), 'search', FALSE),
-                       'One item array no match' => array(array('one'), 'two', FALSE),
-                       'One item array match' => array(array('one'), 'one', TRUE),
-                       'Multiple items array no match' => array(array('one', 2, 'three', 4), 'four', FALSE),
-                       'Multiple items array match' => array(array('one', 2, 'three', 4), 'three', TRUE),
-                       'Integer search items can match string values' => array(array('0', '1', '2'), 1, TRUE),
-                       'Search item is not casted to integer for a match' => array(array(4), '4a', FALSE),
-                       'Empty item won\'t match - in contrast to the php-builtin ' => array(array(0, 1, 2), '', FALSE)
-               );
-       }
-
-       //////////////////////////////////
        // Tests concerning intExplode
        //////////////////////////////////
        /**
@@ -1020,81 +991,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        //////////////////////////////////
-       // Tests concerning keepItemsInArray
-       //////////////////////////////////
-       /**
-        * @test
-        * @dataProvider keepItemsInArrayWorksWithOneArgumentDataProvider
-        */
-       public function keepItemsInArrayWorksWithOneArgument($search, $array, $expected) {
-               $this->assertEquals($expected, Utility\GeneralUtility::keepItemsInArray($array, $search));
-       }
-
-       /**
-        * Data provider for keepItemsInArrayWorksWithOneArgument
-        *
-        * @return array
-        */
-       public function keepItemsInArrayWorksWithOneArgumentDataProvider() {
-               $array = array(
-                       'one' => 'one',
-                       'two' => 'two',
-                       'three' => 'three'
-               );
-               return array(
-                       'Empty argument will match "all" elements' => array(NULL, $array, $array),
-                       'No match' => array('four', $array, array()),
-                       'One match' => array('two', $array, array('two' => 'two')),
-                       'Multiple matches' => array('two,one', $array, array('one' => 'one', 'two' => 'two')),
-                       'Argument can be an array' => array(array('three'), $array, array('three' => 'three'))
-               );
-       }
-
-       /**
-        * Shows the exmaple from the doc comment where
-        * a function is used to reduce the sub arrays to one item which
-        * is then used for the matching.
-        *
-        * @test
-        */
-       public function keepItemsInArrayCanUseCallbackOnSearchArray() {
-               $array = array(
-                       'aa' => array('first', 'second'),
-                       'bb' => array('third', 'fourth'),
-                       'cc' => array('fifth', 'sixth')
-               );
-               $expected = array('bb' => array('third', 'fourth'));
-               $keepItems = 'third';
-               $getValueFunc = create_function('$value', 'return $value[0];');
-               $match = Utility\GeneralUtility::keepItemsInArray($array, $keepItems, $getValueFunc);
-               $this->assertEquals($expected, $match);
-       }
-
-       /**
-        * Similar to keepItemsInArrayCanUseCallbackOnSearchArray(),
-        * but uses a closure instead of create_function()
-        *
-        * @test
-        */
-       public function keepItemsInArrayCanUseClosure() {
-               $array = array(
-                       'aa' => array('first', 'second'),
-                       'bb' => array('third', 'fourth'),
-                       'cc' => array('fifth', 'sixth')
-               );
-               $expected = array('bb' => array('third', 'fourth'));
-               $keepItems = 'third';
-               $match = Utility\GeneralUtility::keepItemsInArray(
-                       $array,
-                       $keepItems,
-                       function ($value) {
-                               return $value[0];
-                       }
-               );
-               $this->assertEquals($expected, $match);
-       }
-
-       //////////////////////////////////
        // Tests concerning implodeArrayForUrl / explodeUrl2Array
        //////////////////////////////////
        /**
@@ -1196,31 +1092,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        //////////////////////////////////
-       // Tests concerning remapArrayKeys
-       //////////////////////////////////
-       /**
-        * @test
-        */
-       public function remapArrayKeysExchangesKeysWithGivenMapping() {
-               $array = array(
-                       'one' => 'one',
-                       'two' => 'two',
-                       'three' => 'three'
-               );
-               $keyMapping = array(
-                       'one' => '1',
-                       'two' => '2'
-               );
-               $expected = array(
-                       '1' => 'one',
-                       '2' => 'two',
-                       'three' => 'three'
-               );
-               Utility\GeneralUtility::remapArrayKeys($array, $keyMapping);
-               $this->assertEquals($expected, $array);
-       }
-
-       //////////////////////////////////
        // Tests concerning array_merge
        //////////////////////////////////
        /**
@@ -1427,66 +1298,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        //////////////////////////////////
-       // Tests concerning removeArrayEntryByValue
-       //////////////////////////////////
-       /**
-        * @test
-        */
-       public function checkRemoveArrayEntryByValueRemovesEntriesFromOneDimensionalArray() {
-               $inputArray = array(
-                       '0' => 'test1',
-                       '1' => 'test2',
-                       '2' => 'test3',
-                       '3' => 'test2'
-               );
-               $compareValue = 'test2';
-               $expectedResult = array(
-                       '0' => 'test1',
-                       '2' => 'test3'
-               );
-               $actualResult = Utility\GeneralUtility::removeArrayEntryByValue($inputArray, $compareValue);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function checkRemoveArrayEntryByValueRemovesEntriesFromMultiDimensionalArray() {
-               $inputArray = array(
-                       '0' => 'foo',
-                       '1' => array(
-                               '10' => 'bar'
-                       ),
-                       '2' => 'bar'
-               );
-               $compareValue = 'bar';
-               $expectedResult = array(
-                       '0' => 'foo',
-                       '1' => array()
-               );
-               $actualResult = Utility\GeneralUtility::removeArrayEntryByValue($inputArray, $compareValue);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function checkRemoveArrayEntryByValueRemovesEntryWithEmptyString() {
-               $inputArray = array(
-                       '0' => 'foo',
-                       '1' => '',
-                       '2' => 'bar'
-               );
-               $compareValue = '';
-               $expectedResult = array(
-                       '0' => 'foo',
-                       '2' => 'bar'
-               );
-               $actualResult = Utility\GeneralUtility::removeArrayEntryByValue($inputArray, $compareValue);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       //////////////////////////////////
        // Tests concerning getBytesFromSizeMeasurement
        //////////////////////////////////
        /**
@@ -2195,90 +2006,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        //////////////////////////////////////
-       // Tests concerning arrayDiffAssocRecursive
-       //////////////////////////////////////
-       /**
-        * @test
-        */
-       public function arrayDiffAssocRecursiveHandlesOneDimensionalArrays() {
-               $array1 = array(
-                       'key1' => 'value1',
-                       'key2' => 'value2',
-                       'key3' => 'value3'
-               );
-               $array2 = array(
-                       'key1' => 'value1',
-                       'key3' => 'value3'
-               );
-               $expectedResult = array(
-                       'key2' => 'value2'
-               );
-               $actualResult = Utility\GeneralUtility::arrayDiffAssocRecursive($array1, $array2);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function arrayDiffAssocRecursiveHandlesMultiDimensionalArrays() {
-               $array1 = array(
-                       'key1' => 'value1',
-                       'key2' => array(
-                               'key21' => 'value21',
-                               'key22' => 'value22',
-                               'key23' => array(
-                                       'key231' => 'value231',
-                                       'key232' => 'value232'
-                               )
-                       )
-               );
-               $array2 = array(
-                       'key1' => 'value1',
-                       'key2' => array(
-                               'key21' => 'value21',
-                               'key23' => array(
-                                       'key231' => 'value231'
-                               )
-                       )
-               );
-               $expectedResult = array(
-                       'key2' => array(
-                               'key22' => 'value22',
-                               'key23' => array(
-                                       'key232' => 'value232'
-                               )
-                       )
-               );
-               $actualResult = Utility\GeneralUtility::arrayDiffAssocRecursive($array1, $array2);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       /**
-        * @test
-        */
-       public function arrayDiffAssocRecursiveHandlesMixedArrays() {
-               $array1 = array(
-                       'key1' => array(
-                               'key11' => 'value11',
-                               'key12' => 'value12'
-                       ),
-                       'key2' => 'value2',
-                       'key3' => 'value3'
-               );
-               $array2 = array(
-                       'key1' => 'value1',
-                       'key2' => array(
-                               'key21' => 'value21'
-                       )
-               );
-               $expectedResult = array(
-                       'key3' => 'value3'
-               );
-               $actualResult = Utility\GeneralUtility::arrayDiffAssocRecursive($array1, $array2);
-               $this->assertEquals($expectedResult, $actualResult);
-       }
-
-       //////////////////////////////////////
        // Tests concerning removeDotsFromTS
        //////////////////////////////////////
        /**
@@ -2357,117 +2084,6 @@ class GeneralUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        //////////////////////////////////////
-       // Tests concerning naturalKeySortRecursive
-       //////////////////////////////////////
-       /**
-        * @test
-        */
-       public function naturalKeySortRecursiveReturnsFalseIfInputIsNotAnArray() {
-               $testValues = array(
-                       1,
-                       'string',
-                       FALSE
-               );
-               foreach ($testValues as $testValue) {
-                       $this->assertFalse(Utility\GeneralUtility::naturalKeySortRecursive($testValue));
-               }
-       }
-
-       /**
-        * @test
-        */
-       public function naturalKeySortRecursiveSortsOneDimensionalArrayByNaturalOrder() {
-               $testArray = array(
-                       'bb' => 'bb',
-                       'ab' => 'ab',
-                       '123' => '123',
-                       'aaa' => 'aaa',
-                       'abc' => 'abc',
-                       '23' => '23',
-                       'ba' => 'ba',
-                       'bad' => 'bad',
-                       '2' => '2',
-                       'zap' => 'zap',
-                       '210' => '210'
-               );
-               $expectedResult = array(
-                       '2',
-                       '23',
-                       '123',
-                       '210',
-                       'aaa',
-                       'ab',
-                       'abc',
-                       'ba',
-                       'bad',
-                       'bb',
-                       'zap'
-               );
-               Utility\GeneralUtility::naturalKeySortRecursive($testArray);
-               $this->assertEquals($expectedResult, array_values($testArray));
-       }
-
-       /**
-        * @test
-        */
-       public function naturalKeySortRecursiveSortsMultiDimensionalArrayByNaturalOrder() {
-               $testArray = array(
-                       '2' => '2',
-                       'bb' => 'bb',
-                       'ab' => 'ab',
-                       '23' => '23',
-                       'aaa' => array(
-                               'bb' => 'bb',
-                               'ab' => 'ab',
-                               '123' => '123',
-                               'aaa' => 'aaa',
-                               '2' => '2',
-                               'abc' => 'abc',
-                               'ba' => 'ba',
-                               '23' => '23',
-                               'bad' => array(
-                                       'bb' => 'bb',
-                                       'ab' => 'ab',
-                                       '123' => '123',
-                                       'aaa' => 'aaa',
-                                       'abc' => 'abc',
-                                       '23' => '23',
-                                       'ba' => 'ba',
-                                       'bad' => 'bad',
-                                       '2' => '2',
-                                       'zap' => 'zap',
-                                       '210' => '210'
-                               ),
-                               '210' => '210',
-                               'zap' => 'zap'
-                       ),
-                       'abc' => 'abc',
-                       'ba' => 'ba',
-                       '210' => '210',
-                       'bad' => 'bad',
-                       '123' => '123',
-                       'zap' => 'zap'
-               );
-               $expectedResult = array(
-                       '2',
-                       '23',
-                       '123',
-                       '210',
-                       'aaa',
-                       'ab',
-                       'abc',
-                       'ba',
-                       'bad',
-                       'bb',
-                       'zap'
-               );
-               Utility\GeneralUtility::naturalKeySortRecursive($testArray);
-               $this->assertEquals($expectedResult, array_values(array_keys($testArray['aaa']['bad'])));
-               $this->assertEquals($expectedResult, array_values(array_keys($testArray['aaa'])));
-               $this->assertEquals($expectedResult, array_values(array_keys($testArray)));
-       }
-
-       //////////////////////////////////////
        // Tests concerning get_dirs
        //////////////////////////////////////
        /**
index 9f8aed0..1511b8f 100644 (file)
@@ -1,19 +1,21 @@
 <?php
 namespace TYPO3\CMS\Extbase\Mvc\Web\Routing;
 
-/*                                                                        *
- * This script is part of the TYPO3 project - inspiring people to share!  *
- *                                                                        *
- * TYPO3 is free software; you can redistribute it and/or modify it under *
- * the terms of the GNU General Public License version 2 as published by  *
- * the Free Software Foundation.                                          *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
- * Public License for more details.                                       *
- *                                                                        */
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 
 /**
  * An URI Builder
@@ -522,7 +524,7 @@ class UriBuilder {
                        $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName);
                        $prefixedControllerArguments = array($pluginNamespace => $controllerArguments);
                }
-               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->arguments, $prefixedControllerArguments);
+               ArrayUtility::mergeRecursiveWithOverrule($this->arguments, $prefixedControllerArguments);
                return $this->build();
        }
 
@@ -600,7 +602,7 @@ class UriBuilder {
                        }
                        foreach ($this->argumentsToBeExcludedFromQueryString as $argumentToBeExcluded) {
                                $argumentToBeExcluded = \TYPO3\CMS\Core\Utility\GeneralUtility::explodeUrl2Array($argumentToBeExcluded, TRUE);
-                               $arguments = \TYPO3\CMS\Core\Utility\GeneralUtility::arrayDiffAssocRecursive($arguments, $argumentToBeExcluded);
+                               $arguments = ArrayUtility::arrayDiffAssocRecursive($arguments, $argumentToBeExcluded);
                        }
                } else {
                        $arguments = array(
@@ -608,7 +610,7 @@ class UriBuilder {
                                'id' => \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id')
                        );
                }
-               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($arguments, $this->arguments);
+               ArrayUtility::mergeRecursiveWithOverrule($arguments, $this->arguments);
                $arguments = $this->convertDomainObjectsToIdentityArrays($arguments);
                $this->lastArguments = $arguments;
                $moduleName = $arguments['M'];
index 7447bc5..21c0006 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 use TYPO3\CMS\Frontend\ContentObject\Exception\ContentRenderingException;
@@ -5513,7 +5514,7 @@ class ContentObjectRenderer {
                                        case 'gp':
                                                // Merge GET and POST and get $key out of the merged array
                                                $getPostArray = GeneralUtility::_GET();
-                                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($getPostArray, GeneralUtility::_POST());
+                                               ArrayUtility::mergeRecursiveWithOverrule($getPostArray, GeneralUtility::_POST());
                                                $retVal = $this->getGlobal($key, $getPostArray);
                                                break;
                                        case 'tsfe':
@@ -6691,11 +6692,11 @@ class ContentObjectRenderer {
                                break;
                        case 'GET,POST':
                                $currentQueryArray = GeneralUtility::_GET();
-                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($currentQueryArray, GeneralUtility::_POST());
+                               ArrayUtility::mergeRecursiveWithOverrule($currentQueryArray, GeneralUtility::_POST());
                                break;
                        case 'POST,GET':
                                $currentQueryArray = GeneralUtility::_POST();
-                               \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($currentQueryArray, GeneralUtility::_GET());
+                               ArrayUtility::mergeRecursiveWithOverrule($currentQueryArray, GeneralUtility::_GET());
                                break;
                        default:
                                $currentQueryArray = GeneralUtility::explodeUrl2Array($this->getEnvironmentVariable('QUERY_STRING'), TRUE);
@@ -6705,14 +6706,14 @@ class ContentObjectRenderer {
                        $exclude = GeneralUtility::explodeUrl2Array($exclude, TRUE);
                        // never repeat id
                        $exclude['id'] = 0;
-                       $newQueryArray = GeneralUtility::arrayDiffAssocRecursive($currentQueryArray, $exclude);
+                       $newQueryArray = ArrayUtility::arrayDiffAssocRecursive($currentQueryArray, $exclude);
                } else {
                        $newQueryArray = $currentQueryArray;
                }
                if ($forceOverruleArguments) {
-                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments);
+                       ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments);
                } else {
-                       \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments, FALSE);
+                       ArrayUtility::mergeRecursiveWithOverrule($newQueryArray, $overruleQueryArguments, FALSE);
                }
                return GeneralUtility::implodeArrayForUrl('', $newQueryArray, '', FALSE, TRUE);
        }
index 10f5ac4..e8c1f54 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
+
 /**
  * Contains FlowPlayer class object.
  *
@@ -318,7 +320,7 @@ class FlowPlayerContentObject extends AbstractContentObject {
                $flowplayerVideoConfig = array();
                $flowplayerAudioConfig = array();
                if (is_array($conf['flashvars.'])) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']);
+                       ArrayUtility::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']);
                } else {
                        $conf['flashvars.'] = array();
                }
@@ -380,7 +382,7 @@ class FlowPlayerContentObject extends AbstractContentObject {
                $flowplayerAudioJsonConfig = str_replace(array('"true"', '"false"'), array('true', 'false'), json_encode($flowplayerAudioConfig));
                // Assemble param tags (required?)
                if (is_array($conf['params.'])) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
+                       ArrayUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
                }
                $videoFlashParams = '';
                if (is_array($conf['params.'])) {
@@ -397,7 +399,7 @@ class FlowPlayerContentObject extends AbstractContentObject {
                // Assemble audio/video tag attributes
                $attributes = '';
                if (is_array($conf['attributes.'])) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']);
+                       ArrayUtility::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']);
                }
                foreach ($this->html5TagAttributes as $attribute) {
                        if ($conf['attributes.'][$attribute] === 'true' || $conf['attributes.'][$attribute] === strToLower($attribute) || $conf['attributes.'][$attribute] === $attribute) {
index aedf5c1..240c12d 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  */
 
 use TYPO3\CMS\Core\TypoScript\TemplateService;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Frontend\Page\PageRepository;
@@ -1169,7 +1170,7 @@ class AbstractMenuContentObject {
                                // Not hidden in navigation
                                if (!$data['nav_hide'] || $this->conf['includeNotInMenu']) {
                                        // not in banned uid's
-                                       if (!GeneralUtility::inArray($banUidArray, $uid)) {
+                                       if (!ArrayUtility::inArray($banUidArray, $uid)) {
                                                // Checks if the default language version can be shown:
                                                // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
                                                $blockPage = $data['l18n_cfg'] & 1 && (!$GLOBALS['TSFE']->sys_language_uid || $GLOBALS['TSFE']->sys_language_uid && !$data['_PAGES_OVERLAY']);
index 13b7060..75baff1 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Frontend\ContentObject\Menu;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
+
 /**
  * JavaScript/Selectorbox based menus
  *
@@ -126,7 +128,7 @@ class JavaScriptMenuContentObject extends AbstractMenuContentObject {
                        // If the spacer-function is not enabled, spacers will not enter the $menuArr
                        if ($this->mconf['SPC'] || !$spacer) {
                                // Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
-                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->doktypeExcludeList, $data['doktype']) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !\TYPO3\CMS\Core\Utility\GeneralUtility::inArray($banUidArray, $uid)) {
+                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->doktypeExcludeList, $data['doktype']) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !ArrayUtility::inArray($banUidArray, $uid)) {
                                        if ($count < $levels) {
                                                $addLines = $this->generate_level($levels, $count + 1, $data['uid'], '', $MP_array_sub);
                                        } else {
index 646967a..d3dcec6 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
+
 /**
  * Contains QTOBJECT class object.
  *
@@ -56,7 +58,7 @@ class QuicktimeObjectContentObject extends AbstractContentObject {
                // Merge with default parameters
                $conf['params.'] = array_merge((array)$typeConf['default.']['params.'], (array)$conf['params.']);
                if (is_array($conf['params.'])) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
+                       ArrayUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
                        foreach ($conf['params.'] as $key => $value) {
                                $params .= $qtObject . '.addParam("' . $key . '", "' . $value . '");' . LF;
                        }
index 408a026..8ba8df1 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
+
 /**
  * Contains SWFOBJECT class object.
  *
@@ -85,15 +87,15 @@ class ShockwaveFlashObjectContentObject extends AbstractContentObject {
                        }
                }
                if (is_array($conf['flashvars.'])) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']);
+                       ArrayUtility::remapArrayKeys($conf['flashvars.'], $typeConf['mapping.']['flashvars.']);
                }
                $flashvars = 'var flashvars = ' . (count($conf['flashvars.']) ? json_encode($conf['flashvars.']) : '{}') . ';';
                if (is_array($conf['params.'])) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
+                       ArrayUtility::remapArrayKeys($conf['params.'], $typeConf['mapping.']['params.']);
                }
                $params = 'var params = ' . (count($conf['params.']) ? json_encode($conf['params.']) : '{}') . ';';
                if (is_array($conf['attributes.'])) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']);
+                       ArrayUtility::remapArrayKeys($conf['attributes.'], $typeConf['attributes.']['params.']);
                }
                $attributes = 'var attributes = ' . (count($conf['attributes.']) ? json_encode($conf['attributes.']) : '{}') . ';';
                $flashVersion = isset($conf['flashVersion.']) ? $this->cObj->stdWrap($conf['flashVersion'], $conf['flashVersion.']) : $conf['flashVersion'];
index b486937..ff10e63 100644 (file)
@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageQueue;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
 use TYPO3\CMS\Fluid\View\StandaloneView;
@@ -121,52 +122,52 @@ class ConfigurationView extends BaseScriptClass {
                switch ($this->MOD_SETTINGS['function']) {
                        case 0:
                                $theVar = $GLOBALS['TYPO3_CONF_VARS'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TYPO3_CONF_VARS';
                                break;
                        case 1:
                                $theVar = $GLOBALS['TCA'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TCA';
                                break;
                        case 2:
                                $theVar = $GLOBALS['TCA_DESCR'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TCA_DESCR';
                                break;
                        case 3:
                                $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
                                break;
                        case 4:
                                $theVar = $GLOBALS['T3_SERVICES'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$T3_SERVICES';
                                break;
                        case 5:
                                $theVar = $GLOBALS['TBE_MODULES'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TBE_MODULES';
                                break;
                        case 6:
                                $theVar = $GLOBALS['TBE_MODULES_EXT'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TBE_MODULES_EXT';
                                break;
                        case 7:
                                $theVar = $GLOBALS['TBE_STYLES'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TBE_STYLES';
                                break;
                        case 8:
                                $theVar = $GLOBALS['BE_USER']->uc;
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$BE_USER->uc';
                                break;
                        case 9:
                                $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
-                               GeneralUtility::naturalKeySortRecursive($theVar);
+                               ArrayUtility::naturalKeySortRecursive($theVar);
                                $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
                                break;
                        default:
index c69c306..9a92a60 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Version\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
@@ -406,7 +407,7 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
         * @return string Table with content if any
         */
        public function pageSubContent($pid, $c = 0) {
-               $tableNames = GeneralUtility::removeArrayEntryByValue(array_keys($GLOBALS['TCA']), 'pages');
+               $tableNames = ArrayUtility::removeArrayEntryByValue(array_keys($GLOBALS['TCA']), 'pages');
                $tableNames[] = 'pages';
                $content = '';
                foreach ($tableNames as $tN) {
index 9c9fd65..8623018 100644 (file)
@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Version\Hook;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Database\ReferenceIndex;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
+use TYPO3\CMS\Core\Utility\ArrayUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Versioning\VersionState;
 
@@ -238,7 +239,7 @@ class DataHandlerHook {
                                $tcemainObj->versionizeRecord($table, $id, 'DELETED!', TRUE);
                                // Determine newly created versions:
                                // (remove placeholders are copied and modified, thus they appear in the copyMappingArray)
-                               $versionizedElements = GeneralUtility::arrayDiffAssocRecursive($tcemainObj->copyMappingArray, $copyMappingArray);
+                               $versionizedElements = ArrayUtility::arrayDiffAssocRecursive($tcemainObj->copyMappingArray, $copyMappingArray);
                                // Delete localization overlays:
                                foreach ($versionizedElements as $versionizedTableName => $versionizedOriginalIds) {
                                        foreach ($versionizedOriginalIds as $versionizedOriginalId => $_) {