Review main Merged

73984[TASK] Add modern typing to ArrayUtility

crell CR +2 V +2 Hard +113 −145 updated 03/27/23, 08:38

Commit message

PHP 8.1's type system lets us add a lot more types
to ArrayUitlity's signatures, and remove some
unnecessary code in the process.

I also did a little bit of related modern-syntax
cleanup along the way, but this is mainly types.

That also lets us remove some now-unnecessary tests,
and with them some phpstan baseline entries.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Oliver Klee +1
    • Stefan Bürk +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Stefan Bürk +1
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 3546

Show 1521 earlier messages
  1. crell uploaded patch set 1 03/17/22, 18:55

  2. core-ci voted on patch set 1 V +1 03/17/22, 19:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24966

  3. Oli Bartsch commented on patch set 1 V -1 03/17/22, 21:46

    Adding type hints to parameters of API methods is a breaking change which has to be documented as such.
  4. crell uploaded patch set 2 03/18/22, 15:49

  5. core-ci voted on patch set 2 V -1 03/18/22, 15:57 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24989

  6. Mathias Brodala commented on patch set 2 03/18/22, 16:08

    Breaking-97210-TypesAddedToMethodSignatures.rst:4

    > Add native type hints to methods We also include return type hints, right?

    Breaking-97210-TypesAddedToMethodSignatures.rst:13

    Only a single space should be used here.

    Breaking-97210-TypesAddedToMethodSignatures.rst:23

    Calling any of these methods with incompatible types now throws a :php:`\TypeError`. Before the result of such method calls was undefined or inconsistent.
  7. crell commented on patch set 2 03/18/22, 16:43

    Breaking-97210-TypesAddedToMethodSignatures.rst:4 Reply

    Yes, the return type is part of the signature. "Signature" covers both. Also, they're not "type hints". PHP hasn't called them "hints" since sometime in PHP 5.1, I think. They're type declarations.

    Breaking-97210-TypesAddedToMethodSignatures.rst:13 Reply

    Ack

    Breaking-97210-TypesAddedToMethodSignatures.rst:23 Reply

    Ack
  8. crell uploaded patch set 3 03/18/22, 16:43

  9. core-ci voted on patch set 3 V +1 03/18/22, 16:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24990

  10. Oliver Klee commented on patch set 3 03/18/22, 17:12

    ArrayUtility.php:180

    Can/should we add a type for $delimiter as well here?
  11. crell commented on patch set 3 03/18/22, 17:40

    ArrayUtility.php:180 Reply

    Ak, yes, I just missed one. Will update, thanks.
  12. crell uploaded patch set 4 03/18/22, 17:41

  13. core-ci voted on patch set 4 V +1 03/18/22, 17:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24991

  14. Oliver Klee voted on patch set 4 CR +1 03/18/22, 18:11

  15. Nikita Hovratov uploaded patch set 5 03/18/22, 20:34

  16. core-ci voted on patch set 5 V +1 03/18/22, 20:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24992

  17. Oliver Klee voted on patch set 5 CR +1 03/19/22, 10:14

  18. Oliver Hader commented on patch set 5 03/21/22, 09:29

    ArrayUtility.php:914

    would that be something for `array_is_list` (also other occurrences in this class, search for `is_string`)? There seems to be a pending change as well for that: https://review.typo3.org/c/Packages/TYPO3.CMS/+/70246/18/typo3/sysext/core/Classes/Utility/ArrayUtility.php
  19. crell uploaded patch set 6 03/21/22, 14:35

  20. crell commented on patch set 5 03/21/22, 14:38

    ArrayUtility.php:914 Reply

    After a brief chat in Slack, I updated isAssociative() to just wrap array_is_list(). However, the other uses are not *quite* the same, as their behavior (based on the tests) depends on numeric keys only, not on list keys (0-based). I left comments to that effect for future clarity. We can fully deprecate isAssociative() in another patch later as desired.
  21. core-ci voted on patch set 6 V +1 03/21/22, 14:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25027

  1. Oli Bartsch commented on patch set 6 03/21/22, 15:05

    Breaking-97210-TypesAddedToMethodSignatures.rst:1

    Usually our breaking ReST files contain at least four sections: - Description - Impact - Affected Installations - Migration There is also a tool which helps to bootstrap such file: https://forger.typo3.com/utilities/rst
  2. crell uploaded patch set 7 03/21/22, 15:42

  3. core-ci voted on patch set 7 V -1 03/21/22, 15:52 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25033

  4. crell uploaded patch set 8 03/21/22, 17:12

  5. core-ci voted on patch set 8 V +1 03/21/22, 17:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25037

  6. Simon Schaufelberger commented on patch set 8 03/21/22, 17:23

    Breaking-97210-TypesAddedToMethodSignatures.rst:32

    Those will need to be proper*l*y cast also remove double whitespace before
  7. crell commented on patch set 8 03/21/22, 17:38

    Breaking-97210-TypesAddedToMethodSignatures.rst:32 Reply

    Done
  8. crell commented on patch set 8 03/21/22, 17:38

    Breaking-97210-TypesAddedToMethodSignatures.rst:1 Reply

    Done
  9. crell uploaded patch set 9 03/21/22, 17:38

  10. core-ci voted on patch set 9 V +1 03/21/22, 17:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25038

  11. Oliver Klee voted on patch set 9 CR +1 03/22/22, 11:08

  12. Simon Schaufelberger wrote 03/22/22, 15:43

    Removed cc Simon Schaufelberger.
  13. Nikita Hovratov uploaded patch set 10 03/24/22, 17:38

  14. core-ci voted on patch set 10 V +1 03/24/22, 17:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25110

  15. Oliver Klee voted on patch set 10 CR +1 03/24/22, 17:58

  16. crell voted on patch set 10 CR +1 03/24/22, 20:42

  17. Christian Kuhn uploaded patch set 11 03/28/22, 15:32

  18. core-ci voted on patch set 11 V +1 03/28/22, 15:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25220

  19. Oliver Klee voted on patch set 11 CR +1 03/28/22, 15:50

  20. Christian Kuhn voted on patch set 11 V +1 CR +1 03/28/22, 15:51

  21. Stefan Bürk voted on patch set 11 V +1 CR +1 03/28/22, 15:53

  22. Georg Ringer voted on patch set 11 V +2 CR +2 03/28/22, 16:03

  23. Georg Ringer merged patch set 12 03/28/22, 16:03

  24. Alexander Opitz commented on patch set 12 03/25/23, 17:49

    Post Code-Review -1 Opened https://forge.typo3.org/issues/100302

    ArrayUtility.php:141

    The type of $path should be array|string The argument $path isn't processed it is only handed over to static::getValueByPath which accepts array|path for the $path argument. The method documentation is already wrong.
  25. Oliver Hader commented on patch set 12 03/27/23, 08:38

    ArrayUtility.php:141 Reply