Review 12.4 Merged

88510[TASK] Update to PHPStan 2.1.7 with adjusted baseline

Garvin Hicking CR +2 V +2 Normal +11 −71 updated 03/06/25, 18:26

Commit message

Update to PHPStan 2.1.7, which has improved native type
inference and no longer complains about certain hinting via
`@var`. These have been reworked to be actually removed,
as the native inference is preferable.

Executed commands:

```
Build/Scripts/runTests.sh -s composer require --dev \
	phpstan/phpstan:^2.1.7
Build/Scripts/runTests.sh -s phpstanGenerateBaseline
```

Details:
-------

* typo3/sysext/backend/Classes/Preview/StandardPreviewRendererResolver.php:61

`$previewRendererClassName` is natively ensured to be a string now
(technically `$tca['ctrl']['previewRenderer']` could be set to a
non-string)

* typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php:329

`$row` is advertised to be only `false`, but no guarantee for this.
Using an `is_array()` check here safeguards it better and can use
native inference.

* typo3/sysext/core/Tests/Unit/Context/SecurityAspectTest.php:50

Removed test altogether, now just checking for a guaranteed member
property. Was also already touched with #105741 and deemed little
helpful.

* typo3/sysext/extbase/Classes/Reflection/ClassSchema.php:356

Type-hint should be valid and can be kept.

* typo3/sysext/fluid/Classes/ViewHelpers/Link/ActionViewHelper.php:(106|111|121)
* typo3/sysext/fluid/Classes/ViewHelpers/Uri/ActionViewHelper.php:(97|102|112||196|201|211)

Unsure to which it would apply, but annotations are likely valid.

* typo3/sysext/install/Classes/Configuration/FeatureManager.php:53

Due to the `instanceof` check, the type hint can be natively inferred
and be removed.

* typo3/sysext/install/Classes/Configuration/FeatureManager.php:82&116

Can be removed due to return type/return type-hint inference.

Note: Backports to 13.4 and 12.4 will be slightly different.

Review

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

Issues 2

Files 8

Review log 710

  1. Garvin Hicking commented on patch set 1 03/06/25, 12:35

    Cherry Picked from branch main. The following files contain Git conflicts: * Build/phpstan/phpstan-baseline.neon * composer.json * composer.lock * typo3/sysext/core/Tests/Unit/Context/SecurityAspectTest.php
  2. core-ci voted on patch set 1 V -1 03/06/25, 12:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75218

  3. Garvin Hicking uploaded patch set 2 V -1 03/06/25, 12:52

    Adjust to v12
  4. core-ci voted on patch set 2 V -1 03/06/25, 12:58 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75219

  5. Garvin Hicking marked it ready for review 03/06/25, 13:11

  6. Garvin Hicking uploaded patch set 3 V -1 03/06/25, 13:13

    Adjust composer
  7. core-ci voted on patch set 3 V +1 03/06/25, 13:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/75221

  8. Oliver Klee voted on patch set 3 CR +1 V +1 03/06/25, 13:26

  9. Benjamin Franzke voted on patch set 3 CR +2 V +2 03/06/25, 18:02

  10. Benjamin Franzke merged patch set 4 03/06/25, 18:26