Kahlan\Jit\Patcher\Rebase::_processTree PHP Method

_processTree() protected method

Helper for Rebase::process().
protected _processTree ( array $parent, string $path )
$parent array The node instance tor process.
$path string The file path of the source code.
    protected function _processTree($parent, $path)
    {
        $path = addcslashes($path, "'");
        $dir = "'" . dirname($path) . "'";
        $file = "'" . $path . "'";
        $alphanum = '[\\\\a-zA-Z0-9_\\x7f-\\xff]';
        $dirRegex = "/(?<!\\:|\\\$|\\>|{$alphanum})(\\s*)(__DIR__)/";
        $fileRegex = "/(?<!\\:|\\\$|\\>|{$alphanum})(\\s*)(__FILE__)/";
        foreach ($parent->tree as $node) {
            if ($node->processable && $node->type === 'code') {
                $node->body = preg_replace($dirRegex, $dir, $node->body);
                $node->body = preg_replace($fileRegex, $file, $node->body);
            }
            if (count($node->tree)) {
                $this->_processTree($node, $path);
            }
        }
    }