Review main Merged

77825[TASK] Make extbase repository generic (phpstan-wise)

Alexander Schnitzler CR +2 V +2 Normal +77 −19 updated 02/14/23, 18:04

Commit message

This patch introduces template tags on the extbase repository
interface, the extbase repository class and the abstract resource
repository class (File, ProcessedFile etc.) to let static code
analyzers and modern IDE's know what that those repositories are
generic.

This patch also introduces extends tags on actual reposities to
let static code analysis know what kind of object the repository
deals with.

As a byproduct, a few phpdoc params and return types have been
fixed or specified.

Review

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

Issues 1

Files 17

Review log 2329

Show 24 earlier messages
  1. Alexander Schnitzler uploaded patch set 1 02/10/23, 13:50

  2. Alexander Schnitzler uploaded patch set 2 02/10/23, 13:51

  3. core-ci voted on patch set 2 V -1 02/10/23, 14:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37560

  4. core-ci voted on patch set 1 V -1 02/10/23, 14:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37559

  1. Oliver Klee commented on patch set 2 02/10/23, 14:54

    We'll need to add the corresponding annotation to the allowlist in Build/Scripts/annotationChecker.php.
  2. Alexander Schnitzler uploaded patch set 3 V -1 02/11/23, 19:21

  3. Alexander Schnitzler uploaded patch set 4 02/11/23, 19:37

  4. core-ci voted on patch set 3 V -1 02/11/23, 19:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37609

  5. Oliver Klee commented on patch set 4 02/11/23, 19:38

    AbstractRepository.php:30

    Schouldn't that be "T of \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface"?

    AbstractRepository.php:279

    Can't we use @return instead of most of the @phpstan-return?

    Repository.php:37

    class-string<T>
  6. Oliver Klee commented on patch set 4 02/11/23, 19:39

    ExtensionRepository.php:32

    For all @extends, we can also use the short class name AFAIK.
  7. Alexander Schnitzler commented on patch set 4 02/11/23, 19:45

    annotationChecker.php:76

    This change has potential for a huge discussion. I remember a decision against using "@phpstan-"-variants of annotations but we do in fact use phpstan in the core and using those in addition to regular annotations adds more information for static code analysis, not all IDE's or even phpdoc itself can handle. Take numeric-string for instance. We can of course just use @param numeric-string $uid and potentially break code analysis of several IDE's or we can simply add more information via @phpstan-param numeric-string $uid. This way we stay backwards compatible but also let phpstan know more about the code base. Just a little off topic. makeInstance() does in fact already use @param class-string and my IDE does not understand it anymore. It thinks, makeInstance() expects an instance of \TYPO3\CMS\Core\Utility\class-string, which of course does not exist...
  8. Alexander Schnitzler commented on patch set 4 02/11/23, 19:48

    AbstractRepository.php:30 Reply

    Actually not. Those FAL-objects don't implement the extbase interface, but their repositories implement the extbase repository interface.

    AbstractRepository.php:279 Reply

    Please see my comment for this on the annotationChecker.php file.

    Repository.php:37 Reply

    Please see my comment for this on the annotationChecker.php file.

    ExtensionRepository.php:32 Reply

    I think it depends on whether there is an include or not. Have to check again.
  9. Oliver Klee commented on patch set 4 02/11/23, 19:58

    annotationChecker.php:76 Reply

    Ack

    AbstractRepository.php:30 Reply

    Ack

    AbstractRepository.php:279 Reply

    Ack

    Repository.php:37 Reply

    Ack
  10. Oliver Klee commented on patch set 4 02/11/23, 20:12

    Repository.php:117

    QueryResultInterface (over a few hops) already extends iterable. So iterable<T> should be sufficient.
  11. core-ci voted on patch set 4 V -1 02/11/23, 20:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37610

  12. Christian Kuhn commented on patch set 4 02/13/23, 12:07

    Repository.php:117 Reply

    Done

    ExtensionRepository.php:32 Reply

    does not harm much to keep FQDN's here, i suppose.
  13. Christian Kuhn commented on patch set 4 02/13/23, 12:10

    Repository.php:117 Reply

    still, it's needed for toArray() and friends, going with QueryResultInterface should do, though.
  14. Christian Kuhn uploaded patch set 5 V -1 02/13/23, 12:10

  15. Christian Kuhn commented on patch set 4 02/13/23, 12:11

    Repository.php:117 Reply

    both need to stay since it could return array, too.
  16. core-ci voted on patch set 5 V +1 02/13/23, 12:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37644

  17. Christian Kuhn uploaded patch set 6 V +1 02/13/23, 12:19

  18. core-ci voted on patch set 6 V +1 02/13/23, 12:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/37645

  19. Christian Kuhn voted on patch set 6 V +1 CR +1 02/13/23, 13:11

  20. Stefan Bürk voted on patch set 6 V +2 CR +2 02/13/23, 18:27

  21. Stefan Bürk merged patch set 7 02/13/23, 18:27

  22. Alexander Schnitzler commented on patch set 7 02/13/23, 19:09

    Repository.php:100

    This was a mistake. Need to revert the T for regular @param tag.

    Repository.php:149

    This was a mistake. Need to revert the T for regular @param tag
  23. Stefan Bürk commented on patch set 7 02/14/23, 16:18

    Repository.php:100 Reply

    Will you come up with a follow up patch ?
  24. Alexander Schnitzler commented on patch set 7 02/14/23, 18:04

    Repository.php:100 Reply

    I put it as drive-by changes into this one: https://review.typo3.org/c/Packages/TYPO3.CMS/+/77846
  25. Alexander Schnitzler commented on patch set 7 02/14/23, 18:04