scanner/modules/scanner_lint.php
Correl Roush 2386113895 Text output is now tab delimited, one fault per line. Added an html output module. Mantis: 2691
git-svn-id: file:///srv/svn/scanner/trunk@5 a0501263-5b7a-4423-a8ba-1edf086583e7
2008-02-15 19:05:09 +00:00

30 lines
684 B
PHP

<?php
class LintModule extends ScannerModule {
function LintModule() {
$this->ScannerModule();
}
function preScan( $filename ) {
parent::preScan( $filename );
$output = array();
exec( "php -l '$filename' 2>/dev/null", $output, $result );
if( $result != 0 ) {
$file = file( $filename );
foreach( $output as $linterror ) {
$matches = array();
if( preg_match( '/error:.*?on line (\d+)$/i', $linterror, $matches ) == 0 ) { continue; }
$this->fault(
array(
'file' => $filename,
'line' => $matches[1],
'context' => $file[$matches[1] - 1]
),
FAULT_MAJOR,
$linterror
);
}
}
}
}
addModule( new LintModule() );
?>