[php-src] Issue #19536: Array destructuring should warn when used on a non-array
| From: | tgr | Date: | Wed, 20 Aug 2025 19:20:44 +0000 |
| Subject: | [php-src] Issue #19536: Array destructuring should warn when used on a non-array | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250588@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19536
Author: tgr
### Description
This emits a warning:
```php
<?php
['a'=>$b] = [];
var_dump($b);
// Warning: Undefined array key "a" in /in/D0WSJ on line 2
// NULL
```
This doesn't:
```
['a'=>$b] = 0;
var_dump($b);
// NULL
```
That seems unintuitive and error-prone.
(3v4l: [first](https://3v4l.org/D0WSJ), [second](https://3v4l.org/9J69K))
### PHP Version
```plain
all supported versions + current master
```
### Operating System
_No response_