From 0d36bf31a7066718d36274673f21b5ea9822add7 Mon Sep 17 00:00:00 2001 From: Oliver Bartsch <bo@cedev.de> Date: Mon, 29 Nov 2021 16:06:18 +0100 Subject: [PATCH] [!!!][TASK] Remove GeneralUtility::rmFromList GeneralUtility::rmFromList is unused since at least v10 and is therefore now removed. Resolves: #96142 Related: #94311 Releases: main Change-Id: Ib237bc7fb2af58877f0baef94d97853cefe396ea Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72377 Tested-by: Benni Mack <benni@typo3.org> Tested-by: core-ci <typo3@b13.com> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> Reviewed-by: Benni Mack <benni@typo3.org> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../core/Classes/Utility/GeneralUtility.php | 27 ------------- ...g-96107-DeprecatedFunctionalityRemoved.rst | 1 + .../Utility/GeneralUtilityTest.php | 40 ------------------- .../Php/MethodCallStaticMatcher.php | 1 + 4 files changed, 2 insertions(+), 67 deletions(-) diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 65298a83b372..026b1411498a 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -528,33 +528,6 @@ class GeneralUtility return str_contains(',' . $list . ',', ',' . $item . ','); } - /** - * Removes an item from a comma-separated list of items. - * - * If $element contains a comma, the behaviour of this method is undefined. - * Empty elements in the list are preserved. - * - * @param string $element Element to remove - * @param string $list Comma-separated list of items (string) - * @return string New comma-separated list of items - * @deprecated since v11, will be removed in v12. - */ - public static function rmFromList($element, $list) - { - trigger_error( - 'GeneralUtility::rmFromList() is deprecated and will be removed in v12.', - E_USER_DEPRECATED - ); - - $items = explode(',', $list); - foreach ($items as $k => $v) { - if ($v == $element) { - unset($items[$k]); - } - } - return implode(',', $items); - } - /** * Expand a comma-separated list of integers with ranges (eg 1,3-5,7 becomes 1,3,4,5,7). * Ranges are limited to 1000 values per range. diff --git a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst index 1f65efdc5fb8..6d4dbecc0b98 100644 --- a/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst +++ b/typo3/sysext/core/Documentation/Changelog/12.0/Breaking-96107-DeprecatedFunctionalityRemoved.rst @@ -48,6 +48,7 @@ The following PHP static class methods that have previously been marked as depre - :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::softRefParserObj()` - :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::explodeSoftRefParserList()` - :php:`\TYPO3\CMS\Backend\Utility\BackendUtility::viewOnClick` +- :php:`\TYPO3\CMS\Core\Utility\GeneralUtility::rmFromList()` - :php:`\TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode()` - :php:`\TYPO3\CMS\Core\Utility\HttpUtility::redirect()` - :php:`\TYPO3\CMS\Core\Utility\HttpUtility::setResponseCode()` diff --git a/typo3/sysext/core/Tests/UnitDeprecated/Utility/GeneralUtilityTest.php b/typo3/sysext/core/Tests/UnitDeprecated/Utility/GeneralUtilityTest.php index 36db2249552f..f62d5474fbd1 100644 --- a/typo3/sysext/core/Tests/UnitDeprecated/Utility/GeneralUtilityTest.php +++ b/typo3/sysext/core/Tests/UnitDeprecated/Utility/GeneralUtilityTest.php @@ -47,46 +47,6 @@ class GeneralUtilityTest extends UnitTestCase self::assertSame($expected, $result); } - /** - * @test - * @dataProvider rmFromListRemovesElementsFromCommaSeparatedListDataProvider - * - * @param string $initialList - * @param string $listWithElementRemoved - */ - public function rmFromListRemovesElementsFromCommaSeparatedList( - string $initialList, - string $listWithElementRemoved - ): void { - self::assertSame($listWithElementRemoved, GeneralUtility::rmFromList('removeme', $initialList)); - } - - /** - * Data provider for rmFromListRemovesElementsFromCommaSeparatedList - * - * @return array - */ - public function rmFromListRemovesElementsFromCommaSeparatedListDataProvider(): array - { - return [ - 'Element as second element of three' => ['one,removeme,two', 'one,two'], - 'Element at beginning of list' => ['removeme,one,two', 'one,two'], - 'Element at end of list' => ['one,two,removeme', 'one,two'], - 'One item list' => ['removeme', ''], - 'Element not contained in list' => ['one,two,three', 'one,two,three'], - 'Empty element survives' => ['one,,three,,removeme', 'one,,three,'], - 'Empty element survives at start' => [',removeme,three,removeme', ',three'], - 'Empty element survives at end' => ['removeme,three,removeme,', 'three,'], - 'Empty list' => ['', ''], - 'List contains removeme multiple times' => ['removeme,notme,removeme,removeme', 'notme'], - 'List contains removeme multiple times nothing else' => ['removeme,removeme,removeme', ''], - 'List contains removeme multiple times nothing else 2x' => ['removeme,removeme', ''], - 'List contains removeme multiple times nothing else 3x' => ['removeme,removeme,removeme', ''], - 'List contains removeme multiple times nothing else 4x' => ['removeme,removeme,removeme,removeme', ''], - 'List contains removeme multiple times nothing else 5x' => ['removeme,removeme,removeme,removeme,removeme', ''], - ]; - } - /////////////////////////////// // Tests concerning isFirstPartOfStr /////////////////////////////// diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php index 2b8847e0ef3e..5b9016332673 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php @@ -1094,6 +1094,7 @@ return [ 'maximumNumberOfArguments' => 2, 'restFiles' => [ 'Deprecation-94311-DeprecatedGeneralUtilityrmFromList.rst', + 'Breaking-96107-DeprecatedFunctionalityRemoved.rst', ], ], 'TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5' => [ -- GitLab