syntax error, unexpected variable “$task”, expecting “)”¶
Description¶
In a function, method or closure signature, each parameter must be separated from the next one by a comma. Here, the comma between $name and $task is missing, so once PHP has parsed $name as a complete, typed parameter, it expects either another comma or the closing parenthesis of the argument list; instead it finds another variable, $task.
This is the generic “unexpected variable, expecting )” message, reported here with the concrete variable name found in the offending code, $task.
Example¶
<?php
function schedule(string $name $task) {}
?>
Solutions¶
Add the missing comma between the two parameters.
Remove the extra variable if it was left over from editing.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.