Correl Roush
2386113895
git-svn-id: file:///srv/svn/scanner/trunk@5 a0501263-5b7a-4423-a8ba-1edf086583e7
30 lines
684 B
PHP
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() );
|
|
?>
|