Add findKey() method to return index of first element matching a callable#153
Merged
Add findKey() method to return index of first element matching a callable#153
findKey() method to return index of first element matching a callable#153Conversation
…t via callable Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/9727c001-36d7-4c06-865e-c0a76fd5012f Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/9727c001-36d7-4c06-865e-c0a76fd5012f Co-authored-by: voku <264695+voku@users.noreply.github.com>
Owner
|
@copilot run build/generate_docs.php and create a AGENTS.md file afterwards where you put your knowlage about this project and your findings from this task + put the new markdown file into .gitattributes so that we do not distribute it via composer |
… update .gitattributes Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/f018d0bd-6d0f-42fb-bc9f-526de3787dd6 Co-authored-by: voku <264695+voku@users.noreply.github.com>
Contributor
Author
Done in commit f13314f:
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No method existed to find the index/key of an array element by predicate — only
find()(returns value) andsearchIndex()(requires exact value match).Changes
src/Arrayy.php: AddedfindKey(\Closure $closure)— iterates via generator, returns the key of the first element where$closure($value, $key)is truthy, orfalseif none match.tests/ArrayyTest.php: AddedfindKeyProvider()data provider +testFindKey()(value-based matching across int/string/bool/float/assoc cases) +testFindKeyWithKeyParameter()(verifies$keyis correctly forwarded to the closure).README.md: Regenerated viabuild/generate_docs.phpto includefindKeyin the method table and docs section.AGENTS.md: Created a knowledge base documenting project architecture, conventions, how to run tests, how to regenerate docs, and findings from this task. Added to.gitattributesasexport-ignoreso it is not distributed via Composer.Example
This change is
This change is