ILIAS icon indicating copy to clipboard operation
ILIAS copied to clipboard

src/Data: Add `Enum` trait

Open mjansenDatabay opened this issue 2 years ago • 2 comments

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 is public, so the state could be mutated. Unfortunately the readonly modifier, which would solve this issue, will be available with PHP 8.2, where we do not need this trait anymore. So to maintain the encapsulated state we could use a value() method instead.

mjansenDatabay avatar Sep 16 '22 17:09 mjansenDatabay

@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

mjansenDatabay avatar Sep 19 '22 07:09 mjansenDatabay

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.

matthiaskunkel avatar Sep 19 '22 14:09 matthiaskunkel

IMO this can be closed

mjansenDatabay avatar Jan 06 '23 07:01 mjansenDatabay