Review main Merged Breaking

79883[!!!][TASK] Introduce type declarations in FileInterface

Alexander Schnitzler CR +2 V +2 Hard +159 −190 updated 07/19/23, 08:16

Commit message

Return and param type declarations have been introduced for all
methods stubs of \TYPO3\CMS\Core\Resource\FileInterface.

All implementations of \TYPO3\CMS\Core\Resource\FileInterface
need to reflect those changes and add the same return and param
type declarations.

In case, any of the core implementations are extended, overridden
methods might need to be adjusted. The core classes, implementing
\TYPO3\CMS\Core\Resource\FileInterface are:

- \TYPO3\CMS\Core\Resource\AbstractFile
- \TYPO3\CMS\Core\Resource\File
- \TYPO3\CMS\Core\Resource\FileReference
- \TYPO3\CMS\Core\Resource\ProcessedFile

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
    • core-ci +1 CI

Issues 1

Files 8

Review log 4251

Show 2126 earlier messages
  1. Alexander Schnitzler uploaded patch set 1 07/09/23, 06:45

  2. Alexander Schnitzler wrote 07/09/23, 06:45

    Topic set to FAL
  3. core-ci voted on patch set 1 V -1 07/09/23, 06:52 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43952

  4. Alexander Schnitzler uploaded patch set 2 V -1 07/09/23, 07:01

  5. Alexander Schnitzler marked it ready for review 07/09/23, 07:01

  6. Alexander Schnitzler uploaded patch set 3 07/09/23, 07:08

  7. core-ci voted on patch set 2 V +1 07/09/23, 07:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43953

  8. core-ci voted on patch set 3 V +1 07/09/23, 07:15 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/43954

  9. Oliver Klee commented on patch set 3 07/09/23, 08:34

    I propose that while we’re having a breaking change for these classes/interfaces anyway, we add the other missing type declarations there as well.

    AbstractFile.php:136

    Can we add a native `array` return type declaration here?

    AbstractFile.php:177

    Shorter: `?int`

    AbstractFile.php:408

    Can we add a native `: self` return type declaration here?

    AbstractFile.php:422

    Can we add a native `: self` return type declaration here?

    AbstractFile.php:434

    `: string`

    AbstractFile.php:465

    `: void`

    AbstractFile.php:475

    `: bool`

    AbstractFile.php:541

    Shorter: `?string`

    File.php:157

    `: void`

    File.php:225

    `@return non-empty-string` and `: string`

    File.php:241

    Can we add a return type declaration here?

    File.php:284

    `: bool`

    File.php:292

    `: void`

    File.php:304

    `?string`

    File.php:317

    `: mixed`

    FileInterface.php:45

    `?int`

    FileInterface.php:64

    `?string`

    FileInterface.php:97

    `@return $this`

    FileInterface.php:126

    `?string`
  10. Oliver Klee voted on patch set 3 V +1 07/09/23, 08:47

  11. Alexander Schnitzler commented on patch set 3 07/09/23, 16:32

    Reply

    If that doesn't widen the scope too much, I am ok with it. I try to keep patch sets smalls however in case of needed reverts. I wouldn't have a problem with another breaking change and a breaking.rst file. Probably there is one huge file for such signature changes anyway, isn't there?
  12. Oliver Klee commented on patch set 3 07/10/23, 21:40

    Reply

    Then let's have two breaking changes to keep both changes a bit smaller.
  13. Alexander Schnitzler commented on patch set 3 07/11/23, 05:36

    AbstractFile.php:136 Reply

    Done

    AbstractFile.php:408 Reply

    Done

    AbstractFile.php:422 Reply

    Done

    AbstractFile.php:434 Reply

    Done

    AbstractFile.php:465 Reply

    Done

    AbstractFile.php:475 Reply

    Done

    AbstractFile.php:541 Reply

    Done

    File.php:157 Reply

    Done

    File.php:225 Reply

    Done

    File.php:241 Reply

    Done

    File.php:284 Reply

    Done

    File.php:292 Reply

    Done

    File.php:317 Reply

    Done
  14. Alexander Schnitzler commented on patch set 4 V +1 07/11/23, 06:23

    Published edit on patch set 3.
  15. Alexander Schnitzler commented on patch set 4 07/11/23, 06:24

    AbstractFile.php:177 Reply

    Done

    File.php:304 Reply

    Done

    FileInterface.php:45 Reply

    Done

    FileInterface.php:64 Reply

    Done

    FileInterface.php:97 Reply

    Done

    FileInterface.php:126 Reply

    Done
  16. core-ci voted on patch set 4 V +1 07/11/23, 06:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44002

  17. Oliver Klee voted on patch set 4 V +1 07/11/23, 06:33

  18. Oliver Klee commented on patch set 4 07/11/23, 06:37

    AbstractFile.php:541

    `?string`

    FileReference.php:252

    `non-empty-string`

    FileReference.php:418

    `?string`

    ProcessedFile.php:588

    `?string`
  19. Oliver Klee commented on patch set 4 CR -1 07/11/23, 06:37

    on it
  20. Oliver Klee commented on patch set 5 CR -1 V +1 07/11/23, 06:40

    Published edit on patch set 4.
  21. Oliver Klee commented on patch set 5 V +1 CR +1 07/11/23, 06:40

    AbstractFile.php:541 Reply

    Done

    FileReference.php:252 Reply

    Done

    FileReference.php:418 Reply

    Done

    ProcessedFile.php:588 Reply

    Done
  22. core-ci voted on patch set 5 V +1 07/11/23, 06:47 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44003

  23. Stefan Bürk commented on patch set 5 07/11/23, 14:24

    FileInterface.php:45

    Why the nullable int return type ? Should this not be `: int` only like the docblock before ?
  24. Alexander Schnitzler commented on patch set 5 07/11/23, 14:33

    FileInterface.php:45 Reply

    That's because of the actual implementation in AbstractFile, which violates the interface and returns null. I am open to change the implementation to return a 0 instead of null or throw an Exception. I guess the least harmful would be to return 0. Since we have a breaking change already, we can simply change this as well.
  25. Alexander Schnitzler commented on patch set 5 CR -1 07/11/23, 14:43

    -1 until issues are resolved.
  26. Oliver Klee commented on patch set 5 07/11/23, 14:44

    FileInterface.php:45 Reply

    I propose we move this to a pre-patch then. (I wouldn't expect this kind of behavior change in a commit with the title of this change here.)
  1. Alexander Schnitzler uploaded patch set 6 CR +1 V +1 07/18/23, 12:09

  2. Alexander Schnitzler commented on patch set 6 07/18/23, 12:10

    FileInterface.php:45 Reply

  3. Alexander Schnitzler commented on patch set 6 07/18/23, 12:10

    Reply

    Done
  4. Oliver Klee voted on patch set 6 CR +1 07/18/23, 12:11

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

  6. Oliver Klee voted on patch set 6 V +1 07/18/23, 12:17

  7. Oliver Klee updated the commit message in patch set 7 CR +1 V +1 07/18/23, 12:18

  8. Oliver Klee voted on patch set 7 V +1 CR +1 07/18/23, 12:18

  9. core-ci voted on patch set 7 V +1 07/18/23, 12:25 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44248

  10. Christian Kuhn commented on patch set 7 07/18/23, 12:28

    FileInterface.php:69

    it seems getExtension() implementations return string and not ?string. do we need ?string here, or could we switch to string only? hope this hasn't been discussed, yet ...
  11. Alexander Schnitzler commented on patch set 7 07/18/23, 12:32

    FileInterface.php:69 Reply

    Hasn't been discussed yet but my argument would be that there are files without extension. Absence of extension is expressed by null. I would also consider changing the implementation but in another patch a dedicated breaking rst.
  12. Christian Kuhn commented on patch set 7 07/18/23, 12:33

    FileInterface.php:69 Reply

    Ack
  13. Christian Kuhn commented on patch set 7 07/18/23, 12:36

    FileInterface.php:69 Reply

    actually ... empty extension could also return empty string, cloudn't it? that's logically fine as well, i guess? unsure ...
  14. Alexander Schnitzler commented on patch set 7 07/18/23, 12:43

    FileInterface.php:69 Reply

    I am open to different views and approaches. I personally like showing the absence of a file extension by null better than having an empty string because then different behavior means different types. As a caller I'd rather want to see null|non-empty-string than checking the string for it's length. But if others think it's more convenient that way, I am fine either way.
  15. Alexander Schnitzler commented on patch set 7 07/18/23, 12:52

    FileInterface.php:69 Reply

    After thinking about it: Let's change it back to string. java and .net also just use empty strings, our implementation uses strings only, all internal callers expect a string. Will be easier for everyone.
  16. Alexander Schnitzler uploaded patch set 8 CR +1 V +1 07/18/23, 12:56

  17. core-ci voted on patch set 8 V +1 07/18/23, 13:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44251

  18. Alexander Schnitzler commented on patch set 8 07/18/23, 14:18

    FileInterface.php:69 Reply

    Done
  19. Oliver Klee voted on patch set 8 V +1 CR +1 07/18/23, 14:36

  20. Christian Kuhn uploaded patch set 9 CR +1 V +1 07/19/23, 05:57

  21. Christian Kuhn voted on patch set 9 V +1 CR +1 07/19/23, 05:57

  22. core-ci voted on patch set 9 V +1 07/19/23, 06:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/44289

  23. Oliver Klee voted on patch set 9 V +1 CR +1 07/19/23, 07:54

  24. Stefan Bürk voted on patch set 9 V +2 CR +2 07/19/23, 08:16

  25. Stefan Bürk merged patch set 10 07/19/23, 08:16