[php-src] Issue #9202: Randomizer::pickArrayKeys() has intransparent external behavior
| From: | TimWolla | Date: | Sat, 30 Jul 2022 09:53:37 +0000 |
| Subject: | [php-src] Issue #9202: Randomizer::pickArrayKeys() has intransparent external behavior | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242081@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9202
Author: TimWolla
### Description
The following code:
```php
<?php
$r1 = new Random\Randomizer(new Random\Engine\Xoshiro256StarStar(1));
$r2 = new Random\Randomizer(new Random\Engine\Xoshiro256StarStar(1));
$a = [ 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4,
'e' => 5, 'f' => 6, ];
unset($a['b']);
$b = [ 'a' => 1, 'c' => 3, 'd' => 4, 'e' => 5,
'f' => 6, ];
var_dump($a === $b); // bool(true)
var_dump(
$r1->pickArrayKeys($a, 1), // [ 0 => 'e' ]
$r2->pickArrayKeys($b, 1), // [ 0 => 'd' ]
);
```
Resulted in this output:
```
bool(true)
array(1) {
[0]=>
string(1) "e"
}
array(1) {
[0]=>
string(1) "d"
}
```
But I expected this output instead:
The same key selected, because the arrays are identical.
### PHP Version
Current git master
### Operating System
_No response_