unset
does not return a value - it cannot be used meaningfully as an expression, even if such a production was accepted.
However, the parse error is caused because unset
is a keyword and a "special production": even though unset
looks like a function, it is not a function1. As such, unset
is only valid as a statement2 per the language grammar.
The production can be found in zend_language_parser.y:
309 unticked_statement:
| ..
338 | T_UNSET '(' unset_variables ')' ';'
1 The syntax is due to historical design choices, and arguably a mistake from a consistency viewpoint:
Note: Because [unset] is a language construct and not a function, it cannot be called using variable functions.
2 There is also "(unset) casting", but I'm ignoring that here.