Review main Merged

74743[TASK] Solve several phpstan issues in GifBuilder

Simon Schaufelberger CR +2 V +2 Normal +139 −14 updated 06/06/22, 19:46

Commit message

Also add some (indirect) basic tests for
GifBuilder::calculateValue.

Used command:

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Review

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

Issues 1

Files 3

Review log 2431

Show 56 earlier messages
  1. Simon Schaufelberger uploaded patch set 1 05/25/22, 12:41

  2. Simon Schaufelberger updated the commit message in patch set 2 05/25/22, 12:42

  3. Oliver Klee commented on patch set 2 05/25/22, 12:43

    GifBuilder.php:759

    As the return value currently is a whole-number float, I‘d propose doing an int cast instead.
  4. Simon Schaufelberger uploaded patch set 3 05/25/22, 12:47

  5. Simon Schaufelberger commented on patch set 2 05/25/22, 12:47

    GifBuilder.php:759 Reply

    Done
  6. core-ci voted on patch set 2 V +1 05/25/22, 12:50 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27456

  1. core-ci voted on patch set 1 V -1 05/25/22, 12:50 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27455

  2. core-ci voted on patch set 3 V +1 05/25/22, 12:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27457

  3. Oliver Klee voted on patch set 3 CR +1 05/25/22, 13:02

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

  5. Christian Kuhn commented on patch set 3 05/25/22, 13:27

    well. i guess and hope that't fine. however i'm not sure if the annotation is actually correct ... as such, i'd rather go with v12 only on this change. what do you think?
  6. Oliver Klee commented on patch set 3 05/25/22, 13:46

    Reply

    I'd prefer this to go into 11.5 as well as this is a real bugfix. The function with the added int cast is only called in GigBuilder::calcOffset, where the return value should be a comma-separated list of integers according to the documentation: /** * Calculation of offset using "splitCalc" and insertion of dimensions from other GIFBUILDER objects. * * Example: * Input: 2+2, 2*3, 123, [10.w] * Output: 4,6,123,45 (provided that the width of object in position 10 was 45 pixels wide) * * @param string $string The string to resolve/calculate the result of. The string is divided by a comma first and each resulting part is calculated into an integer. * @return string The resolved string with each part (separated by comma) returned separated by comma */ public function calcOffset($string) { $value = []; $numbers = GeneralUtility::trimExplode(',', $this->calculateFunctions($string)); foreach ($numbers as $key => $val) { if ((string)$val == (string)(int)$val) { $value[$key] = (int)$val; } else { $value[$key] = $this->calculateValue($val); } } $string = implode(',', $value); return $string; } If round() results in an number that cannot represented as a float without rounding artefacts, this would result in something like this (even though that's not one of the affected real numbers): "1,2,12341324.0000000000000000000000000001,4"
  7. Simon Schaufelberger commented on patch set 3 05/25/22, 13:49

    Reply

    @Oliver: Would you like to write a test for that?
  8. Oliver Klee commented on patch set 3 05/25/22, 16:19

    Yes, I'll see what I can come up with for tests during the next few days.
  9. crell commented on patch set 3 CR +1 05/27/22, 16:33

    Looks reasonable to me, but yes a test would be beneficial.
  10. Oliver Klee uploaded patch set 4 06/06/22, 16:27

  11. Oliver Klee voted on patch set 4 V +1 CR +1 06/06/22, 16:28

  12. core-ci voted on patch set 4 V -1 06/06/22, 16:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27729

  13. Oliver Klee commented on patch set 4 06/06/22, 16:53

    The test failure is the flaky acceptance test.
  14. Simon Schaufelberger commented on patch set 4 06/06/22, 17:10

    Reply

    restarted.
  15. crell commented on patch set 4 06/06/22, 17:11

    GifBuilderTest.php:56

    If you have to cast to a string every time it's used, why not just use a string in the first place? (Signature and in the data provider.)
  16. core-ci voted on patch set 4 V +1 06/06/22, 17:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27729

  17. Oliver Klee commented on patch set 4 06/06/22, 17:28

    GifBuilderTest.php:56 Reply

    I wanted to make it clear that this is about "integers behind the strings".
  18. Oliver Klee commented on patch set 4 06/06/22, 18:18

    GifBuilderTest.php:56 Reply

    (I'd be fine with both approaches, though. Whatever is helpful to get this merged.)
  19. Simon Schaufelberger commented on patch set 4 06/06/22, 18:21

    GifBuilderTest.php:56 Reply

    I'd vote for string because calcOffset expects a string, so we should also provide one natively.
  20. Oliver Klee uploaded patch set 5 06/06/22, 18:52

  21. Oliver Klee commented on patch set 5 06/06/22, 18:52

    GifBuilderTest.php:56 Reply

    Done.
  22. Oliver Klee voted on patch set 5 V +1 CR +1 06/06/22, 18:52

  23. core-ci voted on patch set 5 V +1 06/06/22, 18:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/27739

  24. Stefan Bürk voted on patch set 5 V +2 CR +2 06/06/22, 19:46

  25. Stefan Bürk merged patch set 6 06/06/22, 19:46