[php-src] Issue #10034: `array_unshift` should allow empty reference

From: Date: Fri, 02 Dec 2022 02:05:37 +0000
Subject: [php-src] Issue #10034: `array_unshift` should allow empty reference
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243019@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10034 Author: mvorisek ### Description The following code: ```php <?php $arr = ['y' => []]; array_unshift($arr['x'], 'a', 'b'); print_r($arr); ``` https://3v4l.org/llgI6 Resulted in this output: ``` Uncaught TypeError: array_unshift(): Argument #1 ($array) must be of type array, null given ``` But I expected this output instead: ``` Array ( [x] => Array ( [0] => a [1] => b ) ) ``` I would expect php to accept reference to null for array_unshift (and friend functions) and create empty array like $arr['x'][] = 'a' syntax does.

« previous php.bugs (#243019) next »