Skip to content

Commit b020a29

Browse files
committed
Fixed result from map() method when keys are strings
1 parent 7115eae commit b020a29

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3110,9 +3110,9 @@ public function map( callable $callback ) : self
31103110
{
31113111
$list = $this->list();
31123112
$keys = array_keys( $list );
3113-
$elements = array_map( $callback, $list, $keys );
3113+
$map = array_map( $callback, array_values( $list ), $keys );
31143114

3115-
return new static( array_combine( $keys, $elements ) ?: [] );
3115+
return new static( array_combine( $keys, $map ) );
31163116
}
31173117

31183118

@@ -3890,7 +3890,7 @@ public function reject( $callback = true ) : self
38903890
{
38913891
$isCallable = $callback instanceof \Closure;
38923892

3893-
return new static( array_filter( $this->list(), function( $value, $key ) use ( $callback, $isCallable ) {
3893+
return new static( array_filter( $this->list(), function( $value, $key ) use ( $callback, $isCallable ) {
38943894
return $isCallable ? !$callback( $value, $key ) : $value != $callback;
38953895
}, ARRAY_FILTER_USE_BOTH ) );
38963896
}

0 commit comments

Comments
 (0)