Add check for evil, EVIL @
This commit is contained in:
parent
bc205c281c
commit
e6fd7607d7
1 changed files with 14 additions and 0 deletions
|
|
@ -275,7 +275,9 @@ class CheckSyntax extends Maintenance {
|
|||
}
|
||||
|
||||
$text = file_get_contents( $file );
|
||||
$tokens = token_get_all( $text );
|
||||
|
||||
$this->checkEvilToken( $file, $tokens, '@', 'Error supression operator (@)');
|
||||
$this->checkRegex( $file, $text, '/^[\s\r\n]+<\?/', 'leading whitespace' );
|
||||
$this->checkRegex( $file, $text, '/\?>[\s\r\n]*$/', 'trailing ?>' );
|
||||
$this->checkRegex( $file, $text, '/^[\xFF\xFE\xEF]/', 'byte-order mark' );
|
||||
|
|
@ -292,6 +294,18 @@ class CheckSyntax extends Maintenance {
|
|||
$this->mWarnings[$file][] = $desc;
|
||||
$this->output( "Warning in file $file: $desc found.\n" );
|
||||
}
|
||||
|
||||
private function checkEvilToken( $file, $tokens, $evilToken, $desc ) {
|
||||
if ( !in_array( $evilToken, $tokens ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !isset( $this->mWarnings[$file] ) ) {
|
||||
$this->mWarnings[$file] = array();
|
||||
}
|
||||
$this->mWarnings[$file][] = $desc;
|
||||
$this->output( "Warning in file $file: $desc found.\n" );
|
||||
}
|
||||
}
|
||||
|
||||
$maintClass = "CheckSyntax";
|
||||
|
|
|
|||
Loading…
Reference in a new issue