Skip to content

[DX] Unify the way the key and value are used in closures when accessing collections #541

@KDederichs

Description

@KDederichs

Feature Request

What

First let me say I'm well aware it probably won't happen but it's been bugging me for so long now I wanted to at least mention it...

Currently when you try to operate on collections via, map, filter, findFirst etc. the closure you pass randomly has either the key or the value as first closure parameter and it's driving me nuts to always have to check which it is for the given method.

Why

Unifying it would eliminate that need to check which is the correct parameter order every time saving tons of time.

How

Optimally, you'd probably order it value first and then key for 2 reasons:

  1. First I think accessing the value on those is probably more common than doing something with the key.
  2. It'd probably be easier to migrate? I'm not sure if the collection interfaces are strictly used for doctrine entities, but if they are the value itself could never be some primitive type so it'd be relatively trivial to check and keep BC (?)

I'm aware this is a big change so I don't plan on this to happen anytime soon, if at all, but it would be nice...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions