protected function determineContext(array &$data)
    {
        // Get the variable names defined in the AST
        $refs = 0;
        $vars = array_map(function ($node) use (&$refs) {
            if ($node->byRef) {
                $refs++;
            }
            if ($node->var instanceof VariableNode) {
                // For PHP-Parser >=4.0
                return $node->var->name;
            } else {
                // For PHP-Parser <4.0
                return $node->var;
            }
        }, $data['ast']->uses);
        $data['hasRefs'] = ($refs > 0);

        // Get the variable names and values using reflection
        $values = $data['reflection']->getStaticVariables();

        // Combine the names and values to create the canonical context.
        foreach ($vars as $name) {
            if (isset($values[$name])) {
                $data['context'][$name] = $values[$name];
            }
        }
    }
protected function determineContext(array &$data)
    {
        // Get the variable names defined in the AST
        $refs = 0;
        $vars = array_map(function ($node) use (&$refs) {
            if ($node->byRef) {
                $refs++;
            }
            if ($node->var instanceof VariableNode) {
                // For PHP-Parser >=4.0
                return $node->var->name;
            } else {
                // For PHP-Parser <4.0
                return $node->var;
            }
        }, $data['ast']->uses);
        $data['hasRefs'] = ($refs > 0);

        // Get the variable names and values using reflection
        $values = $data['reflection']->getStaticVariables();

        // Combine the names and values to create the canonical context.
        foreach ($vars as $name) {
            if (isset($values[$name])) {
                $data['context'][$name] = $values[$name];
            }
        }
    }
protected function determineContext ( array & $ data ) { // Get the variable names defined in the AST $ refs = 0 ; $ vars = array_map ( function ( $ node ) use ( & $ refs ) { if ( $ node -> byRef ) { $ refs ++ ; } if ( $ node -> var instanceof VariableNode ) { // For PHP-Parser >=4.0 return $ node -> var -> name ; } else { // For PHP-Parser <4.0 return $ node -> var ; } } , $ data [ 'ast' ] -> uses ) ; $ data [ 'hasRefs' ] = ( $ refs > 0 ) ; // Get the variable names and values using reflection $ values = $ data [ 'reflection' ] -> getStaticVariables ( ) ; // Combine the names and values to create the canonical context. foreach ( $ vars as $ name ) { if ( isset ( $ values [ $ name ] ) ) { $ data [ 'context' ] [ $ name ] = $ values [ $ name ] ; } } }
Returns the variables that in the "use" clause of the closure definition.
These are referred to as the "used variables", "static variables", or
"closed upon variables", "context" of the closure.

@param array $data
Returns the variables that in the use clause of the closure definition . These are referred to as the used variables static variables or closed upon variables context of the closure .