protected function executeOnPHPFile(File $file) { $command = "echo " . escapeshellarg($file->getContent()) . " | php -l 2>&1"; exec($command, $output, $returnVal); if ($returnVal == 255 && $output) { $this->pushError(str_replace(' -', " " . $file->getPath(), implode(',', $output))); } }
private function prepareFileContent(File $file) { $byLine = array(); $lineNo = 1; foreach (preg_split('/[(\\r\\n)|(\\n)|(\\n\\r)]/', $file->getContent()) as $line) { $byLine[$lineNo++] = $line; } return $byLine; }