r54737 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54736‎ | r54737 | r54738 >
Date:20:36, 10 August 2009
Author:brion
Status:ok
Tags:
Comment:
Revert r54644 to syntaxChecker.php "Use parsekit instead. php -l sucks."
ParseKit is an external PECL module which isn't super easy to install. Don't want to rely on something like that for tests we want everyone to be able to run prior to checkin...
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/syntaxChecker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/syntaxChecker.php
@@ -38,20 +38,12 @@
3939 }
4040
4141 public function execute() {
42 - if( !function_exists( 'parsekit_compile_file' ) ) {
43 - $this->error( 'Requires PHP with parsekit', true );
44 - }
45 -
4642 $this->output( "Building file list..." );
4743 $this->buildFileList();
4844 $this->output( "done.\n" );
4945
5046 $this->output( "Checking syntax (this can take a really long time)...\n\n" );
51 - foreach( $this->mFiles as $f ) {
52 - $this->checkFile( $f );
53 - }
54 - $this->output( "\nDone! " . count( $this->mFiles ) . " files checked, " .
55 - count( $this->mFailures ) . " failures found" );
 47+ $res = $this->checkSyntax();
5648 }
5749
5850 /**
@@ -88,33 +80,19 @@
8981 }
9082
9183 /**
92 - * Check a file for syntax errors. Shamelessly stolen
93 - * from tools/lint.php by TimStarling
94 - *
95 - * @param $file String Path to a file to check for syntax errors
 84+ * Check the files for syntax errors
9685 * @return boolean
9786 */
98 - private function checkFile( $file ) {
99 - static $okErrors = array(
100 - 'Redefining already defined constructor',
101 - 'Assigning the return value of new by reference is deprecated',
102 - );
103 - $errors = array();
104 - parsekit_compile_file( $file, $errors, PARSEKIT_SIMPLE );
105 - $ret = true;
106 - if ( $errors ) {
107 - foreach ( $errors as $error ) {
108 - foreach ( $okErrors as $okError ) {
109 - if ( substr( $error['errstr'], 0, strlen( $okError ) ) == $okError ) {
110 - continue 2;
111 - }
112 - }
113 - $ret = false;
114 - $this->output( "Error in $file line {$error['lineno']}: {$error['errstr']}\n" );
 87+ private function checkSyntax() {
 88+ foreach( $this->mFiles as $f ) {
 89+ $res = exec( 'php -l ' . $f );
 90+ if( strpos( $res, 'No syntax errors detected' ) === false ) {
 91+ $this->mFailures[] = $f;
 92+ $this->error( $res . "\n" );
11593 }
116 - $this->mFailures[ $file ] = $errors;
11794 }
118 - return $ret;
 95+ $this->output( count($this->mFiles) . " files checked, "
 96+ . count($this->mFailures) . " failures\n" );
11997 }
12098 }
12199
Property changes on: trunk/phase3/RELEASE-NOTES
___________________________________________________________________
Name: svn:mergeinfo
122100 + /branches/REL1_15/phase3/RELEASE-NOTES:51646

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r54644Use parsekit instead. php -l sucks.demon23:13, 8 August 2009

Status & tagging log