Review main Abandoned

94759[TASK] Address PHPStan complaints in Rfc822AddressesParser

Garvin Hicking CR -1 V -1 Normal +11 −48 updated 07/17/26, 06:07

Commit message

Resolves six static analysis errors in the RFC 822 address parser
without adding phpstan-ignore annotations or baseline entries.
Runtime behavior is unchanged; the MailUtility unit tests continue
to pass. Also, the Rfc822AddressesParser remains ancient and
should be subject to axing.

The fixes address incorrect PHPDoc types, dead conditions and a
by-ref out-type that were flagged by PHPStan:

* Corrected the `_validateAddress() @param` to the array shape it
  actually receives instead of string.

* Declared the `@param-out` type of the by-ref `$mailbox` in
  `validateMailbox()`, which is reassigned to a `stdClass`, and guarded
  the caller's error message concatenation accordingly.

* Typed the address iteration source, since PHPStan cannot track that
  `_splitAddresses()` actually populates the property across the method
  boundary.

* Dropped a redundant `?? []` on an always-initialized variable.

* Simplified `_validateDliteral()`, whose second operand only ran on an
  empty `$matches` array and therefore always evaluated to true.

Review

  • Code review CR -1
    • Oliver Klee +1
    • Garvin Hicking -1
    • Simon Schaufelberger +1
  • Verified V -1
    • Oliver Klee +1
    • Garvin Hicking -1
    • Simon Schaufelberger +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2024

  1. Garvin Hicking uploaded patch set 1 07/10/26, 16:59

  2. core-ci voted on patch set 1 V +1 07/10/26, 17:07 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104640

  3. Oliver Klee commented on patch set 1 07/11/26, 11:25

    Rfc822AddressesParser.php:196

    Can we update the PHPDoc annotation of the property instead?
  4. Garvin Hicking commented on patch set 1 07/11/26, 11:49

    Rfc822AddressesParser.php:196 Reply

    Sure, please go ahead to adjust this.
  5. Oliver Klee commented on patch set 2 V +1 07/11/26, 11:55

    Published edit on patch set 1.
  6. Oliver Klee commented on patch set 2 07/11/26, 11:56

    Rfc822AddressesParser.php:196 Reply

    Okay, I've given it a try (from the browser as I'm on the road without a development machine with me).
  7. core-ci voted on patch set 2 V -1 07/11/26, 12:03 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104662

  8. Oliver Klee commented on patch set 2 07/11/26, 12:15

    This reads like a false positive from PHPStan to me. Should we add it to the baseline? WDYT?
  9. Garvin Hicking commented on patch set 2 07/11/26, 13:20

    Reply

    Ah wait now I remember, this was my bulletpoint 3 - definitely a phpstan inability to track the changed property. I'd like to not have a baseline entry so eigher we keeo it like patchset 1 or we add a phphstan-ignore inline. Midterm I'd like to remove this whole class in our domain.
  10. Oliver Klee commented on patch set 2 07/11/26, 16:18

    Reply

    Then let's revert to patchset 1 plus the improved PHPDoc for the property.
  11. Garvin Hicking commented on patch set 3 V -1 07/11/26, 18:17

    Published edit on patch set 2.
  12. Garvin Hicking commented on patch set 4 07/11/26, 18:18

    Published edit on patch set 3.
  13. core-ci voted on patch set 4 V +1 07/11/26, 18:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104664

  14. core-ci voted on patch set 3 V -1 07/11/26, 18:33 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/104663

  15. Oliver Klee voted on patch set 4 CR +1 07/11/26, 18:44

  16. Oliver Klee commented on patch set 4 07/11/26, 18:44

    Reply

    Done
  17. Oliver Klee voted on patch set 4 V +1 07/11/26, 21:23

  18. Simon Schaufelberger voted on patch set 4 CR +1 V +1 07/12/26, 09:06

  19. Markus Klein commented on patch set 4 07/12/26, 09:41

    Rfc822AddressesParser.php:92

    This type repeats 3 times now. I propse to declare a phpstan-type at the top and give this structure a name.

    Rfc822AddressesParser.php:196

    Not sure if we really need this here? We have this exact type at the property now.

    Rfc822AddressesParser.php:764

    Is this really correct? Shouldn't this be `|| $matches[1] !== '\\'`
  20. Oliver Klee commented on patch set 4 07/12/26, 21:31

    Rfc822AddressesParser.php:196 Reply

    Yes, unfortunately PHPStan cannot track this if we have the PHPDoc only for the property. (I tried this in changeset 2.)
  21. Garvin Hicking commented on patch set 4 07/13/26, 06:15

    Rfc822AddressesParser.php:92 Reply Unresolved

    Not sure if it's worth this when I'd like to remove the whole class eventually with a better dependency or implementation. But feel free to do it! :)

    Rfc822AddressesParser.php:764 Reply Unresolved

    I've went through this a couple of time and believed PHPStan was right. The only place this is used has a \\ precondition, but reading it for the fourth time now makes even less sense. Yeah, needs a better explanation because if it's so now I don't see how the method is working at all 🤪
  22. Garvin Hicking commented on patch set 4 CR -1 V -1 07/13/26, 16:43

    Unresolved

    I think the class needs to go now. Will check it out with Benni
  23. Garvin Hicking marked it work in progress 07/13/26, 16:43

  24. Garvin Hicking abandoned the change 07/17/26, 06:07