Randomizer::pickArrayKeys() has intransparent external behavior
Open
Nobody has claimed this yet.
Extension: random
- Dominant language
- XML
- Stars
- 596
- Forks
- 890
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 55
Description
Description
The following code:
<?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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's reproducible example and the PHP documentation for Randomizer::pickArrayKeys(). Determine whether the differing selections for arrays with identical key-value pairs are expected, then clarify the documented behavior and expected result; no specific file or test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100