Hi all,
I got a case where I have to create multiple different formatters and
also I want to define the possible tokens of each formatter accessible
in specific groups using enums.
During that task I'm wondering why it's not possible to create an inline
enum definition similar to an anonymous class object?
Example:
class MyFormatter {
public const DATE_TOKEN = enum:string {
case DayOfMonth = 'j';
// ...
};
public const TIME_TOKEN = enum:string {
case Hour = 'h';
// ...
};
}
class AnotherFormatter {
public const DATE_TOKEN = enum:string {
case DayOfMonth = 'd';
// ...
};
public const TIME_TOKEN = enum:string {
case Hour = 'h';
// ...
};
}
$token = MyFormatter::DATE_TOKEN::DayOfMonth;
$token instanceof MyFormatter::DATE_TOKEN;
What do you think?
Does that make sense?
Is that implementable?
Marc