30) { // to many files.. we can not check that amount without causing serious delays in commits return true; } foreach ($files as $filename) { $pi = pathinfo($filename); if ( $pi['extension'] == 'php') { $fp = $checker->bridge->getFileStream($filename); $res = $this->checkPHP($filename, $fp); if ($res !== true) { $ret[] = $res; } $fp = null; // remove stream. } } return $ret ? implode("\n", $ret) : true; } function postCommit($msg, $files, $actions) { return true; } function checkPHP($filename, $fp) { $pipes = null; $proc = proc_open(MTrackConfig::get('tools', 'php') . " -l", array( 0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w') ), $pipes); // send in data stream_copy_to_stream($fp, $pipes[0]); $fp = null; $pipes[0] = null; $output = stream_get_contents($pipes[1]); $output .= stream_get_contents($pipes[2]); $st = proc_get_status($proc); if ($st['running']) { proc_terminate($proc); sleep(1); $st = proc_get_status($proc); } if ($st['exitcode'] != 0) { return "$filename: $output"; } return true; } }