Review main Merged Breaking

88687[!!!][TASK] Use native types and fix proper return types in FAL

Benni Mack CR +2 V +2 Expert +473 −1225 updated 04/02/25, 13:54

Commit message

This change aims for
- adding types to objects throughout FAL
- solving some weird issues due to wrong type-hinting
and wrong return types.

Some major public API entry points such as
- getFileObject()
- getFileReferenceObject()
- getResourceFromCombinedIdentifier()

are softened to allow string|int as argument
to ensure maximum backwards-compatibility for
regular extension developers.

All of the existing changes were obvious because most of
the code was already returning the correct values, or used
in the right way -  no code outside of FAL was needed
to be adjusted which makes this change less intrusive.

Some quirks found while sorting out the API:

Apparently some methods in ResourceStorage such
as createFile() etc. should return a File, but _could_ return
File|ProcessedFile|null, which is wrong, but are
now clearly stated.

FolderInterface explicitly mentions "Folder" asa return type
whereas the interface should be strict and not follow any other
implementations when returning code. In general, extending
the FolderInterface and type-hinting FolderInterface everywhere
should be one of the next steps (see comments in FolderInterface).

Some methods within AbstractFile do belong to the actual "File"
object. Some methods within FileInterface should be removed, this is
done in a followup patch and marked as such.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
  • Verified V +2 Done
    • Georg Ringer +2
    • core-ci +1 CI

Issues 1

Files 34

Show 14 more files

Review log 4369

