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

History 26

  1. Gerrit Code Review pushed patch set 1 for main to change 84631 status New Under Review 06/11/24, 20:50

  2. Gerrit Code Review pushed patch set 2 for main to change 84631 06/15/24, 19:40

  3. Gerrit Code Review pushed patch set 3 for main to change 84631 06/15/24, 20:24

  4. Gerrit Code Review pushed patch set 1 for 12.4 to change 84651 06/18/24, 05:51

  5. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % 06/18/24, 05:55

    Applied in changeset commit:9eaa5a0c96d58bed00aacbf33e5d27c4d5e2e014.

  6. Benni Mack changed status Resolved Closed 07/09/24, 15:12