Skip to content

[TASK] DPL-158: Fix PHPStan level 8 reportings#40

Merged
sbuerk merged 2 commits into
mainfrom
task/DPL-158-fix-phpstan
Jun 30, 2026
Merged

[TASK] DPL-158: Fix PHPStan level 8 reportings#40
sbuerk merged 2 commits into
mainfrom
task/DPL-158-fix-phpstan

Conversation

@sbuerk

@sbuerk sbuerk commented Jun 28, 2026

Copy link
Copy Markdown
Member

What

Makes the PHPStan (level 8) analysis pass cleanly for the single
currently supported TYPO3 version (v13) and corrects stale
runTests.sh help text.

Why

PHPStan reported 49 errors in Classes/, and the Core13 PHPStan
configuration did not even scan the version-specific Core13/
sources (3 further errors once included).

How

  • Classes/ (49 errors) — added missing array value-type
    annotations on parameters/properties/return types, guarded nullable
    and false returns (getRecord(), preg_split(), saveXML(),
    parsed request body), corrected invalid casts and redundant
    null-coalescing, and asserted the concrete RenderingContext
    before calling getRequest(). No behaviour changes.
  • Core13/ analysis — added Core13/ to the analysed paths in
    Build/phpstan/Core13/phpstan.neon and fixed the 3 errors surfaced.
  • Optional lowlevel integration — added typo3/cms-lowlevel to
    require-dev so the event class referenced by the blinding event
    listener resolves during analysis/testing.
  • runTests.sh help text — fixed the TYPO3 default version label
    (1213), the PHP 8.5 label and the -p version list, and
    the examples referencing the no longer supported PHP 8.1.

Verification

  • runTests.sh -s phpstanNo errors
  • runTests.sh -s cgl → no changes needed
  • runTests.sh -s unit → OK
  • runTests.sh -s functional → the 4 errors / 2 failures are
    pre-existing on main (testing-framework dangling error handler;
    basicTest needs DeepL API credentials) and unrelated to this change.

Note

TYPO3 v14 remarks are intentionally left untouched; v14 support is
handled in following steps.

PHPStan at level 8 reported 49 errors in `Classes/`. They are
resolved without behaviour changes by:

* adding the missing array value-type annotations on parameters,
  properties and return types,
* guarding nullable and `false` return values (`getRecord()`,
  `preg_split()`, `saveXML()`, parsed request body),
* correcting invalid casts and redundant null-coalescing, and
* asserting the concrete `RenderingContext` before calling
  `getRequest()` in the site preset ViewHelper.

The Core13 PHPStan configuration only analysed `Classes/` and
`Tests/`, leaving the version specific `Core13/` sources
unchecked. `Core13/` is now added to the analysed paths, which
surfaced and fixes three further errors there.

The optional `EXT:lowlevel` integration references an event class
that is not resolvable without the package, so `typo3/cms-lowlevel`
is added to `require-dev` for static analysis and testing.

Finally the stale `runTests.sh` help text is corrected: the TYPO3
default version label, the PHP `8.5` label and version list, and the
examples that referenced the no longer supported PHP `8.1`.
@sbuerk sbuerk requested a review from calien666 June 28, 2026 19:53
The PHPStan analysis step in the TYPO3 v13 GitHub workflow was
commented out. Now that the codebase passes PHPStan at level 8,
the step is enabled so regressions are caught in CI.
@sbuerk sbuerk merged commit 461ba8b into main Jun 30, 2026
1 check passed
@sbuerk sbuerk deleted the task/DPL-158-fix-phpstan branch June 30, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant