Skip to content

refactor(ScheduleStyle): Convert ScheduleStyle to an enum#1017

Open
JohnVillalovos wants to merge 1 commit intodevelopfrom
jlvillal/phpstan_3
Open

refactor(ScheduleStyle): Convert ScheduleStyle to an enum#1017
JohnVillalovos wants to merge 1 commit intodevelopfrom
jlvillal/phpstan_3

Conversation

@JohnVillalovos
Copy link
Collaborator

This is done so that it will work better with types in the future. Previously it would have to be typed as an int. Now we can type as ScheduleStyle in many places. Not all as sometimes do need to pass the int value.

Copilot AI review requested due to automatic review settings February 15, 2026 07:53
@JohnVillalovos JohnVillalovos marked this pull request as draft February 15, 2026 07:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors ScheduleStyle from a class with public constants to a PHP backed enum (int). This change improves type safety by allowing ScheduleStyle to be used as a proper type hint throughout the codebase instead of being represented as generic integers.

Changes:

  • Converted ScheduleStyle from a class with constants to a backed enum with integer values
  • Updated all method signatures to accept and return ScheduleStyle enum types where appropriate
  • Modified array key references and template usages to access the integer value via ->value property
  • Enhanced type safety in Schedule domain model by properly typing the internal $_defaultStyle property and improving the SetDefaultStyle() method to handle both int and enum inputs

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Domain/Schedule.php Converted ScheduleStyle class to enum, updated Schedule property type and accessor methods to work with enum
Pages/SchedulePage.php Updated interface and implementation to use ScheduleStyle enum in method signatures, modified array keys to use ->value
Pages/ViewSchedulePage.php Updated array keys to use ->value property of enum cases
Pages/ScheduleViewerViewSchedulesPage.php Updated StyleNames array to use enum ->value for keys
Pages/Admin/ManageSchedulesPage.php Updated StyleNames array to use enum ->value for keys
Presenters/Schedule/SchedulePageBuilder.php Updated to convert between int values from database and ScheduleStyle enum instances
WebServices/SchedulesWebService.php Updated method signatures to match interface changes with ScheduleStyle enum types
tpl/Schedule/schedule.tpl Updated template to use ->value property when accessing enum integer values for HTML attributes
tests/Domain/Schedule/ScheduleRepositoryTest.php Updated test to pass integer value when testing SetDefaultStyle
tests/fakes/FakeSchedules.php Updated fake data to use ->value when providing integer for database row
tests/Presenters/SchedulePresenterTest.php Updated mock interface methods to match new ScheduleStyle enum signatures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@JohnVillalovos JohnVillalovos marked this pull request as ready for review February 15, 2026 08:15
This is done so that it will work better with types in the future.
Previously it would have to be typed as an int. Now we can type as
ScheduleStyle in many places. Not all as sometimes do need to pass the
int value.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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