Fix Generic.Files.LineLength phpcs failure in 11 files under includes/
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 288e486..efad151 100644 (file)
@@ -91,8 +91,10 @@ class Parser {
        # at least one character of a host name (embeds EXT_LINK_URL_CLASS)
        const EXT_LINK_ADDR = '(?:[0-9.]+|\\[(?i:[0-9a-f:.]+)\\]|[^][<>"\\x00-\\x20\\x7F\p{Zs}])';
        # RegExp to make image URLs (embeds IPv6 part of EXT_LINK_ADDR)
+       // @codingStandardsIgnoreStart Generic.Files.LineLength
        const EXT_IMAGE_REGEX = '/^(http:\/\/|https:\/\/)((?:\\[(?i:[0-9a-f:.]+)\\])?[^][<>"\\x00-\\x20\\x7F\p{Zs}]+)
                \\/([A-Za-z0-9_.,~%\\-+&;#*?!=()@\\x80-\\xFF]+)\\.((?i)gif|png|jpg|jpeg)$/Sxu';
+       // @codingStandardsIgnoreEnd
 
        # Regular expression for a non-newline space
        const SPACE_NOT_NL = '(?:\t|&nbsp;|&\#0*160;|&\#[Xx]0*[Aa]0;|\p{Zs})';
@@ -511,7 +513,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 +1473,6 @@ class Parser {
         * @private
         */
        public function makeFreeExternalLink( $url, $numPostProto ) {
-
                $trail = '';
 
                # The characters '<' and '>' (which were escaped by
@@ -1476,7 +1480,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] );
                }
@@ -3378,6 +3387,8 @@ class Parser {
         * Warn the user when a parser limitation is reached
         * Will warn at most once the user per limitation type
         *
+        * The results are shown during preview and run through the Parser (See EditPage.php)
+        *
         * @param string $limitationType Should be one of:
         *   'expensive-parserfunction' (corresponding messages:
         *       'expensive-parserfunction-warning',
@@ -3400,8 +3411,10 @@ class Parser {
         */
        public function limitationWarn( $limitationType, $current = '', $max = '' ) {
                # does no harm if $current and $max are present but are unnecessary for the message
+               # Not doing ->inLanguage( $this->mOptions->getUserLangObj() ), since this is shown
+               # only during preview, and that would split the parser cache unnecessarily.
                $warning = wfMessage( "$limitationType-warning" )->numParams( $current, $max )
-                       ->inLanguage( $this->mOptions->getUserLangObj() )->text();
+                       ->text();
                $this->mOutput->addWarning( $warning );
                $this->addTrackingCategory( "$limitationType-category" );
        }
@@ -4843,16 +4856,7 @@ class Parser {
                $ts = $this->mOptions->getTimestamp();
                $timestamp = MWTimestamp::getLocalInstance( $ts );
                $ts = $timestamp->format( 'YmdHis' );
-               $tzMsg = $timestamp->format( 'T' );  # might vary on DST changeover!
-
-               # Allow translation of timezones through wiki. format() can return
-               # whatever crap the system uses, localised or not, so we cannot
-               # ship premade translations.
-               $key = 'timezone-' . strtolower( trim( $tzMsg ) );
-               $msg = wfMessage( $key )->inContentLanguage();
-               if ( $msg->exists() ) {
-                       $tzMsg = $msg->text();
-               }
+               $tzMsg = $timestamp->getTimezoneMessage()->inContentLanguage()->text();
 
                $d = $wgContLang->timeanddate( $ts, false, false ) . " ($tzMsg)";
 
@@ -5327,7 +5331,6 @@ class Parser {
                $ig->setParser( $this );
                $ig->setHideBadImages();
                $ig->setAttributes( Sanitizer::validateTagAttributes( $params, 'table' ) );
-               $this->getOutput()->addModuleStyles( 'mediawiki.page.gallery.styles' );
 
                if ( isset( $params['showfilename'] ) ) {
                        $ig->setShowFilename( true );