Cannot use auto-global as lexical variable

Description

A lexical variable is the variables used in the use part of a closure definition. These variable will be imported in the closure. In this case, the variable is an auto-global variable, which is included in every context, so this is useless.

Example

<?php

function () use ($_POST) {

};

?>

Solutions

  • Remove the auto-global from the list of imported variable (in the use clause).

  • Remove the use clause, if that variable is there alone.

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>`_.