Review main Merged

93027[TASK] phpstan: do not treatPhpDocTypesAsCertain

Benni Mack CR +2 V +2 Hard +75 −206 updated 03/04/26, 15:52

Commit message

This change disables the option "treatPhpDocTypesAsCertain"
for core. Our baseline contains 86 entries instead of 118 now.

Why should we do this?

1. We don't have strict / native PHP types everywhere, and thus
need to check for e.g. "is_array()" even though the type hint
says "@param array". This is a breaking change if we'd change
this but right now "not a bug" for us.

2. "non-empty-string" options are currently not helpful for TYPO3
as a framework, as we expect a "non-empty-string" but user-land
code might still hand in an empty string so we do need to check for
such cases.

3. narrowed types such as "$this->avatarProviders" being
"AvatarProviderInterface[]" cannot be natively typed in some
cases, and should thus be a help for the IDE but not an exception
in TYPO3's phpstan baseline.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Oliver Klee +1
    • Garvin Hicking +1
  • Verified V +2 Done
    • Benni Mack +2
    • Oliver Klee +1
    • Garvin Hicking +1
    • core-ci +1 CI

Issues 1

Files 7

Review log 1418

  1. Benni Mack uploaded patch set 1 02/27/26, 16:25

  2. Benni Mack marked it work in progress 02/27/26, 16:26

  3. Benni Mack updated the commit message in patch set 2 02/27/26, 16:28

  4. core-ci voted on patch set 2 V +1 02/27/26, 16:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96981

  5. core-ci voted on patch set 1 V +1 02/27/26, 17:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/96980

  6. Benjamin Franzke commented on patch set 2 CR +1 03/03/26, 16:40

    Checked with phpstan level max: `treatPhpDocTypesAsCertain: false`: 60810 errors `treatPhpDocTypesAsCertain: true`: 60856 errors Looks good 👍 Also note: Some years ago (last time I tested it was 2023), `treatPhpDocTypesAsCertain: false` caused PHP API to produce false negatives. Example from back than which works today: https://phpstan.org/r/af3e55da-b4d6-48c1-ae07-1a812e7aa41a I would be fine with merging this.
  7. Benni Mack commented on patch set 2 03/03/26, 17:00

    Reply

    we can add some comments above the "phpstan.neon" file so we know why we do this?
  8. Benni Mack commented on patch set 3 CR +1 V +1 03/04/26, 12:53

    Published edit on patch set 2.
  9. Benni Mack marked it ready for review 03/04/26, 12:53

  10. Benni Mack commented on patch set 3 03/04/26, 12:53

    Reply

    Done
  11. core-ci voted on patch set 3 V -1 03/04/26, 13:01 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97318

  12. Benni Mack uploaded patch set 4 V -1 03/04/26, 13:08

  13. core-ci voted on patch set 4 V +1 03/04/26, 13:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/97321

  14. Garvin Hicking commented on patch set 4 CR +1 V +1 03/04/26, 14:01

    gg
  15. Oliver Klee voted on patch set 4 CR +1 V +1 03/04/26, 15:41

  16. Oliver Klee commented on patch set 4 03/04/26, 15:41

    Yeah, makes sense.
  17. Benni Mack voted on patch set 4 CR +2 V +2 03/04/26, 15:52

  18. Benni Mack merged patch set 5 03/04/26, 15:52