Review main Merged

84351[TASK] Use special PHPUnit ruleset for PHPStan

Ayke Halder CR +2 V +2 Easy +18 −16 updated 05/27/24, 12:48

Commit message

This enables the already available `phpstan-phpunit` rules:
* PHPStan\Rules\PHPUnit\AssertSameBooleanExpectedRule
* PHPStan\Rules\PHPUnit\AssertSameNullExpectedRule
* PHPStan\Rules\PHPUnit\AssertSameWithCountRule
* PHPStan\Rules\PHPUnit\MockMethodCallRule
* PHPStan\Rules\PHPUnit\ShouldCallParentMethodsRule

`ShouldCallParentMethodsRule` is of great interest:
It checks for missing calls to `parent::setUp` and `parent::tearDown`.

`AssertSameWithCountRule` replaces
`assertSame($expectedCount, count($variable))` with
`assertCount($expectedCount, $variable)`.

Review

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

Issues 2

Files 12

Review log 2125

  1. Ayke Halder uploaded patch set 1 05/22/24, 22:17

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

  3. Anja Leichsenring commented on patch set 1 CR +1 V +1 05/23/24, 04:58

    I like, thank you.
  4. Christian Kuhn commented on patch set 1 05/23/24, 07:18

    did you check all places where ->count() is substituted with assertCount() actually works on objects that implement \Countable?

    IntegrityServiceTest.php:249

    this should be turned around along the way, shouldn't it? expectation first, then subject value?
  5. Oliver Klee commented on patch set 1 V +1 05/23/24, 09:59

    Very nice! (And yes, what Lolli says.)
  6. Stefan Bürk commented on patch set 1 05/23/24, 21:43

    Please use three normal points instead of these three-dot char, replacing ``` `…` => `...` ``` on the places in the commit message.
    main has doctrine/dbal 4.x required as minumum, and in TYPO3 v12 we are on doctrine/dbal 3.7.x, thus being higher than the 2.11.0 mentioned here - so that does not explain the need for the baseline. What do I miss here ?
  7. Stefan Bürk commented on patch set 1 05/26/24, 21:57

    Reply

    You related to the conditional mocking in the test case, as far as I could tell. I created a dedicated pre-patch to resolve this, after that got merged this commit statement could be removed along with the baseline entry, I guess. See: I4cc2d5942149f69e044c25379c82388f1c4b9f45
  8. Benjamin Franzke commented on patch set 1 05/27/24, 06:34

    Reply

    Why? The unicode ellipsis `…` indicates an intentional omission of text. The three ascii dots `...` would be real code that creates a callable. The omission of text was the intention. I think that's fine. Agreed?
  9. Ayke Halder uploaded patch set 2 CR +1 V +1 05/27/24, 06:36

  10. core-ci voted on patch set 2 V -1 05/27/24, 06:43 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58323

  11. Ayke Halder commented on patch set 2 05/27/24, 06:46

    Reply

    PHPStan tells to substitute with `assertCount()` on objects that implement `\Countable`. PHPStan `assertCount()` is implemented like this: ``` final public static function assertCount(int $expectedCount, Countable|iterable $haystack, string $message = ''): void { if ($haystack instanceof Generator) { throw GeneratorNotSupportedException::fromParameterName('$haystack'); } static::assertThat( $haystack, new Count($expectedCount), $message, ); } ``` No errors after replacement and does work.

    Reply

    Just quoted the whole messsage now - including variable names.

    Reply

    That was my intention. Patch is blocked by I4cc2d5942149f69e044c25379c82388f1c4b9f45 and can be merged after that.

    IntegrityServiceTest.php:249 Reply

    Reverted.
  12. Ayke Halder rebased onto patch set 3 V -1 05/27/24, 10:40

  13. core-ci voted on patch set 3 V +1 05/27/24, 10:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58336

  14. Oliver Klee voted on patch set 3 CR +1 V +1 05/27/24, 10:50

  15. Christian Kuhn commented on patch set 3 05/27/24, 12:38

    Reply

    Done
  16. Christian Kuhn voted on patch set 3 CR +1 V +1 05/27/24, 12:39

  17. Christian Kuhn voted on patch set 3 CR 0 V 0 05/27/24, 12:40

  18. Christian Kuhn updated the commit message in patch set 4 CR +1 V +1 05/27/24, 12:41

  19. Christian Kuhn rebased onto patch set 5 05/27/24, 12:41

  20. Christian Kuhn commented on patch set 5 CR +1 V +1 05/27/24, 12:42

    removed v12 from releases since the patch gives headaches with some v12 tests that have been cleaned up in main. i guess that's fine: 99% patches are main-first, we don't loose much not enabling this in v12.
  21. Oliver Klee voted on patch set 5 CR +1 V +1 05/27/24, 12:42

  22. Christian Kuhn commented on patch set 5 05/27/24, 12:44

    note: good cleanup and good addition to regular code integrity checks.
  23. Stefan Bürk voted on patch set 5 CR +2 V +2 05/27/24, 12:44

  24. Stefan Bürk merged patch set 6 05/27/24, 12:44

  25. core-ci voted on patch set 5 V +1 05/27/24, 12:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/58346