Repository navigation
chore(phpstan): enable level 4 for lib/ helpers, Pages/ and installer - #1883
Merged
Merged
Conversation
Fix the level 4 findings in lib/Common, lib/Config, lib/Database, lib/Email, Pages/ and Web/install, and remove them from the phpstan_next exclude list. None of them changes behaviour: - Drop properties that are written but never read: SqlCommand's parameter name and value copies and ReservationWaitlistPage's save flag (the waitlist presenter never reports a save result). - Drop the primaryResource parameter of ReservationEmailTemplateContext and the userRepository parameter of ReservationCreatedEmailAdmin and ReservationRequiresApprovalEmailAdmin. Both became unused when the email context switched to AllResources() in 0ae98b6. - Remove checks that can never fail: is_array() on debug_backtrace(), is_null() on a Date parameter, method_exists() on ConfigKeys methods that AbstractConfigKeys always defines, and duplicate '' / false comparisons. - Make ExceptionHandler::$handler nullable instead of relying on isset(), and declare the real return types of the installer permission check and the rich text attribute sanitizer. - Document that legacy config files fill in $conf through require, so PHPStan no longer treats the 'settings' check as impossible. Assisted-by: Claude:claude-opus-5-5
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, with the reported PHPStan findings resolved and corresponding exclusions removed across the affected code and tests.
No open issues 🎉
What changed in this PR
This pull request enables PHPStan level 4 for selected helpers, pages, email components, and installer code by resolving reported findings and removing the corresponding exclusions.
Changes:
- Removes unused properties and constructor parameters.
- Simplifies redundant or unreachable checks.
- Adds explicit return and nullable type declarations.
- Documents legacy configuration mutation through
require. - Updates affected tests and PHPStan exclusions.
| File | Description |
|---|---|
Web/install/index.php |
Declares the installer permission helper’s boolean return type. |
tests/lib/Email/Messages/ReservationEmailMessageTest.php |
Updates email construction after removing an unused dependency. |
tests/Application/Reservation/ReservationEmailTemplateContextTest.php |
Updates context construction after removing an unused parameter. |
tests/Application/Reservation/AdminEmailNotificationTest.php |
Updates expected admin email construction for simplified constructors. |
phpstan_next.neon |
Removes resolved paths from the PHPStan exclusion list. |
Pages/SchedulePage.php |
Removes a redundant empty-string comparison. |
Pages/Ajax/ReservationWaitlistPage.php |
Removes unused save-state storage and keeps the setter as a no-op. |
lib/Email/Messages/ReservationRequiresApprovalEmailAdmin.php |
Removes an unused user repository parameter. |
lib/Email/Messages/ReservationEmailTemplateContext.php |
Removes an unused primary-resource parameter. |
lib/Email/Messages/ReservationEmailMessage.php |
Adjusts context construction for the simplified signature. |
lib/Email/Messages/ReservationCreatedEmailAdmin.php |
Removes unused repository state and constructor input. |
lib/Database/SqlCommand.php |
Removes unused parameter copies and a redundant comparison. |
lib/Config/MigrateConfig.php |
Documents legacy configuration mutation through require. |
lib/Config/Configurator.php |
Documents legacy config loading and simplifies guaranteed method calls. |
lib/Config/Configuration.php |
Documents legacy configuration mutation through require. |
lib/Common/Security/RichTextHtmlSanitizer.php |
Adds concrete array return types to sanitizer methods. |
lib/Common/Logging/Log.php |
Removes an impossible debug_backtrace() array check. |
lib/Common/Logging/ExceptionHandler.php |
Makes the static handler explicitly nullable. |
lib/Common/Date.php |
Removes an impossible null branch for a non-nullable date parameter. |
lib/Application/Reservation/Notification/AdminEmailNotification.php |
Updates notification message construction for simplified email constructors. |
Review effort: Lite
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.
Fix the level 4 findings in lib/Common, lib/Config, lib/Database, lib/Email, Pages/ and Web/install, and remove them from the phpstan_next exclude list. None of them changes behaviour:
Assisted-by: Claude:claude-opus-5-5