Review main Merged

73986[TASK] Add modern typing to MathUtility

crell CR +2 V +2 Normal +16 −36 updated 03/29/22, 18:07

Commit message

This patch add more explicit types to MathUtility.

Of particular note:

* isIntegerInRange(), despite its name, allows for non-ints and
  treats them as out-of-range. Types are setup to retain that
  behavior.
* convertToPositiveInteger() is the same behavior as a call to
  forceIntegerInRange() with a min of 0, thus changed to be that.
* calculateWithPriorityToAdditionAndSubtraction() was docblock
  typed to return an int, when in reality it's float|string. Both
  are changed to "float|string" rather than changing the behavior.
* Similarly, calculateWithParentheses()'s docblock changed to
  proper return type string instead of the incorrect int.

Review

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

Issues 1

Files 3

Review log 1622

  1. crell uploaded patch set 1 03/17/22, 19:56

  2. core-ci voted on patch set 1 V -1 03/17/22, 20:09 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24969

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

    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/28/22, 17:01

  5. Oliver Klee voted on patch set 2 CR +1 03/28/22, 17:06

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

  7. Simon Schaufelberger voted on patch set 2 V +1 CR +1 03/28/22, 19:35

  8. Stefan Bürk updated the commit message in patch set 3 03/28/22, 20:44

  9. core-ci voted on patch set 3 V +1 03/28/22, 21:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25232

  10. Stefan Bürk uploaded patch set 4 03/28/22, 21:26

  11. Stefan Bürk uploaded patch set 5 03/28/22, 21:28

  12. core-ci voted on patch set 4 V +1 03/28/22, 21:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25234

  13. core-ci voted on patch set 5 V +1 03/28/22, 21:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25235

  14. Oliver Klee voted on patch set 5 CR +1 03/28/22, 21:47

  15. Stefan Bürk commented on patch set 5 CR -1 03/29/22, 10:15

    It may be similar, but the used replacement does not. Used replacement changes the range and thus the behaviour. See comments for method.

    MathUtility.php:55

    docblock type <=> argument type missmatch. Should be changed to 'mixed'.

    MathUtility.php:60

    Do not get why you replaced that here. 1. the adding a call which using a condition more 2. limit the "max" to lower. Original "max" was automaticlly PHP_INT_MAX, default 'max' for called method is lower than that '2000000000' At least, third argument with PHP_INT_MAX must be given to keep the same behaviour and range as before. But would keep the original prior to calling the forceInterInRange() method.
  16. crell commented on patch set 5 03/29/22, 14:45

    Reply

    Done

    MathUtility.php:55 Reply

    Done

    MathUtility.php:60 Reply

    Added the PHP_MAX_INT argument. I think it's better to still fold the methods together, though, as their logic is the same. This isn't along a critical path so any performance impact either way is likely to be undetectable.
  17. crell uploaded patch set 6 03/29/22, 14:46

  18. core-ci voted on patch set 6 V +1 03/29/22, 15:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/25263

  19. Oliver Klee voted on patch set 6 CR +1 03/29/22, 15:09

  20. Stefan Bürk voted on patch set 6 V +1 CR +1 03/29/22, 18:05

  21. Christian Kuhn voted on patch set 6 V +2 CR +2 03/29/22, 18:07

  22. Christian Kuhn merged patch set 7 03/29/22, 18:07