scanner/modules/lint.php

29 lines
611 B
PHP
Raw Normal View History

<?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 ) {
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]
),
FAULT_MAJOR,
$linterror
);
}
}
}
}
$modules[] = new LintModule();
?>