{"action":"created","issue":{"url":"https://api.github.com/repos/php/php-src/issues/4175","repository_url":"https://api.github.com/repos/php/php-src","labels_url":"https://api.github.com/repos/php/php-src/issues/4175/labels{/name}","comments_url":"https://api.github.com/repos/php/php-src/issues/4175/comments","events_url":"https://api.github.com/repos/php/php-src/issues/4175/events","html_url":"https://github.com/php/php-src/pull/4175","id":445582879,"node_id":"MDExOlB1bGxSZXF1ZXN0MjgwMDA0NTMx","number":4175,"title":"Allow calling array_merge / array_merge_recursive without arguments","user":{"login":"dtakken","id":2066447,"node_id":"MDQ6VXNlcjIwNjY0NDc=","avatar_url":"https://avatars2.githubusercontent.com/u/2066447?v=4","gravatar_id":"","url":"https://api.github.com/users/dtakken","html_url":"https://github.com/dtakken","followers_url":"https://api.github.com/users/dtakken/followers","following_url":"https://api.github.com/users/dtakken/following{/other_user}","gists_url":"https://api.github.com/users/dtakken/gists{/gist_id}","starred_url":"https://api.github.com/users/dtakken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtakken/subscriptions","organizations_url":"https://api.github.com/users/dtakken/orgs","repos_url":"https://api.github.com/users/dtakken/repos","events_url":"https://api.github.com/users/dtakken/events{/privacy}","received_events_url":"https://api.github.com/users/dtakken/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-05-17T19:20:36Z","updated_at":"2019-05-17T19:26:42Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/php/php-src/pulls/4175","html_url":"https://github.com/php/php-src/pull/4175","diff_url":"https://github.com/php/php-src/pull/4175.diff","patch_url":"https://github.com/php/php-src/pull/4175.patch"},"body":"The [array_merge](https://www.php.net/manual/en/function.array-merge.php) and [array_merge_recursive](https://www.php.net/manual/en/function.array-merge-recursive.php) functions require at least one argument. That requirement was relevant until version 5.6, because calling it without any arguments made no sense. But with argument unpacking syntax we can use the spread operator for merging multiple arrays:\r\n\r\n```php\r\narray_merge(...$arrays);\r\narray_merge_recursive(...$arrays);\r\n```\r\n\r\nUsing array_merge or array_merge_recursive in this way requires checking that the list of arrays is not empty. Failing to do so may give you null in stead of an array, as well as a warning. This introduces a corner case that gives rise to bugs. A work-around like this appears to be popular:\r\n\r\n```php\r\narray_merge([], ...$arrays)\r\n```\r\n\r\nThe proposed change makes both array_merge and array_merge_recursive return an empty array when called without arguments, making the use of the spread operator a lot more convenient. A similar issue was fixed by #https://github.com/php/php-src/pull/3011 for the array_push and array_unshift functions in PHP 7.3. Back then, @nikic already hinted at fixing array_merge and array_merge_recursive in the same way, which is what this PR intends to do.\r\n\r\nJust like with the change of array_push, changing array_merge causes a minor BC break for the return value. Using the spread operator to merge an empty list of arrays will now return an empty list in stead of returning null. The BC break for array_merge has slightly more impact though, because the result of the merge is provided by means of the return value while array_push modifies an argument."},"comment":{"url":"https://api.github.com/repos/php/php-src/issues/comments/493571554","html_url":"https://github.com/php/php-src/pull/4175#issuecomment-493571554","issue_url":"https://api.github.com/repos/php/php-src/issues/4175","id":493571554,"node_id":"MDEyOklzc3VlQ29tbWVudDQ5MzU3MTU1NA==","user":{"login":"carusogabriel","id":16328050,"node_id":"MDQ6VXNlcjE2MzI4MDUw","avatar_url":"https://avatars3.githubusercontent.com/u/16328050?v=4","gravatar_id":"","url":"https://api.github.com/users/carusogabriel","html_url":"https://github.com/carusogabriel","followers_url":"https://api.github.com/users/carusogabriel/followers","following_url":"https://api.github.com/users/carusogabriel/following{/other_user}","gists_url":"https://api.github.com/users/carusogabriel/gists{/gist_id}","starred_url":"https://api.github.com/users/carusogabriel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carusogabriel/subscriptions","organizations_url":"https://api.github.com/users/carusogabriel/orgs","repos_url":"https://api.github.com/users/carusogabriel/repos","events_url":"https://api.github.com/users/carusogabriel/events{/privacy}","received_events_url":"https://api.github.com/users/carusogabriel/received_events","type":"User","site_admin":false},"created_at":"2019-05-17T19:26:42Z","updated_at":"2019-05-17T19:26:42Z","author_association":"MEMBER","body":"This needs a discussion on internals.\r\n\r\n"}}
{"actor":{"display_login":"carusogabriel"}}