ILIAS
ILIAS copied to clipboard
src/Data: Add `Enum` trait
This PR suggests a trait
to emulate an (backed) Enum
type for PHP < 8.1.
@klees suggested to add this trait
to src/Data
after @thibsy, @klees and @mjansenDatabay discussed this approach in Discord
.
Of course it only makes sence if this trait
is really used for ILIAS 9
. I am confident that usages can be migrated to a native Enum
with rector
later on.
To discuss:
- The
value
property ispublic
, so the state could be mutated. Unfortunately thereadonly
modifier, which would solve this issue, will be available with PHP 8.2, where we do not need thistrait
anymore. So to maintain the encapsulated state we could use avalue()
method instead.
@klees
thx a bunch! I would opt for a value()-method, so we do not throw away the guarantees that this will give.
Done
Would you present this on todays JF so people become aware and use this?
Yes
Jour Fixe, 19 SEP 2022 : Facing the changed timeline for ILIAS 9 we have to discuss again the required software for ILIAS 9 and the supported PHP versions. Probably, we do not support PHP 8.0 with ILIAS 9 and therefore do not need this emulation of enum. Decision will be made on the next TB meeting.
IMO this can be closed