Review main Merged Breaking

81885[!!!][TASK] Use strict types in Extbase ActionController

Torben Hansen CR +2 V +2 Hard +189 −183 updated 01/24/24, 12:41

Commit message

This change introduces strict types for properties, excluding the
`$view` property, in
`TYPO3\CMS\Extbase\Mvc\Controller\ActionController`. In addition, all
function arguments and function return types are now also strictly
typed.

Review

  • Code review CR +2 Done
    • Oliver Hader +2
    • Oliver Klee +1
    • Nikita Hovratov +1
    • Simon Schaufelberger +1
  • Verified V +2 Done
    • Oliver Hader +2
    • Oliver Klee +1
    • Nikita Hovratov +1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 10

Review log 3847

Show 1722 earlier messages
  1. Torben Hansen uploaded patch set 1 11/23/23, 08:48

  2. core-ci voted on patch set 1 V +1 11/23/23, 08:55 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/49612

  3. Andreas Wolf commented on patch set 1 11/23/23, 10:35

    ActionController.php:91

    Should we maybe add `class-string<ViewInterface>` as an additional type hint here?
  4. Torben Hansen uploaded patch set 2 V +1 12/07/23, 18:14

  5. Torben Hansen commented on patch set 2 12/07/23, 18:14

    ActionController.php:91 Reply

    Done
  6. core-ci voted on patch set 2 V +1 12/07/23, 18:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50464

  7. Torben Hansen uploaded patch set 3 V +1 12/08/23, 14:17

  8. Torben Hansen wrote 12/08/23, 14:18

    Topic set to extbase
  9. Torben Hansen updated the commit message in patch set 4 12/08/23, 14:18

  10. core-ci voted on patch set 3 V +1 12/08/23, 14:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50503

  11. core-ci voted on patch set 4 V +1 12/08/23, 14:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50504

  12. Oliver Klee voted on patch set 4 V +1 12/08/23, 15:05

  13. Oliver Klee commented on patch set 4 12/08/23, 15:08

    ActionController.php:99

    Would it make sense to annotate this as `@var non-empty-string`?

    ActionController.php:692

    Should we type this as well, e.g., as `mixed`?
  14. Oliver Klee commented on patch set 4 12/11/23, 21:18

    ActionController.php:692 Reply

    (The stand-alone type `null` (which would have been the most fitting type AFAICT) is unfortunately only available in PHP 8.2 and later, it seems: https://www.php.net/manual/en/language.types.declarations.php)
  15. Simon Schaufelberger commented on patch set 4 12/15/23, 00:02

    why is the view property excluded. please explain.
  16. Torben Hansen uploaded patch set 5 V +1 12/15/23, 11:04

  17. Torben Hansen commented on patch set 4 12/15/23, 11:04

    Reply

    The `view` property is excluded here, since if this variable would be type safe, then all classes extending `ActionController` have to use `ViewInterface` as type for this variable. As an example, the `TYPO3\CMS\Extensionmanager\Controller\DownloadController` uses `JsonView` as type annotation and if we have strict types for the `view` property, we have to use both the PHP type declaration for the property and the `@var` annotation. Basically I'm open to make this property strict too, as the change is breaking. If someone sees a benefit in this, I can change the patch.

    ActionController.php:99 Reply

    Done

    ActionController.php:692 Reply

    Done
  18. core-ci voted on patch set 5 V +1 12/15/23, 11:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50682

  19. Oliver Klee voted on patch set 5 CR +1 V +1 12/16/23, 10:49

  20. Christian Kuhn commented on patch set 5 12/18/23, 10:54

    Reply

    the view class has to change later anyways. keep it non-typed for now, please.
  21. Christian Kuhn commented on patch set 5 CR -1 12/18/23, 10:59

    Breaking-102632-UseStrictTypesInExtbaseActionController.rst:37

    The problem is here that extensions which want to stay compatatible with v12 & v13 need a quirk here: properties in PHP are liskov co- *and* contravariant. That means, when an inheriting class sets the property to something different, it will either crash v12 (if type hint is there), or v13 (if type hint is *not* there). The only solution for extensions that aim for both v12&v13 compat is to *not* override the property, but instead set the wanted value in __construct(). This migration path should be documented here.
  22. Christian Kuhn commented on patch set 5 12/18/23, 11:00

    Breaking-102632-UseStrictTypesInExtbaseActionController.rst:37 Reply

    note this is a general strategy for other places where core delivers an abstract and wants to add types on properties that might have custom values in inheritance.
  1. Torben Hansen uploaded patch set 6 CR +1 V +1 12/21/23, 07:53

  2. Torben Hansen commented on patch set 6 12/21/23, 07:54

    Breaking-102632-UseStrictTypesInExtbaseActionController.rst:37 Reply

    Done
  3. core-ci voted on patch set 6 V +1 12/21/23, 08:03 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50859

  4. Oliver Klee voted on patch set 6 CR +1 V +1 12/21/23, 10:49

  5. Nikita Hovratov commented on patch set 6 CR -1 12/21/23, 12:00

    Breaking-102632-UseStrictTypesInExtbaseActionController.rst:60

    One "-" too much

    ActionController.php:742

    Return type must be `never` here, as the exception is always thrown.
  6. Torben Hansen uploaded patch set 7 CR +1 V +1 12/21/23, 12:37

  7. Torben Hansen commented on patch set 7 12/21/23, 12:37

    Breaking-102632-UseStrictTypesInExtbaseActionController.rst:60 Reply

    Done

    ActionController.php:742 Reply

    Thanks, did not know that.
  8. core-ci voted on patch set 7 V +1 12/21/23, 12:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50865

  9. Oliver Klee voted on patch set 7 CR +1 V +1 12/21/23, 12:53

  10. Nikita Hovratov voted on patch set 7 CR +1 12/21/23, 13:27

  11. Nikita Hovratov uploaded patch set 8 CR +1 V +1 12/21/23, 19:42

  12. Nikita Hovratov commented on patch set 8 12/21/23, 19:47

    ActionController.php:717

    This looks odd. Maybe this should be string? Or UriInterface|string ?
  13. core-ci voted on patch set 8 V +1 12/21/23, 19:52 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/50876

  14. Oliver Klee commented on patch set 8 V +1 12/21/23, 20:10

    ActionController.php:693

    I'd suggest (for the sake of completeness) to also type `$_`, e.g., as `mixed`.

    ActionController.php:717

    Also, I'd suggest (for the sake of completeness) to also type `$_`, e.g., as `mixed`.
  15. Nikita Hovratov commented on patch set 8 12/21/23, 20:16

    ActionController.php:693 Reply

    I don't know, it is hinted as `null` in the doc block param. `mixed` would allow the old value `int` and would not warn the user that this value is deprecated.

    ActionController.php:717 Reply

    Same as comment above.
  16. Oliver Klee commented on patch set 8 12/21/23, 20:44

    ActionController.php:693 Reply

    Ah, and we already have the PHPDoc type annotation `null`. Then let's keep it as is.

    ActionController.php:717 Reply

    Ack.
  17. Torben Hansen uploaded patch set 9 V +1 01/05/24, 10:20

  18. Torben Hansen commented on patch set 8 01/05/24, 10:20

    ActionController.php:717 Reply

    done
  19. core-ci voted on patch set 9 V +1 01/05/24, 10:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/51133

  20. Oliver Klee voted on patch set 9 CR +1 V +1 01/05/24, 11:01

  21. Simon Schaufelberger voted on patch set 9 CR +1 V +1 01/05/24, 12:07

  22. Nikita Hovratov voted on patch set 9 CR +1 V +1 01/08/24, 10:02

  23. Oliver Hader voted on patch set 9 CR +1 V +1 01/24/24, 12:39

  24. Oliver Hader voted on patch set 9 CR +2 V +2 01/24/24, 12:41

  25. Oliver Hader merged patch set 10 01/24/24, 12:41