The documentation says the following, where "list-intrinsic" is a grammar containing all the valid forms list(...) may have.
list-intrinsic should be used as the left operand in a simple assignment expression, the right operand of which should be an expression that denotes an array (called the original array).
What does an array mean? The documentation says the following:
An array is a data structure that contains a collection of zero or more elements. Elements of an array do not have to be of the same type, and the type of an array element can change during its lifetime.
I think you are right that FALSE , boolean, does not qualify as anything denoting an array, since it is not a collection.
What does "should" mean in this context? If we read Conformance, the part of the documentation we find:
In this specification, "must" should be interpreted as a requirement for an implementation or program; on the contrary, it should not be interpreted as a ban.
If the requirement "must" or "must not" that appears outside the constraint is violated, the behavior is undefined. Undefined behavior is otherwise indicated in this specification by the words "undefined behavior" or the absence of any explicit definition of behavior. There is no difference in these three differences; they all describe "behavior that is undefined."
Do you correctly assume that a fatal error should occur? I think you're wrong about that. If the semantics section does not indicate that a fatal error will occur, the absence of a behavior specification or “mandatory” with restrictions means that the behavior of this part of the language is undefined. He can work. This can lead to an error, a fatal error. He can create an AI that destroys us all, turns the moon into purple, or blows up the server. It is undefined.
So what's going on? The semantics documentation states the following:
This inline object assigns zero or more elements of the source array to target variables. On success, a copy of the original array is returned. If the original array is actually NULL, this is considered a failure, and the return value from the list is undefined.
All elements in the source array that have type string keys are ignored. An element having an int key of 0 is assigned the first target variable, an element having an int key of 1 is assigned the second target variable, and so on, until all the target variables are assigned. Any other elements of the array are ignored. If the number of elements in the source array is less than that of the target variables, then the unassigned target variables are set to NULL and a non-fatal error occurs.
Testing gives the following results:
$a = 1; $z = FALSE; $e = (list( $a, $b ) = $z); var_dump($a); //NULL var_dump($b); //NULL var_dump($z); //FALSE var_dump($e); //FALSE
Indeed, $z = $e for any $z seems even if $z = NULL . No notification, warning or error is generated for any value that I tested if the length of the original array is not less than the number of variables in the list-intrensic expression. In this case, a Notice: Undefined offset is displayed.
It seems that any non-iterative expression is treated as if it were a NULL value (but this behavior is Undefined); in my version of PHP it seems that any NULL value reduces the assignment halfway; it will not be repeated, but the preliminary part of the NULL assignment is performed for all variables.
Thus, the expression while (list($id, $name, $salary) = $result->fetch(PDO::FETCH_NUM)) assigns NULL $id , $name and $salary , and the value FALSE ends the while loop. However, this behavior is not expected or guaranteed by the language specification.