Review main Merged

76546[TASK] Introduce new functions to ArrayUtility and StringUtility

Bastien Lutz CR +2 V +2 Hard +290 −0 updated 11/10/22, 21:47

Commit message

New helper methods are added to allow
to do the reverse of flattenPlain() in ArrayUtility,
that is ArrayUtility::unflatten().

In order to unflatten correctly, an explode function
which respects escaping characters was introduced to
StringUtility.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Susi Moog +1
  • Verified V +2 Done
    • Benni Mack +2
    • Susi Moog +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 2331

Show 56 earlier messages
  1. Bastien Lutz uploaded patch set 1 11/10/22, 15:57

  2. Bastien Lutz updated the commit message in patch set 2 11/10/22, 16:00

  3. Benni Mack commented on patch set 3 11/10/22, 16:02

    Published edit on patch set 2.
  4. Christian Kuhn commented on patch set 3 11/10/22, 16:07

    StringUtility.php:182

    how to escape the escape char?
  5. Benni Mack commented on patch set 4 11/10/22, 16:07

    Published edit on patch set 3.
  6. core-ci voted on patch set 1 V -1 11/10/22, 16:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33514

  1. core-ci voted on patch set 2 V -1 11/10/22, 16:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33515

  2. core-ci voted on patch set 3 V -1 11/10/22, 16:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33516

  3. core-ci voted on patch set 4 V -1 11/10/22, 16:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33517

  4. Bastien Lutz uploaded patch set 5 11/10/22, 16:56

  5. core-ci voted on patch set 5 V +1 11/10/22, 17:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33520

  6. Bastien Lutz uploaded patch set 6 11/10/22, 17:25

  7. core-ci voted on patch set 6 V +1 11/10/22, 17:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33522

  8. Bastien Lutz commented on patch set 6 11/10/22, 17:35

    StringUtility.php:182 Reply

    I added a testcase which covers escaping the escape char.
  9. Susi Moog voted on patch set 6 CR +1 11/10/22, 17:50

  10. Bastien Lutz commented on patch set 6 11/10/22, 17:55

    Thanks!
  11. Oliver Klee commented on patch set 6 11/10/22, 18:36

    ArrayUtility.php:533

    @param array<string, mixed> $input (as the method relies on the array keys being strings)

    ArrayUtility.php:535

    @return array<string, mixed>

    StringUtility.php:177

    @param non-empty-string $delimiter
  12. Benni Mack uploaded patch set 7 11/10/22, 19:04

  13. Benni Mack commented on patch set 7 11/10/22, 19:04

    ArrayUtility.php:533 Reply

    Done

    ArrayUtility.php:535 Reply

    Done

    StringUtility.php:177 Reply

    Done
  14. core-ci voted on patch set 7 V -1 11/10/22, 19:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33526

  15. Oliver Klee commented on patch set 7 11/10/22, 19:44

    ArrayUtility.php:533

    Ah, this even needs to be more specific: array<non-empty-string, mixed>

    StringUtility.php:180

    Is it intentional that the behavior with an empty delimiter is to return the unchanged subject in an array? (In my eyes, calling this method with an empty delimiter does not make much sense. But I might be missing something.)
  16. Bastien Lutz commented on patch set 7 11/10/22, 20:49

    StringUtility.php:180 Reply

    Yes it is intentional behavior as a string cannot be exploded. So in order to prevent an exception we return the unchanged subject.
  17. Bastien Lutz uploaded patch set 8 11/10/22, 21:04

  18. Oliver Klee commented on patch set 8 11/10/22, 21:07

    StringUtility.php:180 Reply

    I think I need to rephrase. :-) Does is make sense to call this method with an empty string as delimiter in the first place?
  19. core-ci voted on patch set 8 V +1 11/10/22, 21:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/33530

  20. Bastien Lutz commented on patch set 8 11/10/22, 21:19

    StringUtility.php:180 Reply

    No it doesn't make sense but it could always somehow happen. As explode() can't handle an empty string we return the type the developer expects(array) and also prevent an exception from the explode function. So this isn't about the sense of calling an explode without a valid delimiter but more kind of how can wen logically secure this function.
  21. Benni Mack voted on patch set 8 V +1 CR +1 11/10/22, 21:30

  22. Bastien Lutz commented on patch set 8 11/10/22, 21:30

    ArrayUtility.php:533 Reply

    Done
  23. Susi Moog voted on patch set 8 V +1 CR +1 11/10/22, 21:45

  24. Benni Mack voted on patch set 8 V +2 CR +2 11/10/22, 21:47

  25. Benni Mack merged patch set 9 11/10/22, 21:47