/** * @see FWS_Module::run() */ public function run() { $user = FWS_Props::get()->user(); $tpl = FWS_Props::get()->tpl(); $jobs = array(); $files = $user->get_session_data('phpref_files'); for ($i = 0; $i < count($files); $i += PC_PHPREF_PAGES_PER_CYCLE) { $args = array(); for ($j = 0, $count = min(count($files) - $i, PC_PHPREF_PAGES_PER_CYCLE); $j < $count; $j++) { $args[] = escapeshellarg($files[$i + $j]); } $jobs[] = PC_PHP_EXEC . ' cli.php phpref ' . implode(' ', $args); } $user->delete_session_data('phpref_files'); $user->set_session_data('job_commands', $jobs); $user->set_session_data('job_finalizer', PC_PHP_EXEC . ' cli.php phpreffin'); // init shared data $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = new PC_JobData(); $data->set_misc(array('versions' => array(), 'aliases' => array())); $mutex->write(serialize($data)); $mutex->close(); $tpl->add_variables(array('file_count' => count($files), 'files_per_job' => PC_PHPREF_PAGES_PER_CYCLE, 'check_interval' => PC_JOB_CTRL_POLL_INTERVAL / 1000)); }
public function run($args) { $errors = array(); foreach ($args as $file) { try { if (preg_match('/\\/class\\./', $file)) { $this->grab_class($file); } else { $this->grab_function($file); } } catch (PC_PHPRef_Exception $e) { $errors[] = $e->getMessage() . ' in file "' . $file . '"'; } } // write stuff to shared data $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); /* @var $data PC_JobData */ $data->add_errors($errors); $misc = $data->get_misc(); $misc['versions'] = array_merge($misc['versions'], $this->versions); $misc['aliases'] = array_merge($misc['aliases'], $this->aliases); $data->set_misc($misc); $mutex->write(serialize($data)); $mutex->close(); }
public function run($args) { // get shared data $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); $misc = $data->get_misc(); $mutex->close(); $fin = new PC_PHPRef_Finalizer($misc['aliases'], $misc['versions']); $fin->finalize(); }
/** * @see FWS_Error_Logger::log() * * @param int $no * @param string $msg * @param string $file * @param int $line * @param array $backtrace */ public function log($no, $msg, $file, $line, $backtrace) { // build error-message $msg .= ' in file "' . $file . '", line ' . $line . '<br />'; $btpr = new FWS_Error_BTPrinter_HTML(); $msg .= $btpr->print_backtrace($backtrace); // write stuff to shared data $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); /* @var $data PC_JobData */ $data->add_error($msg); $mutex->write(serialize($data)); $mutex->close(); }
public function run($args) { $project = FWS_Props::get()->project(); $options = new PC_Engine_Options(); $options->set_report_unused(true); $options->set_report_argret_strictly($project->get_report_argret_strictly()); $options->add_project($project->get_id()); foreach ($project->get_project_deps() as $pid) { $options->add_project($pid); } foreach ($project->get_req() as $r) { if ($r['type'] == 'min') { $options->add_min_req($r['name'], $r['version']); } else { $options->add_max_req($r['name'], $r['version']); } } $env = new PC_Engine_Env($options); $ascanner = new PC_Engine_StmtScannerFrontend($env); $msgs = array(); foreach ($args as $file) { try { $ascanner->scan_file($file); } catch (PC_Engine_Exception $e) { $msgs[] = $e->__toString(); } } if (count($env->get_types()->get_calls())) { PC_DAO::get_calls()->create_bulk($env->get_types()->get_calls()); } foreach ($env->get_errors()->get() as $err) { PC_DAO::get_errors()->create($err); } foreach ($ascanner->get_vars() as $vars) { foreach ($vars as $var) { PC_DAO::get_vars()->create($var); } } // write messages to shared data $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); /* @var $data PC_JobData */ $data->add_errors($msgs); $mutex->write(serialize($data)); $mutex->close(); }
/** * @see FWS_Module::run() */ public function run() { $doc = FWS_Props::get()->doc(); $renderer = $doc->use_raw_renderer(); // read from file $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); $mutex->close(); /* @var $data PC_JobData */ $res = $data->get_done() . ';'; if (count($data->get_errors())) { $res .= '<div style="text-align: left; padding-left: 3em;"><ul>'; foreach ($data->get_errors() as $err) { $res .= '<li>' . $err . '</li>'; } $res .= '</ul></div>'; } $renderer->set_content($res); }
public function run($args) { $project = FWS_Props::get()->project(); $options = new PC_Engine_Options(); foreach ($project->get_project_deps() as $pid) { $options->add_project($pid); } $env = new PC_Engine_Env($options); $tscanner = new PC_Engine_TypeScannerFrontend($env); $msgs = array(); foreach ($args as $file) { try { $tscanner->scan_file($file); } catch (PC_Engine_Exception $e) { $msgs[] = $e->__toString(); } } foreach ($env->get_types()->get_classes() as $class) { PC_DAO::get_classes()->create($class); } foreach ($env->get_types()->get_constants() as $const) { PC_DAO::get_constants()->create($const); } foreach ($env->get_types()->get_functions() as $func) { PC_DAO::get_functions()->create($func); } foreach ($env->get_errors()->get() as $err) { PC_DAO::get_errors()->create($err); } // write msgs to shared data $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); /* @var $data PC_JobData */ $data->add_errors($msgs); $mutex->write(serialize($data)); $mutex->close(); }
/** * Adds the given error to file * * @param string $err the error */ private function add_error($err) { $mutex = new FWS_MutexFile(PC_CLI_MUTEX_FILE); $mutex->aquire(); $data = unserialize($mutex->read()); /* @var $data PC_JobData */ $data->add_error($err); $mutex->write(serialize($data)); $mutex->close(); }