Review main Merged

78283[TASK] Harden array callbacks in EXT:backend

Oliver Klee CR +2 V +2 Normal +87 −87 updated 07/05/23, 08:05

Commit message

To improve code readability and to help static analysis, add
type annotations and use first-class callables.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Stefan Froemken +1
    • Benni Mack +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Stefan Froemken +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 49

Show 29 more files

Review log 3547

Show 1622 earlier messages
  1. Oliver Klee uploaded patch set 1 03/27/23, 21:56

  2. core-ci voted on patch set 1 V +1 03/27/23, 23:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39736

  3. Stefan Bürk commented on patch set 1 03/29/23, 10:16

    TBH only first quick scroll through with minor comments. No real/honest review yet.

    UserToolbarItem.php:101

    Why should this ever be `false` ?

    NewContentElementController.php:351

    If we typehint string|int, should we not add a (string)cast ?

    AddController.php:141

    ist das sicher ? kann das nicht auch eventuall `array|int|string` sein ?
  4. Andreas Kienast commented on patch set 1 03/29/23, 10:43

    UserToolbarItem.php:101 Reply

    `array|int` would be correct due to `array_flip()` in line 94.
  5. Stefan Bürk commented on patch set 1 03/29/23, 11:14

    UserToolbarItem.php:101 Reply

    Got me, ack.
  6. Stefan Bürk commented on patch set 1 03/29/23, 11:15

    AddController.php:141 Reply

    What the hack .. sorry for german. Is this safe, could this not be eventually `array|int|string`
  7. Oliver Klee commented on patch set 1 03/29/23, 11:18

    UserToolbarItem.php:101 Reply

    Done.

    NewContentElementController.php:351 Reply

    No, we don't need to. Having an int in a string concatenation implicitly casts the int to a string, and IIRC PHPStan would rightfully complain about the unnecessary cast.

    AddController.php:141 Reply

    Better be safe - I've added `|string` now. Done.
  8. Oliver Klee uploaded patch set 2 V +1 03/29/23, 11:18

  9. Andreas Kienast commented on patch set 1 03/29/23, 11:22

    NewContentElementController.php:351 Reply

    Not necessarily. A dot is appended to whatever comes in, triggering an implicit string cast again.

    LiveSearchController.php:86

    Do we need the bool cast? `->getSearchProviderState()` already declares the returned array shape, so phpstan wise it should be safe.

    AddController.php:141 Reply

    Yep, string is IMO missing. GeneralUtility::trimExplode() is explicitly annotated to return a list of strings.
  10. Oliver Klee commented on patch set 2 03/29/23, 11:24

    NewContentElementController.php:351 Reply

    Ack
  11. Oliver Klee commented on patch set 2 03/29/23, 11:26

    LiveSearchController.php:86 Reply

    Done

    AddController.php:141 Reply

    Done
  12. Oliver Klee uploaded patch set 3 03/29/23, 11:26

  13. core-ci voted on patch set 2 V +1 03/29/23, 11:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39818

  14. core-ci voted on patch set 3 V +1 03/29/23, 11:34 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/39819

  15. Oliver Klee uploaded patch set 4 V +1 04/13/23, 08:02

  16. core-ci voted on patch set 4 V +1 04/13/23, 08:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40550

  17. Oliver Klee rebased onto patch set 5 V +1 04/20/23, 15:10

  18. core-ci voted on patch set 5 V +1 04/20/23, 15:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/40987

  19. Oliver Klee rebased onto patch set 6 V +1 04/24/23, 11:17

  20. core-ci voted on patch set 6 V +1 04/24/23, 11:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41148

  21. Benni Mack commented on patch set 6 04/24/23, 12:24

    UserToolbarItem.php:101

    could we use array_filter($mostRecentUsers, is_array(...)) instead?

    CreateBackendUserCommand.php:149

    we could simplify this by using fetchFirstColumn() ?
  22. Oliver Klee commented on patch set 6 04/24/23, 12:47

    UserToolbarItem.php:101 Reply

    Done

    CreateBackendUserCommand.php:149 Reply

    Good idea! I'd like to fix this in a separate change as it's out of scope for this change (adding type annotations to callables and use first-class callables). I've created the ticket https://forge.typo3.org/issues/100729 for this and assigned it to me.
  1. Oliver Klee rebased onto patch set 7 V +1 04/24/23, 12:48

  2. core-ci voted on patch set 7 V +1 04/24/23, 12:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41161

  3. Benni Mack voted on patch set 7 CR +1 04/24/23, 12:56

  4. Oliver Klee uploaded patch set 8 CR +1 V +1 04/25/23, 12:12

  5. core-ci voted on patch set 8 V +1 04/25/23, 12:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41215

  6. Jörg Bösche voted on patch set 8 CR +1 04/28/23, 09:12

  7. Oliver Klee rebased onto patch set 9 CR +1 V +1 05/05/23, 13:46

  8. core-ci voted on patch set 9 V +1 05/05/23, 13:53 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41609

  9. Stefan Froemken commented on patch set 9 CR -1 05/10/23, 21:43

    LiveSearchController.php:86

    IMO isActive is 0 or 1. So return value bool will fail.
  10. Oliver Klee commented on patch set 9 05/11/23, 07:50

    LiveSearchController.php:86 Reply

    Done
  11. Oliver Klee uploaded patch set 10 CR -1 V +1 05/11/23, 07:50

  12. core-ci voted on patch set 10 V +1 05/11/23, 07:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41753

  13. Andreas Kienast commented on patch set 10 CR -1 05/11/23, 08:01

    LiveSearchController.php:86 Reply

    That's not true. `isActive` is the result of `in_array()`, which returns a bool: https://github.com/TYPO3/typo3/blob/main/typo3/sysext/backend/Classes/Search/LiveSearch/SearchRepository.php#L52
  14. Oliver Klee commented on patch set 10 05/11/23, 08:04

    LiveSearchController.php:86 Reply

    Done - I've removed the bool cast and added an explanatory comment for the next person who reads this line.
  15. Oliver Klee uploaded patch set 11 CR -1 V +1 05/11/23, 08:04

  16. core-ci voted on patch set 11 V +1 05/11/23, 08:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/41754

  17. Stefan Froemken voted on patch set 11 V +1 CR +1 05/11/23, 09:00

  18. Benni Mack commented on patch set 11 07/04/23, 07:42

    Can you resolve the merge conflict please?
  19. Oliver Klee commented on patch set 11 07/04/23, 08:37

    Reply

    Done.
  20. Oliver Klee uploaded patch set 12 CR +1 V +1 07/04/23, 08:37

  21. core-ci voted on patch set 12 V +1 07/04/23, 08:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43342

  22. Benni Mack voted on patch set 12 V +1 CR +1 07/04/23, 13:11

  23. Stefan Froemken voted on patch set 12 V +1 CR +1 07/05/23, 06:36

  24. Stefan Bürk voted on patch set 12 V +2 CR +2 07/05/23, 08:05

  25. Stefan Bürk merged patch set 13 07/05/23, 08:05