Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jmwebservices opened this issue Aug 5, 2020 · 0 comments
Closed

Comments

@jmwebservices
Copy link

jmwebservices commented Aug 5, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant