Deprecation: #110202 - StringUtility::multibyteStringPad() method
See forge#110202
Description
The method
\TYPO3\
has been marked as deprecated and will be removed in TYPO3 v16.0.
The method was introduced to provide a multibyte-safe variant of PHP's
str_. Since PHP 8.3, the native function
mb_
covers exactly this use case, making the TYPO3 wrapper obsolete.
Impact
Calling the method will trigger a PHP deprecation warning. It will continue to work as before until it is removed in TYPO3 v16.0.
Affected installations
TYPO3 installations with custom extensions or code that directly call
String are affected.
The extension scanner will report any usage as a strong match.
Migration
Use the native PHP function
mb_ instead.
Note that
mb_ throws a
\Value when an empty pad
string is passed, whereas
String returned
the input unchanged. If an empty pad string can occur, guard against it.
use TYPO3\CMS\Core\Utility\StringUtility;
$padded = StringUtility::multibyteStringPad($string, 10, $padString, STR_PAD_LEFT);
$padded = $padString === ''
? $string
: mb_str_pad($string, 10, $padString, STR_PAD_LEFT);