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);
}
}
}