From 73ab7b30ca52a49fb11b2d61fc757c8eeb7137fd Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 8 Sep 2020 15:14:48 +0200 Subject: Allow array_diff() and array_intersect() with single array argument Both of these functions are well-defined when used with a single array argument -- rejecting this case was an artificial limitation. This is not useful when called with explicit arguments, but removes edge-cases when used with argument unpacking: // OK even if $excludes is empty. array_diff($array, ...$excludes); // OK even if $arrays contains a single array only. array_intersect(...$arrays); This matches the behavior of functions like array_merge() and array_push(), which also allow calls with no array or a single array respectively. Closes GH-6097. --- UPGRADING | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'UPGRADING') diff --git a/UPGRADING b/UPGRADING index 3d37c2db25..f98ae50d1b 100644 --- a/UPGRADING +++ b/UPGRADING @@ -771,6 +771,14 @@ PHP 8.0 UPGRADE NOTES . Sorting functions are now stable, which means that equal-comparing elements will retain their original order. RFC: https://wiki.php.net/rfc/stable_sorting + . array_diff(), array_intersect() and their variations can now be used with + a single array as argument. This means that usages like the following are + now possible: + + // OK even if $excludes is empty. + array_diff($array, ...$excludes); + // OK even if $arrays only contains a single array. + array_intersect(...$arrays); - Zip: . Extension updated to version 1.19.0 -- cgit v1.2.1