Review main Merged

89252[TASK] Update phpstan to 2.1.14

Anja Leichsenring CR +2 V +2 Easy +25 −19 updated 05/03/25, 06:25

Commit message

EvaluateDisplayConditions is adapted to avoid duplicated checks in
operator conditions which always evaluate to true.

Used commands:

> composer req --dev phpstan/phpstan:^2.1.14
> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
  • Verified V +2 Done
    • Benni Mack +2
    • Benjamin Franzke +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 2025

  1. Anja Leichsenring uploaded patch set 1 04/28/25, 05:24

  2. Andreas Kienast commented on patch set 1 04/28/25, 05:29

    phpstan-baseline.neon:3220

    This smells like a new phpstan bug. Apparently, the types of `$this->pageRenderer` are inspected (which indeed can be `null`), but ignores the fact that the property cannot be `null` under any circumstances at that point.
  3. core-ci voted on patch set 1 V +1 04/28/25, 05:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78259

  4. Anja Leichsenring commented on patch set 1 04/28/25, 05:46

    created a report at phpstan for the GU::makeInstance being null report: https://github.com/phpstan/phpstan/issues/12940
  5. Garvin Hicking commented on patch set 1 04/28/25, 06:08

    EvaluateDisplayConditions.php:323

    we should add 'true' as third param for strictness
  6. Anja Leichsenring commented on patch set 1 04/28/25, 06:10

    EvaluateDisplayConditions.php:323 Reply

    not done in the occurence above, I think we should stay consistent here.
  7. Mathias Brodala commented on patch set 1 04/28/25, 07:48

    EvaluateDisplayConditions.php:323 Reply

    ... and repeat existing faulty code? ;-) I agree that type safety should be enforced for new code. (here) And added to existing code in a separate change. (not here)
  8. Benjamin Franzke commented on patch set 1 04/28/25, 09:13

    EvaluateDisplayConditions.php:323 Reply

    We need to look back at the phpstan error, which is (copied from nightly failure): ``` ------ --------------------------------------------------------------------- Line backend/Classes/Form/FormDataProvider/EvaluateDisplayConditions.php ------ --------------------------------------------------------------------- 324 Strict comparison using === between '!=' and '!=' will always evaluate to true. 🪪 identical.alwaysTrue ``` It reported that `!=` will always be `!=`, because phpstan performed dead-code elimination based on the previous in_array checks and noticed: the value can actually only be one of the four and therefore reports the last of these four checks as alwaysTrue. This effectively means this entire `elseif` condition is unneeded and *could* actually just be an `else` without a condition because all allowed values are checked in line 271, and all other values are alread "eliminated"/handled in earlier conditions. So I'd say: Raise the phpstan baseline for the sake of simplicity or move the exception from line 273 into an else branch to avoid duplicated value checks. I'd probably do the latter for main only.
  9. Benjamin Franzke commented on patch set 1 04/28/25, 09:16

    EvaluateDisplayConditions.php:323 Reply

    btw, regarding the change to `in_array`: transforming the previous strict condition into a non-strict condition, just to make phpstan "happy" (making it beleive it could also be some other value that loosely matches) is not a good option.
  10. Anja Leichsenring uploaded patch set 2 V +1 04/28/25, 13:26

  11. Anja Leichsenring commented on patch set 2 04/28/25, 13:32

    EvaluateDisplayConditions.php:323 Reply

    I introduced the strict comparison now. Moving the exception would lead to additional calculation, because in front of all the `ifs` it already answers any invalid inputs. Putting it into the else branch would mean testing for all the branches before, which is unneccesary. Simplifying the last elseif to a pure else would work, but this is something for main only I guess.
  12. core-ci voted on patch set 2 V +1 04/28/25, 13:33 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78279

  13. Benjamin Franzke uploaded patch set 3 V +1 04/29/25, 09:02

  14. Benjamin Franzke commented on patch set 3 04/29/25, 09:02

    phpstan-baseline.neon:3220 Reply

    Yes, @aleichsenring@ab-softlab.de already reported that upstream: https://github.com/phpstan/phpstan/issues/12940 There were even more reports in the meantime which basically report the same: https://github.com/phpstan/phpstan/issues/12946 https://github.com/phpstan/phpstan/issues/12947 I think we should wait a day or two to see if an upstream bugfix release is shipped that fixes this issue.

    EvaluateDisplayConditions.php:323 Reply

    Yes, that's what I described as well, but the fix still worked around the phpstan finding, by combining strict and non-strict in-array checks. I've reworked this to move the exception into an else branch for main-only. Let's raise the baseline for the backports.
  15. core-ci voted on patch set 3 V -1 04/29/25, 09:08 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78336

  16. Benjamin Franzke commented on patch set 3 04/29/25, 09:13

    phpstan-baseline.neon:3220 Reply

    Btw, this is the change that likely introduced this problem. The author already reacted and noticed that the release is broken: https://github.com/phpstan/phpstan-src/pull/3945#issuecomment-2835657783 He is working on a fix in https://github.com/phpstan/phpstan-src/pull/3965
  17. Benjamin Franzke uploaded patch set 4 V -1 04/29/25, 09:21

  18. core-ci voted on patch set 4 V +1 04/29/25, 09:27 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78337

  19. Christian Kuhn voted on patch set 4 CR +1 V +1 04/30/25, 11:32

  20. Oliver Klee voted on patch set 4 V +1 04/30/25, 12:05

  21. Benjamin Franzke uploaded patch set 5 CR +1 V +1 05/03/25, 04:24

  22. Benjamin Franzke commented on patch set 5 05/03/25, 04:24

    phpstan-baseline.neon:3220 Reply

    The regression has been fixed via mentioned PR upstream. We're good to merge (2.1.14) now. Thanks for waiting everyone.
  23. core-ci voted on patch set 5 V +1 05/03/25, 04:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/78456

  24. Benni Mack voted on patch set 5 CR +2 V +2 05/03/25, 06:25

  25. Benni Mack merged patch set 6 05/03/25, 06:25