2008-02-13 22:39:27 +00:00
|
|
|
<?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 ) {
|
2008-02-15 19:05:09 +00:00
|
|
|
$file = file( $filename );
|
2008-02-13 22:39:27 +00:00
|
|
|
foreach( $output as $linterror ) {
|
|
|
|
$matches = array();
|
|
|
|
if( preg_match( '/error:.*?on line (\d+)$/i', $linterror, $matches ) == 0 ) { continue; }
|
|
|
|
$this->fault(
|
|
|
|
array(
|
|
|
|
'file' => $filename,
|
2008-02-15 19:05:09 +00:00
|
|
|
'line' => $matches[1],
|
|
|
|
'context' => $file[$matches[1] - 1]
|
2008-02-13 22:39:27 +00:00
|
|
|
),
|
|
|
|
FAULT_MAJOR,
|
|
|
|
$linterror
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-15 19:05:09 +00:00
|
|
|
addModule( new LintModule() );
|
2008-02-13 22:39:27 +00:00
|
|
|
?>
|