Skip to content

Arrays::renameKey() incorrect replacement for existing new keys. #230

Description

@jmwebservices

Version: 3.1

Bug Description

When $newKey exsits in $array and is positioned after $oldKey, Arrays::renameKey() preserves the value of $newKey over the value of $oldKey.

Steps To Reproduce

use Nette\Utils\Arrays;

$array  = [ 0 => 0, 1 => 1 ];
$oldKey = 0;
$newKey = 1;
$renamedArray = [ $newKey => $array[ $oldKey ] ];

Arrays::renameKey( $array, $oldKey, $newKey );

var_dump( $array === $renamedArray ); // bool(false)

Expected Behavior

bool(true)

Possible Solution

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions