Review main Merged

74313[TASK] Add native types for PermutationUtility

crell CR +2 V +2 Easy +9 −17 updated 04/19/22, 10:01

Commit message

This is more docblocks than function signatures,
but we're being thorough.

Review

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

Issues 3

Files 1

Review log 2629

Show 34 earlier messages
  1. crell uploaded patch set 1 04/13/22, 17:39

  2. core-ci voted on patch set 1 V +1 04/13/22, 17:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26000

  3. Oliver Klee voted on patch set 1 CR +1 04/13/22, 17:52

  4. Jörg Bösche commented on patch set 1 CR -1 04/14/22, 08:10

    PermutationUtility.php:97

    Mixed does not work with PHP versions below 8.0. I'm not sure if the upcoming T3 v12 will only work with PHP v8.0. Correct me if I'm wrong. https://php.watch/versions/8.0/mixed-type
  1. Chris Müller commented on patch set 1 04/14/22, 09:37

    PermutationUtility.php:97 Reply

    TYPO3 v12 will require PHP 8.1+.
  2. Stefan Bürk commented on patch set 1 04/14/22, 11:22

    PermutationUtility.php:97 Reply

    Not will, it already do. min php is 8.1. And this is main only. Changed min requirements for v12 has been already announced: https://typo3.org/article/new-system-requirements-for-upcoming-typo3-v12#:~:text=TYPO3%20v12%20will%20require%20MariaDB,available%20in%20major%20Linux%20distributions. So please remove the -1 as this was the only argument for the -1 vote.
  3. Jörg Bösche voted on patch set 1 CR +1 04/14/22, 11:45

  4. crell commented on patch set 1 04/14/22, 14:09

    PermutationUtility.php:97 Reply

    Done
  5. Benni Mack commented on patch set 1 04/16/22, 20:07

    This change is not breaking.

    PermutationUtility.php:97 Reply

    what's the benefit of using "mixed" vs not having a type?
  6. Benni Mack voted on patch set 1 CR -1 04/16/22, 20:08

  7. Oliver Hader commented on patch set 1 CR -1 04/16/22, 20:17

    This is not a breaking change... PoC: https://3v4l.org/kKYvP#v8.1.5
  8. Oliver Hader commented on patch set 1 04/16/22, 20:18

    Reply

  9. crell commented on patch set 1 04/18/22, 14:28

    PermutationUtility.php:97 Reply

    Explicitness. It makes it clear that the design of the function accepts/works with any type, as opposed to omitting it entirely which could also mean "I don't actually know what my code does". It also signals to callers that any type is allowed, not "you have to go read the function to reverse engineer what types are/are not allowed." At this point in PHP's life, the type system is robust enough that there are no parameters that should be left untyped. (The one exception being those that need combined union/intersection types, but those are very rare and should be supported fairly soon, I wager.)
  10. crell updated the commit message in patch set 2 04/18/22, 14:29

  11. Oliver Klee commented on patch set 2 04/18/22, 14:30

    PermutationUtility.php:97 Reply

    What Larry says. It's for communicating to the reader.
  12. Oliver Klee voted on patch set 2 CR +1 04/18/22, 14:31

  13. core-ci voted on patch set 2 V +1 04/18/22, 14:49 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26155

  14. Stefan Bürk commented on patch set 2 04/18/22, 16:22

    PermutationUtility.php:97 Reply

    To pick up Benni's question and precise it: What's the benefit of adding mixed instead of a concrete type. If we do a change here, we should consider if a concreter type can be used which make sense prior to simply adding a "mixed" for explictness without deeper meaning. Wouldn't 'string|\Stringable' be a more resonable type here ? See: https://3v4l.org/3FKKQ#v8.1.5
  15. crell commented on patch set 2 04/18/22, 17:13

    PermutationUtility.php:97 Reply

    Changing the function to take only `string|Stringable` would have the effect of its body being reduced to: ``` function asString(string|\Stringable $item): string return (string)$item; } ``` and it would change the throwable that gets thrown for non-string types. That is, the types effectively render this function pointless and callers to it should just change to check the type themselves. This method is only called once within this class, I believe, so we certainly could just inline the logic in meltStringItems(). Arguably we could just replace it with nothing, as the array in question is documented as taking an array of strings, and concatenation will already either invoke __toString, throw an exception for a non-stringable object, or raise a Warning on an array. (It used to be a notice, but became a warning on 8.0.) So if we're OK with the error type changing and being *slightly* less picky (arrays become a warning, not a LogicException), we can just remove the method entirely and not replace it with anything. After ducking it through to myself above, I think that's my preferred approach. It doesn't really give us much at this point that we actually need.
  16. Oliver Klee commented on patch set 2 04/18/22, 17:17

    PermutationUtility.php:97 Reply

    Sounds good to me.
  17. Stefan Bürk commented on patch set 2 04/18/22, 17:32

    PermutationUtility.php:97 Reply

    It seems, that this util is mainly ( **only** ) used to prepare data in tests. And not used in normal core code. And in the end, would not make sense for real extension to use it anyway.
  18. Stefan Bürk commented on patch set 2 04/18/22, 17:40

    PermutationUtility.php:97 Reply

    I would go with leaving the protected method and use "string|\Stringable" type here. Or remove it and do a check on the item and if not string or stringable throw the LogicExpection directly in the method.
  19. Stefan Bürk uploaded patch set 3 04/18/22, 17:58

  20. Oliver Klee voted on patch set 3 CR +1 04/18/22, 18:04

  21. crell commented on patch set 3 CR +1 04/18/22, 18:11

    PermutationUtility.php:97 Reply

    Done
  22. core-ci voted on patch set 3 V +1 04/18/22, 18:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/26164

  23. Stefan Bürk voted on patch set 3 V +1 CR +1 04/18/22, 18:25

  24. Benni Mack voted on patch set 3 V +2 CR +2 04/19/22, 10:01

  25. Benni Mack merged patch set 4 04/19/22, 10:01