list() Does Not Type
<?php
list($a) = null;
list($a) = 1;
list($a) = 'a';
list($a) = 1.2;
function foo() { yield 3; }
// syntax error
//list($a) = ...foo();
list($a) = iterator_to_array(foo());
// fatal error
//list($a) = (object) ['a' => 1];
//Undefined array key 0
list($a) = [];
The list() command does not report that the type of the right operand is not correct. It is then possible to use list() with integers, string or boolean, and obtain null values for all variables.
On the other hand, list() does complain if the right hand array does not contain enough values to fit the number of variables. It also produces a Fatal error with an object, because an object cannot be used as an array.
Finally, list() does not compile with an ellipsis ... on the right side. To convert a Generator into a list of variables, one need to use iterator_to_array() first.
See Also
PHP Features
Last updated: 10 September 2026