Repository navigation
Closed
Labels
breaking changeIntroduces or coordinates a breaking changeIntroduces or coordinates a breaking changerefactoringtech debtTechnical debt reductionTechnical debt reduction
Milestone
Description
Summary
Turn the constant classes in the Enums folders that can convert on PHP 8.1 into PHP enums. The adapter types and the remaining classes are in #620, planned for 3.2.0 with PHP 8.2.
Why
An enum gives a closed set of values that PHP and PHPStan check, instead of free strings and integers. A wrong value is caught by the type and not at runtime.
Classes in this ticket
These six are not used in any class constant, property default or parameter default, so nothing blocks them on PHP 8.1:
AuthKeys,ReservedKeys- the database
Type,KeyandRelation Pagination
Things to handle
- An enum case is not its value. Comparisons, array keys and parameters that use the value need
->value, and text that comes from outside needs::from()or::tryFrom(). AuthTraitreadsAuthKeyswithReflectionClass::getConstants(); with an enum that becomesAuthKeys::cases().Paginationmixes string and integer values, and a backed enum has to be all strings or all integers. Decide how to represent it when it is converted.Relationis used in application models ('type' => Relation::BELONGS_TO), in the docs and in the starter project, so update them in step.
Out of scope
- The adapter types,
StatusCode,ContentType,Env,ExitCode: Convert the adapter types and the remaining Enums classes to PHP enums (PHP 8.2) #620. ExceptionMessages, whose classes extend a shared base class.
Breaking changes
- Public constants become enum cases, and the type of some public parameters and return values changes. To be listed in the changelog.
Acceptance criteria
- each class above is converted, or has a recorded reason to stay a constants class
- the starter project, the module templates and the docs examples use the new form
composer test,composer cs:check,composer phpstanandcomposer rector:checkpass on every PHP version in the CI matrix- the changelog lists every converted class
Metadata
Metadata
Assignees
Labels
breaking changeIntroduces or coordinates a breaking changeIntroduces or coordinates a breaking changerefactoringtech debtTechnical debt reductionTechnical debt reduction
Activity
[-]Convert the constant classes in the Enums folders to PHP enums[/-][+]Convert the first batch of Enums classes to PHP enums[/+][#612] Convert ReservedKeys to an enum
[#612] Convert AuthKeys to an enum
[#612] Convert the database Key to an enum
[#612] Convert the Table actions to an enum
[#612] Convert the database Type to an enum
[#612] Convert Relation to an enum
[#612] Convert Pagination to enums
[#612] Add the enum conversion to the changelog
[#612] Accept the column type as text again