Kahlan\Jit\Patcher\Monkey::_flushVariables PHP Method

_flushVariables() protected method

Flush stored variables in the passed node.
protected _flushVariables ( array $node )
$node array The node to store variables in.
    protected function _flushVariables($node)
    {
        if (!$this->_variables[$this->_depth]) {
            return;
        }
        $body = '';
        foreach ($this->_variables[$this->_depth] as $variable) {
            if ($variable['isClass']) {
                $body .= $variable['name'] . '__=null;';
            }
            $body .= $variable['name'] . $variable['patch'];
        }
        if (!$node->inPhp) {
            $body = '<?php ' . $body . ' ?>';
        }
        $patch = new NodeDef($body, 'code');
        $patch->parent = $node;
        $patch->function = $node->function;
        $patch->namespace = $node->namespace;
        array_unshift($node->tree, $patch);
        $this->_variables[$this->_depth] = [];
    }