From e7458cab43b81334f2628dca1419c8c7afd17560 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Sat, 25 Mar 2017 18:27:48 +0100 Subject: [PATCH] [TASK] EXT:form - Use PHP's native array_replace_recursive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves: #80443 Releases: master Change-Id: I3e9c2b3f984068f2ce4d1096cd14670700d77aa6 Reviewed-on: https://review.typo3.org/52155 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Frank Nägler <frank.naegler@typo3.org> Tested-by: Frank Nägler <frank.naegler@typo3.org> Reviewed-by: Ralf Zimmermann <ralf.zimmermann@tritum.de> Tested-by: Ralf Zimmermann <ralf.zimmermann@tritum.de> Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> --- .../InheritancesResolverService.php | 66 +------------------ 1 file changed, 2 insertions(+), 64 deletions(-) diff --git a/typo3/sysext/form/Classes/Mvc/Configuration/InheritancesResolverService.php b/typo3/sysext/form/Classes/Mvc/Configuration/InheritancesResolverService.php index fe97228e15aa..b4b0823b53ac 100644 --- a/typo3/sysext/form/Classes/Mvc/Configuration/InheritancesResolverService.php +++ b/typo3/sysext/form/Classes/Mvc/Configuration/InheritancesResolverService.php @@ -156,7 +156,7 @@ class InheritancesResolverService if (is_array($inheritances)) { $inheritedConfigurations = $this->resolveInheritancesRecursive($inheritances); - $configuration[$key] = $this->mergeRecursiveWithOverrule( + $configuration[$key] = array_replace_recursive( $inheritedConfigurations, $configuration[$key] ); @@ -237,7 +237,7 @@ class InheritancesResolverService ); } - $inheritedConfigurations = $this->mergeRecursiveWithOverrule( + $inheritedConfigurations = array_replace_recursive( $inheritedConfigurations, $inheritedConfiguration ); @@ -350,66 +350,4 @@ class InheritancesResolverService } return $result; } - - /** - * Merges two arrays recursively and "binary safe" (integer keys are overridden as well), - * overruling similar values in the first array ($firstArray) with the - * values of the second array ($secondArray) - * In case of identical keys, ie. keeping the values of the second. - * This is basically the Extbase arrayMergeRecursiveOverrule method. - * This method act different to the core mergeRecursiveWithOverrule method. - * This method has the possibility to overrule a array value within the - * $firstArray with a string value within the $secondArray. - * The core method does not support such a overrule. - * The reason for this code duplication is that the extbase method will be - * deprecated in the future. - * - * @param array $firstArray First array - * @param array $secondArray Second array, overruling the first array - * @param bool $dontAddNewKeys If set, keys that are NOT found in $firstArray (first array) - * will not be set. Thus only existing value can/will be - * overruled from second array. - * @param bool $emptyValuesOverride If set (which is the default), values from $secondArray - * will overrule if they are empty (according to PHP's empty() function) - * @return array Resulting array where $secondArray values has overruled $firstArray values - * @internal - */ - protected function mergeRecursiveWithOverrule( - array $firstArray, - array $secondArray, - bool $dontAddNewKeys = false, - bool $emptyValuesOverride = true - ): array { - foreach ($secondArray as $key => $value) { - if ( - array_key_exists($key, $firstArray) - && is_array($firstArray[$key]) - ) { - if (is_array($secondArray[$key])) { - $firstArray[$key] = $this->mergeRecursiveWithOverrule( - $firstArray[$key], - $secondArray[$key], - $dontAddNewKeys, - $emptyValuesOverride - ); - } else { - $firstArray[$key] = $secondArray[$key]; - } - } else { - if ($dontAddNewKeys) { - if (array_key_exists($key, $firstArray)) { - if ($emptyValuesOverride || !empty($value)) { - $firstArray[$key] = $value; - } - } - } else { - if ($emptyValuesOverride || !empty($value)) { - $firstArray[$key] = $value; - } - } - } - } - reset($firstArray); - return $firstArray; - } } -- GitLab