Closed
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request converts the ScheduleStyle class from using public constants to a backed PHP enum (enum ScheduleStyle: int), improving type safety throughout the codebase. The change allows schedule style to be typed as ScheduleStyle in many places instead of ambiguous int/string types, while maintaining backward compatibility with integer storage in the database and cookies.
Changes:
- Converted
ScheduleStylefrom a class with public constants to a backed enum with integer values - Updated method signatures to use proper
ScheduleStyletypes with nullable return types where appropriate - Modified array keys in style mappings to use
->valuefor integer keys - Updated template expressions to access enum values using
->valuesyntax
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Domain/Schedule.php | Converted ScheduleStyle to backed enum, updated property type to ScheduleStyle, modified getter to return int and setter to accept int|ScheduleStyle |
| Pages/SchedulePage.php | Updated interface and implementation method signatures to use ScheduleStyle types, modified cookie handling to convert between int and enum |
| Pages/ViewSchedulePage.php | Updated style mapping array keys to use enum->value |
| Pages/ScheduleViewerViewSchedulesPage.php | Updated style names array keys to use enum->value |
| Pages/Admin/ManageSchedulesPage.php | Updated style names array keys to use enum->value |
| Presenters/Schedule/SchedulePageBuilder.php | Added enum conversion logic using tryFrom() with fallback to Standard |
| WebServices/SchedulesWebService.php | Updated method signatures to use ScheduleStyle types |
| tests/Presenters/SchedulePresenterTest.php | Updated test mock to return enum and accept enum parameter |
| tests/Domain/Schedule/ScheduleRepositoryTest.php | Updated test to use enum->value for int storage |
| tests/fakes/FakeSchedules.php | Updated fake data to use enum->value |
| tpl/Schedule/schedule.tpl | Updated template expressions to access enum values using ->value |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
a971cb3 to
7d04b8d
Compare
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.
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.