Req #79285 [NEW]: Allow unpacking of arrays with string keys into other arrays

From: Date: Wed, 19 Feb 2020 15:13:25 +0000
Subject: Req #79285 [NEW]: Allow unpacking of arrays with string keys into other arrays
Groups: php.standards 
Request: Send a blank email to standards-+get-1485@lists.php.net to get a copy of this message
From: caelan89 at gmail dot com Operating system: n/a PHP version: 7.4.2 Package: PHP Language Specification Bug Type: Feature/Change Request Bug description:Allow unpacking of arrays with string keys into other arrays Description: ------------ You've added in array unpacking inside of arrays. However, it is a half-baked solution (if you can even call it that), and relatively useless except for a few use cases. You do not allow this: $a1 = [ 'test' => 1 ]; $a2 = [ 'test-2' => 2 ]; $a3 = [ ...$a1, ...$a2 ]; There is absolutely zero reason, other than your inconvenience building it, as to why this should be forbidden. None at all. It is semantically equivalent to: $a3 = array_merge($a1, $a2); Why on earth should I not be able to do the same with with the much neater and preferable array unpacking syntax? Test script: --------------- $a1 = [ 'test' => 1 ]; $a2 = [ 'test-2' => 2 ]; $a3 = [ ...$a1, ...$a2 ]; -- Edit bug report at https://bugs.php.net/bug.php?id=79285&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79285&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79285&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79285&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79285&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79285&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79285&r=support Expected behavior: https://bugs.php.net/fix.php?id=79285&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79285&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79285&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79285&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79285&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79285&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79285&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79285&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79285&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79285&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79285&r=mysqlcfg

« previous php.standards (#1485) next »