Skip to content

chore(phpstan): enable level 4 for lib/Application/ - #1889

Merged
JohnVillalovos merged 1 commit into
developfrom
jlvillal/phpstan
Nov 9, 2026
Merged

JohnVillalovos merged 1 commit into
developfrom
jlvillal/phpstan

Conversation

@JohnVillalovos

Copy link
Copy Markdown
Collaborator

Fix the level 4 findings in lib/Application/ and remove it from the phpstan_next exclude list:

  • Remove dead code: unreachable returns and three unused private methods in DisplaySlotFactory, and the never-called IReservationComponentInitializer::AddAttribute() with the attribute list it filled.
  • Drop write-only properties: ExistingReservationInitializer's page, ReservationInitializerFactory's user repository, ScheduleReservationList's midnight and CalendarWeek's timezone (along with its now unused constructor argument).
  • Simplify "!A || (A && B)" to "!A || B" in AttributeService and drop redundant checks in ResourceImportCsv and AccessoryResourceRule.
  • Mark ReservationItemView's title, description and owner phone, organization and position as nullable; they come from nullable columns, which is why callers guard them with "?? ''".
  • Correct the PHPDoc type of ReportCell::$chartColumnType.

Assisted-by: Claude:claude-opus-5-5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The nullable title can still violate the interface’s string contract and propagate a null reservation label, so the active moderate finding requires a boundary or contract fix.

1 open issue
What changed in this PR

This pull request enables PHPStan level 4 analysis for lib/Application/ by removing dead code and unused state, simplifying redundant conditions, and correcting type annotations.

Changes:

  • Removes lib/Application/ from the PHPStan exclusion list.
  • Deletes unreachable code, unused methods, properties, constructor parameters, and the unused attribute API.
  • Simplifies redundant checks and boolean expressions.
  • Corrects nullable reservation fields and the ReportCell::$chartColumnType PHPDoc.

Review finding: Domain/ReservationItemView.php has a moderate issue (2 votes): GetTitle() may return null despite the IReservedItemView contract promising string. The contract should allow null, or the title should be normalized to '' at the boundary.

File Description
phpstan_next.neon Removes lib/Application/ from the PHPStan exclusion list.
lib/​Application/​Schedule/​ScheduleReservationList.php Removes the unused midnight property and initialization.
lib/​Application/​Schedule/​DisplaySlotFactory.php Removes unreachable returns and unused helper methods.
lib/​Application/​Schedule/​CalendarWeek.php Removes unused timezone state and its constructor argument.
lib/​Application/​Schedule/​CalendarMonth.php Updates CalendarWeek construction for the simplified constructor.
lib/​Application/​Reservation/​Validation/​AccessoryResourceRule.php Removes a redundant null comparison.
lib/​Application/​Reservation/​ReservationInitializerFactory.php Removes unused user repository state.
lib/​Application/​Reservation/​ReservationInitializerBase.php Removes the unused AddAttribute() API and backing storage.
lib/​Application/​Reservation/​ExistingReservationInitializer.php Removes the unused page property.
lib/​Application/​Reporting/​ReportColumn.php Corrects the chartColumnType PHPDoc type.
lib/​Application/​Attributes/​AttributeService.php Simplifies redundant boolean expressions.
lib/​Application/​Admin/​ResourceImportCsv.php Removes a redundant CSV-row guard.
Domain/​ReservationItemView.php Documents nullable reservation and owner fields; title contract handling remains unresolved.

Review effort: Lite

Comment thread Domain/ReservationItemView.php Resolved
Fix the level 4 findings in lib/Application/ and remove it from the
phpstan_next exclude list:

- Remove dead code: unreachable returns and three unused private
  methods in DisplaySlotFactory, and the never-called
  IReservationComponentInitializer::AddAttribute() with the attribute
  list it filled.
- Drop write-only properties: ExistingReservationInitializer's page,
  ReservationInitializerFactory's user repository,
  ScheduleReservationList's midnight and CalendarWeek's timezone
  (along with its now unused constructor argument).
- Simplify "!A || (A && B)" to "!A || B" in AttributeService and drop
  redundant checks in ResourceImportCsv and AccessoryResourceRule.
- Mark ReservationItemView's title, description and owner phone,
  organization and position as nullable; they come from nullable
  columns, which is why callers guard them with "?? ''".
- Correct the PHPDoc type of ReportCell::$chartColumnType.

Assisted-by: Claude:claude-opus-5-5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes remove dead and redundant code while correcting nullable contracts and PHPDoc types needed to enable PHPStan level 4 analysis for the application layer.

No open issues 🎉

1 resolved since last review

Review effort: Lite

@JohnVillalovos
JohnVillalovos merged commit 5a75bf0 into develop Nov 9, 2026
18 checks passed
@JohnVillalovos
JohnVillalovos deleted the jlvillal/phpstan branch November 9, 2026 23:42
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.

2 participants