[TASK] DPL-158: Fix PHPStan level 8 reportings#40
Merged
Conversation
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`.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the PHPStan (level 8) analysis pass cleanly for the single
currently supported TYPO3 version (v13) and corrects stale
runTests.shhelp text.Why
PHPStan reported 49 errors in
Classes/, and the Core13 PHPStanconfiguration did not even scan the version-specific
Core13/sources (3 further errors once included).
How
Classes/(49 errors) — added missing array value-typeannotations on parameters/properties/return types, guarded nullable
and
falsereturns (getRecord(),preg_split(),saveXML(),parsed request body), corrected invalid casts and redundant
null-coalescing, and asserted the concrete
RenderingContextbefore calling
getRequest(). No behaviour changes.Core13/analysis — addedCore13/to the analysed paths inBuild/phpstan/Core13/phpstan.neonand fixed the 3 errors surfaced.typo3/cms-lowleveltorequire-devso the event class referenced by the blinding eventlistener resolves during analysis/testing.
runTests.shhelp text — fixed the TYPO3 default version label(
12→13), the PHP8.5label and the-pversion list, andthe examples referencing the no longer supported PHP
8.1.Verification
runTests.sh -s phpstan→ No errorsrunTests.sh -s cgl→ no changes neededrunTests.sh -s unit→ OKrunTests.sh -s functional→ the 4 errors / 2 failures arepre-existing on
main(testing-framework dangling error handler;basicTestneeds DeepL API credentials) and unrelated to this change.Note
TYPO3 v14 remarks are intentionally left untouched; v14 support is
handled in following steps.