Issue Bug Closed

#102573TypeError: strcasecmp(): Argument #1 ($string1) must be of type string, int given ArrayUtility::sortArraysByKey()

Daniel Siepmann 11/30/23, 14:27 updated 07/09/24, 15:12

Description

The TYPO3 API does not state that ArrayUtility::sortArraysByKey() should only work for strings. One can expect it to work with integers as well.

But the given code leads to an type error:

\TYPO3\CMS\Core\Utility\ArrayUtility::sortArraysByKey([
    [
        'key' => 10,
    ],
    [
        'key' => 11,
    ],
], 'key');

I’d either expect it to working, or a proper note in PHPDoc and type check upfront.
The issue occurs in TYPO3 v12, not in v11. Probably due to the added strict_types=1.

Reviews 2