Skip to content

remove iterator flags for EnumMap #70

Closed
@marc-mabe

Description

@marc-mabe

The EnumMap has the following flags to manage how the iterator behaves.

  • KEY_AS_INDEX
  • KEY_AS_NAME
  • KEY_AS_VALUE
  • KEY_AS_ORDINAL
  • CURRENT_AS_ENUM
  • CURRENT_AS_DATA
  • CURRENT_AS_NAME
  • CURRENT_AS_VALUE
  • CURRENT_AS_ORDINAL

In my opinion this makes the class harder to understand and also harder to use because you need to check the current state of flags before actually iterating of it.

As far as I remember the main reason why it was implemented this way is because of the lack of returning an object (the enumerator instance) as key but this restriction has been lifted since PHP-5.5.

So my suggestion would be to return the enumerator instance as key and the attached data as value of the map without performing any changes in behavior.

Thoughts?

@prolic

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions