Make lines shorter to pass phpcs in some files under includes/parser
authorAmir E. Aharoni <amir.aharoni@mail.huji.ac.il>
Sat, 26 Sep 2015 17:17:49 +0000 (20:17 +0300)
committerReedy <reedy@wikimedia.org>
Sat, 26 Sep 2015 18:19:11 +0000 (18:19 +0000)
This doesn't fix all the files under includes/parser -
some of them deserve their own patches.

Bug: T102614
Change-Id: I2fcbc19ee337e1b7db4635b5e5f324c651b4d144

includes/parser/CacheTime.php
includes/parser/CoreParserFunctions.php
includes/parser/Parser.php
includes/parser/ParserCache.php
includes/parser/ParserOptions.php

index c450689..7acfe38 100644 (file)
@@ -32,10 +32,17 @@ class CacheTime {
         */
        public $mUsedOptions;
 
-       public $mVersion = Parser::VERSION,  # Compatibility check
-               $mCacheTime = '',             # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
-               $mCacheExpiry = null,         # Seconds after which the object should expire, use 0 for uncacheable. Used in ParserCache.
-               $mCacheRevisionId = null;     # Revision ID that was parsed
+       # Compatibility check
+       public $mVersion = Parser::VERSION;
+
+       # Time when this object was generated, or -1 for uncacheable. Used in ParserCache.
+       public $mCacheTime = '';
+
+       # Seconds after which the object should expire, use 0 for uncacheable. Used in ParserCache.
+       public $mCacheExpiry = null;
+
+       # Revision ID that was parsed
+       public $mCacheRevisionId = null;
 
        /**
         * @return string TS_MW timestamp
index 7639e2f..b0737f6 100644 (file)
@@ -60,7 +60,11 @@ class CoreParserFunctions {
                        $parser->setFunctionHook( $func, array( __CLASS__, $func ), Parser::SFH_NO_HASH );
                }
 
-               $parser->setFunctionHook( 'namespace', array( __CLASS__, 'mwnamespace' ), Parser::SFH_NO_HASH );
+               $parser->setFunctionHook(
+                       'namespace',
+                       array( __CLASS__, 'mwnamespace' ),
+                       Parser::SFH_NO_HASH
+               );
                $parser->setFunctionHook( 'int', array( __CLASS__, 'intFunction' ), Parser::SFH_NO_HASH );
                $parser->setFunctionHook( 'special', array( __CLASS__, 'special' ) );
                $parser->setFunctionHook( 'speciale', array( __CLASS__, 'speciale' ) );
@@ -68,7 +72,11 @@ class CoreParserFunctions {
                $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
 
                if ( $wgAllowDisplayTitle ) {
-                       $parser->setFunctionHook( 'displaytitle', array( __CLASS__, 'displaytitle' ), Parser::SFH_NO_HASH );
+                       $parser->setFunctionHook(
+                               'displaytitle',
+                               array( __CLASS__, 'displaytitle' ),
+                               Parser::SFH_NO_HASH
+                       );
                }
                if ( $wgAllowSlowParserFunctions ) {
                        $parser->setFunctionHook(
@@ -810,7 +818,9 @@ class CoreParserFunctions {
         * @param int $direction
         * @return string
         */
-       public static function pad( $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT ) {
+       public static function pad(
+               $parser, $string, $length, $padding = '0', $direction = STR_PAD_RIGHT
+       ) {
                $padding = $parser->killMarkers( $padding );
                $lengthOfPadding = mb_strlen( $padding );
                if ( $lengthOfPadding == 0 ) {
index 3e5e8a1..3b49ccf 100644 (file)
@@ -511,7 +511,10 @@ class Parser {
                        }
                        $limitReport .= 'Cached time: ' . $this->mOutput->getCacheTime() . "\n";
                        $limitReport .= 'Cache expiry: ' . $this->mOutput->getCacheExpiry() . "\n";
-                       $limitReport .= 'Dynamic content: ' . ( $this->mOutput->hasDynamicContent() ? 'true' : 'false' ) . "\n";
+                       $limitReport .= 'Dynamic content: ' .
+                               ( $this->mOutput->hasDynamicContent() ? 'true' : 'false' ) .
+                               "\n";
+
                        foreach ( $this->mOutput->getLimitReportData() as $key => $value ) {
                                if ( Hooks::run( 'ParserLimitReportFormat',
                                        array( $key, &$value, &$limitReport, false, false )
@@ -1468,7 +1471,6 @@ class Parser {
         * @private
         */
        public function makeFreeExternalLink( $url, $numPostProto ) {
-
                $trail = '';
 
                # The characters '<' and '>' (which were escaped by
@@ -1476,7 +1478,12 @@ class Parser {
                # URLs, per RFC 2396.
                # Make &nbsp; terminate a URL as well (bug T84937)
                $m2 = array();
-               if ( preg_match( '/&(lt|gt|nbsp|#x0*(3[CcEe]|[Aa]0)|#0*(60|62|160));/', $url, $m2, PREG_OFFSET_CAPTURE ) ) {
+               if ( preg_match(
+                       '/&(lt|gt|nbsp|#x0*(3[CcEe]|[Aa]0)|#0*(60|62|160));/',
+                       $url,
+                       $m2,
+                       PREG_OFFSET_CAPTURE
+               ) ) {
                        $trail = substr( $url, $m2[0][1] ) . $trail;
                        $url = substr( $url, 0, $m2[0][1] );
                }
index abff543..c03b5c2 100644 (file)
@@ -226,11 +226,17 @@ class ParserCache {
                        wfIncrStats( "pcache.miss.revid" );
                        $revId = $article->getLatest();
                        $cachedRevId = $value->getCacheRevisionId();
-                       wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" );
+                       wfDebug(
+                               "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
+                       );
                        $value = false;
-               } elseif ( Hooks::run( 'RejectParserCacheValue', array( $value, $wikiPage, $popts ) ) === false ) {
+               } elseif (
+                       Hooks::run( 'RejectParserCacheValue', array( $value, $wikiPage, $popts ) ) === false
+               ) {
                        wfIncrStats( 'pcache.miss.rejected' );
-                       wfDebug( "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n" );
+                       wfDebug(
+                               "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
+                       );
                        $value = false;
                } else {
                        wfIncrStats( "pcache.hit" );
@@ -284,7 +290,10 @@ class ParserCache {
                        // ...and its pointer
                        $this->mMemc->set( $this->getOptionsKey( $page ), $optionsKey, $expire );
 
-                       Hooks::run( 'ParserCacheSaveComplete', array( $this, $parserOutput, $page->getTitle(), $popts, $revId ) );
+                       Hooks::run(
+                               'ParserCacheSaveComplete',
+                               array( $this, $parserOutput, $page->getTitle(), $popts, $revId )
+                       );
                } else {
                        wfDebug( "Parser output was marked as uncacheable and has not been saved.\n" );
                }
index 1073aed..e6d5274 100644 (file)
@@ -831,8 +831,8 @@ class ParserOptions {
        }
 
        /**
-        * Sets a hook to force that a page exists, and sets a current revision callback to return a
-        * revision with custom content when the current revision of the page is requested.
+        * Sets a hook to force that a page exists, and sets a current revision callback to return
+        * revision with custom content when the current revision of the page is requested.
         *
         * @since 1.25
         * @param Title $title
@@ -841,20 +841,25 @@ class ParserOptions {
         * @return ScopedCallback to unset the hook
         */
        public function setupFakeRevision( $title, $content, $user ) {
-               $oldCallback = $this->setCurrentRevisionCallback( function ( $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback ) {
-                       if ( $titleToCheck->equals( $title ) ) {
-                               return new Revision( array(
-                                       'page' => $title->getArticleID(),
-                                       'user_text' => $user->getName(),
-                                       'user' => $user->getId(),
-                                       'parent_id' => $title->getLatestRevId(),
-                                       'title' => $title,
-                                       'content' => $content
-                               ) );
-                       } else {
-                               return call_user_func( $oldCallback, $titleToCheck, $parser );
+               $oldCallback = $this->setCurrentRevisionCallback(
+                       function (
+                               $titleToCheck, $parser = false ) use ( $title, $content, $user, &$oldCallback
+                       ) {
+                               if ( $titleToCheck->equals( $title ) ) {
+                                       return new Revision( array(
+                                               'page' => $title->getArticleID(),
+                                               'user_text' => $user->getName(),
+                                               'user' => $user->getId(),
+                                               'parent_id' => $title->getLatestRevId(),
+                                               'title' => $title,
+                                               'content' => $content
+                                       ) );
+                               } else {
+                                       return call_user_func( $oldCallback, $titleToCheck, $parser );
+                               }
                        }
-               } );
+               );
+
                global $wgHooks;
                $wgHooks['TitleExists'][] =
                        function ( $titleToCheck, &$exists ) use ( $title ) {