Merge "Use a faster 7z command line by default"
[lhc/web/wiklou.git] / maintenance / checkSyntax.php
index ef88545..d1c2edd 100644 (file)
@@ -38,10 +38,23 @@ class CheckSyntax extends Maintenance {
                parent::__construct();
                $this->mDescription = "Check syntax for all PHP files in MediaWiki";
                $this->addOption( 'with-extensions', 'Also recurse the extensions folder' );
-               $this->addOption( 'path', 'Specific path (file or directory) to check, either with absolute path or relative to the root of this MediaWiki installation',
-                       false, true );
-               $this->addOption( 'list-file', 'Text file containing list of files or directories to check', false, true );
-               $this->addOption( 'modified', 'Check only files that were modified (requires Git command-line client)' );
+               $this->addOption(
+                       'path',
+                       'Specific path (file or directory) to check, either with absolute path or '
+                               . 'relative to the root of this MediaWiki installation',
+                       false,
+                       true
+               );
+               $this->addOption(
+                       'list-file',
+                       'Text file containing list of files or directories to check',
+                       false,
+                       true
+               );
+               $this->addOption(
+                       'modified',
+                       'Check only files that were modified (requires Git command-line client)'
+               );
                $this->addOption( 'syntax-only', 'Check for syntax validity only, skip code style warnings' );
        }
 
@@ -53,7 +66,8 @@ class CheckSyntax extends Maintenance {
                $this->buildFileList();
 
                // ParseKit is broken on PHP 5.3+, disabled until this is fixed
-               $useParseKit = function_exists( 'parsekit_compile_file' ) && version_compare( PHP_VERSION, '5.3', '<' );
+               $useParseKit = function_exists( 'parsekit_compile_file' )
+                       && version_compare( PHP_VERSION, '5.3', '<' );
 
                $str = 'Checking syntax (using ' . ( $useParseKit ?
                        'parsekit' : ' php -l, this can take a long time' ) . ")\n";
@@ -82,7 +96,7 @@ class CheckSyntax extends Maintenance {
                $this->mIgnorePaths = array(
                        // Compat stuff, explodes on PHP 5.3
                        "includes/NamespaceCompat.php$",
-                       );
+               );
 
                $this->mNoStyleCheckPaths = array(
                        // Third-party code we don't care about
@@ -96,13 +110,14 @@ class CheckSyntax extends Maintenance {
                        "QPoll/Excel/",
                        "/geshi/",
                        "/smarty/",
-                       );
+               );
 
                if ( $this->hasOption( 'path' ) ) {
                        $path = $this->getOption( 'path' );
                        if ( !$this->addPath( $path ) ) {
                                $this->error( "Error: can't find file or directory $path\n", true );
                        }
+
                        return; // process only this path
                } elseif ( $this->hasOption( 'list-file' ) ) {
                        $file = $this->getOption( 'list-file' );
@@ -117,6 +132,7 @@ class CheckSyntax extends Maintenance {
                                $this->addPath( $path );
                        }
                        fclose( $f );
+
                        return;
                } elseif ( $this->hasOption( 'modified' ) ) {
                        $this->output( "Retrieving list from Git... " );
@@ -127,6 +143,7 @@ class CheckSyntax extends Maintenance {
                                        $this->mFiles[] = $file;
                                }
                        }
+
                        return;
                }
 
@@ -227,6 +244,7 @@ class CheckSyntax extends Maintenance {
                                return false;
                        }
                }
+
                return true;
        }
 
@@ -237,6 +255,7 @@ class CheckSyntax extends Maintenance {
         */
        private function addPath( $path ) {
                global $IP;
+
                return $this->addFileOrDir( $path ) || $this->addFileOrDir( "$IP/$path" );
        }
 
@@ -253,6 +272,7 @@ class CheckSyntax extends Maintenance {
                } else {
                        return false;
                }
+
                return true;
        }
 
@@ -299,6 +319,7 @@ class CheckSyntax extends Maintenance {
                                $this->mFailures[$file] = $errors;
                        }
                }
+
                return $ret;
        }
 
@@ -312,8 +333,10 @@ class CheckSyntax extends Maintenance {
                if ( strpos( $res, 'No syntax errors detected' ) === false ) {
                        $this->mFailures[$file] = $res;
                        $this->output( $res . "\n" );
+
                        return false;
                }
+
                return true;
        }
 
@@ -322,7 +345,6 @@ class CheckSyntax extends Maintenance {
         * or pointless ?> closing tags at the end.
         *
         * @param string $file String Path to a file to check for errors
-        * @return bool
         */
        private function checkForMistakes( $file ) {
                foreach ( $this->mNoStyleCheckPaths as $regex ) {