Show 2544 earlier messages
  1. Benni Mack uploaded patch set 1 03/23/25, 17:31

  2. core-ci voted on patch set 1 V -1 03/23/25, 17:46 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76071

  3. Benni Mack uploaded patch set 2 V -1 03/23/25, 19:37

  4. core-ci voted on patch set 2 V -1 03/23/25, 19:48 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76083

  5. Benni Mack uploaded patch set 3 V -1 03/23/25, 19:57

  6. core-ci voted on patch set 3 V -1 03/23/25, 20:07 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76085

  7. Benni Mack uploaded patch set 4 V -1 03/23/25, 21:12

  8. Benni Mack uploaded patch set 5 03/23/25, 21:19

  9. core-ci voted on patch set 4 V -1 03/23/25, 21:21 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76087

  10. core-ci voted on patch set 5 V -1 03/23/25, 21:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76088

  11. Benni Mack uploaded patch set 6 V -1 03/23/25, 22:07

  12. core-ci voted on patch set 6 V -1 03/23/25, 22:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76096

  13. Benni Mack uploaded patch set 7 V -1 03/23/25, 22:28

  14. core-ci voted on patch set 7 V -1 03/23/25, 22:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76100

  15. Benni Mack marked it work in progress 03/23/25, 22:57

  16. Benni Mack uploaded patch set 8 V -1 03/24/25, 22:38

  17. core-ci voted on patch set 8 V -1 03/24/25, 22:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76189

  18. Benni Mack uploaded patch set 9 V -1 03/24/25, 23:02

  19. core-ci voted on patch set 9 V -1 03/24/25, 23:10 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76190

  20. Benni Mack uploaded patch set 10 V -1 03/24/25, 23:12

  21. core-ci voted on patch set 10 V -1 03/24/25, 23:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76191

  22. Benni Mack uploaded patch set 11 V -1 03/24/25, 23:25

  23. core-ci voted on patch set 11 V -1 03/24/25, 23:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76192

  24. Benni Mack uploaded patch set 12 V -1 03/24/25, 23:34

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

  26. Benni Mack uploaded patch set 13 V +1 03/25/25, 10:21

  27. Benni Mack uploaded patch set 14 03/25/25, 10:26

  28. core-ci voted on patch set 13 V -1 03/25/25, 10:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76232

  29. core-ci voted on patch set 14 V -1 03/25/25, 10:34 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76233

  30. Benni Mack uploaded patch set 15 V -1 03/25/25, 10:37

  31. core-ci voted on patch set 15 V +1 03/25/25, 10:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76235

  32. Benni Mack updated the commit message in patch set 16 V +1 03/25/25, 13:36

  33. Benni Mack marked it ready for review 03/25/25, 13:37

  34. core-ci voted on patch set 16 V +1 03/25/25, 13:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76257

  35. Benni Mack uploaded patch set 17 V +1 03/25/25, 14:03

  36. core-ci voted on patch set 17 V +1 03/25/25, 14:12 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76260

  37. Stefan Bürk commented on patch set 18 V +1 03/25/25, 15:35

    Published edit on patch set 17.
  38. core-ci voted on patch set 18 V +1 03/25/25, 15:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76281

  39. Andreas Kienast commented on patch set 18 03/25/25, 16:16

    ProcessedFile.php:182

    We do not need this call anymore at all?

    ResourceFactory.php:88

    x.
  40. Benni Mack uploaded patch set 19 V +1 03/25/25, 16:52

  41. Benni Mack commented on patch set 18 03/25/25, 16:52

    ProcessedFile.php:182 Reply

    thanks. fixed!

    ResourceFactory.php:88 Reply

    Done
  42. core-ci voted on patch set 19 V +1 03/25/25, 17:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76297

  43. Stefan Bürk commented on patch set 19 03/26/25, 09:17

    AbstractFile.php:49

    ```suggestion protected string $name = ''; ``` This should be initialized at least with an empty string. The `AbstractFile` does not set this property in anyway,`File` set it within the constructor which is safe. However, `ProcessedFile` does not and provides a `setName()` method which is itself safe. Calling `getName()` before a name has been set leads to an FatalError. To make this a little bit more safer I would add the empty string default here. What do you think ? https://3v4l.org/lU5Xt

    AbstractFile.php:440

    ```suggestion * @throws \RuntimeException ```

    FolderBasedFileCollection.php:47

    ```suggestion protected bool $recursive = false; ``` Properties not ensured set by an constructor should have a sane default value OR be nullable with a default of null to avoid errors. I suggest to set the default here to false to avoid errors when read access to property happens before setting it. typo3/sysext/core/Classes/Resource/Collection/FolderBasedFileCollection.php Note that this is only an issue when native types are set, without a type there is no vialation.

    ResourceStorage.php:206

    ```suggestion protected DriverInterface $driver, protected array $storageRecord, ``` I guess we could make them CPP and remove the properties + assignments ? What do you think ? (If we are on it going through these classes)
  44. Benni Mack uploaded patch set 20 V +1 03/26/25, 14:20

  1. Benni Mack commented on patch set 19 03/26/25, 14:20

    AbstractFile.php:49 Reply

    Done

    AbstractFile.php:440 Reply

    Done

    FolderBasedFileCollection.php:47 Reply

    Done

    ResourceStorage.php:206 Reply

    Done
  2. core-ci voted on patch set 20 V +1 03/26/25, 14:28 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76388

  3. Stefan Bürk voted on patch set 20 CR +1 V +1 03/27/25, 14:43

  4. Georg Ringer commented on patch set 20 03/27/25, 15:21

    AbstractFile.php:404

    can we add return types as well? also below

    Folder.php:96

    can we rename it to $identifier or $rootIdentifier

    FolderInterface.php:83

    should we keep that?
  5. Oliver Klee commented on patch set 20 03/27/25, 15:50

    FolderInterface.php:65

    This should stay. This allows PHPStan to recognize that this method returns the same instance (instead of any instance of the same class). https://phpstan.org/writing-php-code/phpdoc-types#static-and-%24this
  6. Benni Mack uploaded patch set 21 CR +1 V +1 03/27/25, 15:54

  7. Benni Mack commented on patch set 20 03/27/25, 15:55

    AbstractFile.php:404 Reply

    Done

    Folder.php:96 Reply

    Done

    FolderInterface.php:83 Reply

    Done
  8. core-ci voted on patch set 21 V -1 03/27/25, 16:06 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76478

  9. Benni Mack commented on patch set 21 03/27/25, 16:07

    FolderInterface.php:65 Reply

    feel free to improve
  10. Oliver Klee commented on patch set 21 03/27/25, 16:29

    FolderInterface.php:65 Reply

    Will do when the build is green again.
  11. Benni Mack marked it work in progress 03/27/25, 17:13

  12. Georg Ringer uploaded patch set 22 V -1 03/27/25, 20:16

  13. core-ci voted on patch set 22 V -1 03/27/25, 20:28 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76504

  14. Georg Ringer uploaded patch set 23 V -1 03/31/25, 20:46

  15. core-ci voted on patch set 23 V -1 03/31/25, 21:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76733

  16. Benni Mack uploaded patch set 24 V -1 04/02/25, 05:50

  17. core-ci voted on patch set 24 V +1 04/02/25, 05:56 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76838

  18. Oliver Klee uploaded patch set 25 V +1 04/02/25, 09:37

  19. Oliver Klee commented on patch set 24 04/02/25, 09:37

    FolderInterface.php:65 Reply

    Done
  20. core-ci voted on patch set 25 V -1 04/02/25, 09:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76853

  21. Oliver Klee uploaded patch set 26 V -1 04/02/25, 10:24

  22. core-ci voted on patch set 26 V +1 04/02/25, 10:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/76861

  23. Benni Mack marked it ready for review 04/02/25, 13:48

  24. Georg Ringer voted on patch set 26 CR +2 V +2 04/02/25, 13:54

  25. Georg Ringer merged patch set 27 04/02/25, 13:54