6 public static $arSupportedExtensions = array(
10 public function run(File $file)
12 $fpath = $file->getPath();
13 $fpathlen = strlen($fpath);
15 $res = new Tool_Result();
16 $cmd = 'php -l ' . escapeshellarg($fpath) . ' 2>&1';
17 exec($cmd, $output, $retval);
19 $res->annotations['general'][] = new Tool_Result_Line(
20 'No syntax errors detected', 'ok'
25 $regex = '#^(.+) in ' . preg_quote($fpath) . ' on line ([0-9]+)$#';
26 for ($i = 0; $i < count($output) - 1; $i++) {
28 if (!preg_match($regex, trim($line), $matches)) {
29 throw new Exception('"php -l" does not behave as expected: ' . $line);
32 $linenum = $matches[2];
33 $res->annotations[$linenum][] = new Tool_Result_Line(
38 $res->annotations['general'][] = new Tool_Result_Line(
39 'PHP code has syntax errors', 'error'