Crell/enum-comparison

Allow implementing interfaces in enum cases

Closed this issue · 3 comments

Enum Cases may not implement interfaces themselves.

Since we allow implementing methods that are only available in a subset of the cases allowing to implement interfaces only for a subset of cases would probably also make sense.

Crell commented

Not a hill I'll die on either way. Mainly I'm just trying to balance "make enums as powerful as possible" without becoming "there's really no reason to not just use objects". 😄

@iluuu1994, @Crell then I would propose to implement abstract methods to be available for Enum class as well. It might give a possibility to easy control methods implementation for each case w/o introducing new interface:

enum SomeEnum {

    case FirstCase {
        public function color() {}
    }

    case SecondCase {
        public function color() {}
    }

    abstract public function color();
}

This is now irrelevant.