From eba40ad154be48c1e585b0861aeaab369a244f11 Mon Sep 17 00:00:00 2001 From: Nikita Hovratov <nikita.h@live.de> Date: Mon, 3 Oct 2022 15:10:02 +0200 Subject: [PATCH] [!!!][TASK] Add strict types to GU::fixed_lgd_cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Internal calls to this method have already been adjusted by previous patches. Another one has been found in acceptance tests, which is now fixed as well. Resolves: #98511 Related: #95913 Related: #97887 Releases: main Change-Id: Icf68ed4a05d761e0dcfff33dcb7670c80a934b37 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75950 Tested-by: core-ci <typo3@b13.com> Tested-by: Markus Klein <markus.klein@typo3.org> Tested-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Kevin Appelt <kevin.appelt@icloud.com> Reviewed-by: Markus Klein <markus.klein@typo3.org> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Stefan Bürk <stefan@buerk.tech> --- typo3/sysext/backend/Classes/Clipboard/Clipboard.php | 4 ++-- typo3/sysext/core/Classes/Utility/GeneralUtility.php | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/typo3/sysext/backend/Classes/Clipboard/Clipboard.php b/typo3/sysext/backend/Classes/Clipboard/Clipboard.php index f08a247135ae..ff351400f894 100644 --- a/typo3/sysext/backend/Classes/Clipboard/Clipboard.php +++ b/typo3/sysext/backend/Classes/Clipboard/Clipboard.php @@ -589,7 +589,7 @@ class Clipboard $selectedItem = reset($selectedElements); $selectedRecordTitle = PathUtility::basename($selectedItem); } else { - $selectedRecordTitle = count($selectedElements); + $selectedRecordTitle = (string)count($selectedElements); } } else { $recordTitle = $table !== 'pages' && is_array($reference) @@ -599,7 +599,7 @@ class Clipboard $selectedItem = $this->getSelectedRecord(); $selectedRecordTitle = $selectedItem['_RECORD_TITLE']; } else { - $selectedRecordTitle = count($selectedElements); + $selectedRecordTitle = (string)count($selectedElements); } } // @TODO diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php index 9c866f32a646..36590b5e0475 100644 --- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php +++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php @@ -184,13 +184,9 @@ class GeneralUtility * @param int $chars Must be an integer with an absolute value of at least 4. if negative the string is cropped from the right end. * @param string $appendString Appendix to the truncated string * @return string Cropped string - * @todo Add strict types and return types as breaking change in v12. */ - public static function fixed_lgd_cs($string, $chars, $appendString = '...') + public static function fixed_lgd_cs(string $string, int $chars, string $appendString = '...'): string { - $string = (string)$string; - $chars = (int)$chars; - $appendString = (string)$appendString; if ($chars === 0 || mb_strlen($string, 'utf-8') <= abs($chars)) { return $string; } -- GitLab