PHP has a special behavior when appending an element to an array where some elements were unset. I spotted a bug in an optimization of https://github.com/GromNaN/php-src/pull/1
array_merge([], $array). Should I submit a PR to fix it?php
$a = [5 => 'x']; unset($a[5]); $r = array_merge([], $a); $r[] = 'y'; var_dump($r); // [6 => 'y'] before, [0 => 'y'] after
- Open the PR on php-src100%, 5 votes
- Close it, nobody care about this subtile behavior0%, 0 votes
5 votesFinal results
GitHubext/standard: Fix array_merge() with an empty array argument by GromNaN · Pull Request #1 · GromNaN/php-srcarray_merge() returns the non-empty argument as is when the other argument is empty, instead of building a copy. This shortcut dates back to commit 05f3706. The shortcut was too broad. The returned...
commit fe37ec1