Skip to content

Add Arrays::mapKeys - #60

Merged
frankdekker merged 5 commits into
masterfrom
Add-arrays-map-key
Jan 19, 2026
Merged

Add Arrays::mapKeys#60
frankdekker merged 5 commits into
masterfrom
Add-arrays-map-key

Conversation

@frankdekker

Copy link
Copy Markdown
Member

Adds Arrays::mapKeys which transforms the keys of an array to a new key

Example

$data = ['FOO' => true, 'BAR' => false];
$data = Arrays::mapKeys($data, static fn(string $key): string => strtolower($key));
// output: ['foo' => true, 'bar' => false]

Copilot AI review requested due to automatic review settings January 17, 2026 12:39
@frankdekker frankdekker changed the title Add arrays map key Add Arrays::mapKeys key Jan 17, 2026
@frankdekker frankdekker changed the title Add Arrays::mapKeys key Add Arrays::mapKeys Jan 17, 2026
@frankdekker
frankdekker requested a review from bram123 January 17, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Arrays::mapKeys method that transforms the keys of an array while preserving the values. The function accepts an iterable and a callback that transforms each key, supporting use cases like normalizing key casing.

Changes:

  • Added Arrays::mapKeys() method with PHPDoc documentation and example
  • Added comprehensive test coverage in testMapKeys()
  • Updated README.md to document the new method

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Arrays.php Implements the new mapKeys() method with template type annotations for type safety
tests/Unit/ArraysTest.php Adds unit tests covering empty arrays, basic key transformation, and ArrayIterator support
README.md Documents the new mapKeys method in the Arrays section

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Arrays.php
Comment thread README.md Outdated
@frankdekker
frankdekker merged commit 95d9e78 into master Jan 19, 2026
12 checks passed
@frankdekker
frankdekker deleted the Add-arrays-map-key branch January 19, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants