Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayExtension preserves keys #7

Open
wants to merge 4 commits into
base: 0.1.x
Choose a base branch
from
Open

Conversation

mecha
Copy link
Member

@mecha mecha commented Jun 22, 2021

Fixes #6

@mecha mecha added the bug Something isn't working label Jun 22, 2021
@mecha mecha requested a review from XedinUnknown June 22, 2021 12:31
@mecha mecha self-assigned this Jun 22, 2021
@XedinUnknown
Copy link
Member

Is this really better than just array_map()?

Not quite sure. Maybe, resolveDeps() should return a map with keys preserved, and it's just a matter of array_values() to turn it into function args?

@XedinUnknown XedinUnknown added this to Backlog in Project Management via automation Jun 23, 2021
@XedinUnknown XedinUnknown moved this from Backlog to In Progress in Project Management Jun 23, 2021
@XedinUnknown XedinUnknown moved this from In Progress to In Review in Project Management Jun 23, 2021
@mecha
Copy link
Member Author

mecha commented Jun 24, 2021

That would work. I wanted to keep the current resolveDeps() because I can see its utility. Given ["foo", "bar"] it returns ["foo" => ..., "bar" => ...], which makes a lot of sense. This is why I added a new method. A consumer may want to access the services by their key after passing them through resolveDeps().

On the other hand, there is nothing that is currently utilizing the service keys in the resolveDeps() return value. And realistically, there may not be. Given that this trait is used for service helpers, it's unlikely that individual services will be extracted from the returned array. So it could be changed to preserve the keys in the argument array.

But if we're going to do that, I think we could just use array_map. The immediately-invoked function and the creation of a Generator becomes obsolete and unnecessary.

Project Management automation moved this from In Review to Reviewed Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging this pull request may close these issues.

ArrayExtension does not preserve keys
2 participants