Skip to content

Commit

Permalink
Added "see also" sections for map()/rekey()/transform()
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Oct 24, 2024
1 parent 3434897 commit 331a134
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,11 @@ map( function() {
} );
```

**See also:**

* [rekey()](#rekey) - Changes the keys according to the passed function
* [transform()](#transform) - Creates new key/value pairs using the passed function and returns a new map for the result


### __construct()

Expand Down Expand Up @@ -4144,6 +4149,11 @@ Map::from( ['a' => 2, 'b' => 4] )->rekey( function( $value, $key ) {
// ['key-a' => 2, 'key-b' => 4]
```

**See also:**

* [map()](#map) - Maps new values to the existing keys using the passed function and returns a new map for the result
* [transform()](#transform) - Creates new key/value pairs using the passed function and returns a new map for the result


### remove()

Expand Down Expand Up @@ -5550,6 +5560,11 @@ Map::from( ['la' => 2, 'le' => 4, 'li' => 6] )->transform( function( $value, $ke
// ['l' => 12]
```

**See also:**

* [map()](#map) - Maps new values to the existing keys using the passed function and returns a new map for the result
* [rekey()](#rekey) - Changes the keys according to the passed function


### transpose()

Expand Down
6 changes: 6 additions & 0 deletions src/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -2853,6 +2853,8 @@ public function ltrim( string $chars = " \n\r\t\v\x00" ) : self
*
* @param callable $callback Function with (value, key) parameters and returns computed result
* @return self<int|string,mixed> New map with the original keys and the computed values
* @see rekey() - Changes the keys according to the passed function
* @see transform() - Creates new key/value pairs using the passed function and returns a new map for the result
*/
public function map( callable $callback ) : self
{
Expand Down Expand Up @@ -3653,6 +3655,8 @@ public function reject( $callback = true ) : self
*
* @param callable $callback Function with (value, key) parameters and returns new key
* @return self<int|string,mixed> New map with new keys and original values
* @see map() - Maps new values to the existing keys using the passed function and returns a new map for the result
* @see transform() - Creates new key/value pairs using the passed function and returns a new map for the result
*/
public function rekey( callable $callback ) : self
{
Expand Down Expand Up @@ -5029,6 +5033,8 @@ public function toUrl() : string
*
* @param \Closure $callback Function with (value, key) parameters and returns an array of new key/value pair(s)
* @return self<int|string,mixed> New map with the new key/value pairs
* @see map() - Maps new values to the existing keys using the passed function and returns a new map for the result
* @see rekey() - Changes the keys according to the passed function
*/
public function transform( \Closure $callback ) : self
{
Expand Down

0 comments on commit 331a134

Please sign in to comment.