/** * load binary from file * @param \recompilr\Compiler\CompilerInterface $compiler */ public function load(CompilerInterface $compiler = null) { if (is_file($this->fileName)) { $pathinfo = pathinfo($this->fileName); if ($pathinfo['extension'] === 'rcx') { $bin = file_get_contents($this->fileName); $contents = base64_decode($bin); \Veval::execute($contents); } } }
/** * Dynamically adds context to closure * @param mixed $object * @param array $context */ static function rebind($object, array $context) { $code = self::code($object); $count = count($context) - 1; $fn_code = '$_function = ' . $code . ';'; if (($pos = strpos($fn_code, 'use(')) !== false) { $c_string = ''; foreach ($context as $k => $c) { $c_string .= '$' . $k . ','; } $fn_code = substr($fn_code, 0, $pos) . $c_string . substr($fn_code, $pos); } else { $pos = strpos($fn_code, '{'); if ($pos !== false) { $pos -= 1; $c_string = ''; $i = 0; foreach ($context as $k => $c) { $c_string .= '$' . $k; if ($i < $count) { $c_string .= ','; } $i++; } $fn_code = substr($fn_code, 0, $pos) . 'use(' . $c_string . ')' . substr($fn_code, $pos); } } if (strpos(ini_get('disable_functions'), 'eval') === false) { extract($context); eval($fn_code); } else { $id = qtil\Identifier::identify($code); $a_string = ''; $i = 0; foreach ($context as $k => $c) { $a_string .= '$' . $k; if ($i < $count) { $a_string .= ','; } $i++; } $fn_code = 'function delegate_' . $id . '(' . $a_string . ') { return ' . $fn_code . '; }'; \Veval::execute('<?php ' . $fn_code); $_function = call_user_func_array('delegate_' . $id, array_values($context)); } self::remove($object); self::add($object, $_function); }