Merge "Perform a permission check on the title when changing the page language"
[lhc/web/wiklou.git] / includes / content / WikitextContent.php
index 89e9356..942390f 100644 (file)
@@ -38,7 +38,7 @@ class WikitextContent extends TextContent {
        }
 
        /**
-        * @param string|number $sectionId
+        * @param string|int $sectionId
         *
         * @return Content|bool|null
         *
@@ -58,7 +58,7 @@ class WikitextContent extends TextContent {
        }
 
        /**
-        * @param string|number|null|bool $sectionId
+        * @param string|int|null|bool $sectionId
         * @param Content $with
         * @param string $sectionTitle
         *
@@ -68,7 +68,6 @@ class WikitextContent extends TextContent {
         * @see Content::replaceSection()
         */
        public function replaceSection( $sectionId, Content $with, $sectionTitle = '' ) {
-
                $myModelId = $this->getModel();
                $sectionModelId = $with->getModel();
 
@@ -89,7 +88,7 @@ class WikitextContent extends TextContent {
                        # Inserting a new section
                        $subject = $sectionTitle ? wfMessage( 'newsectionheaderdefaultlevel' )
                                        ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : '';
-                       if ( Hooks::run( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) {
+                       if ( Hooks::run( 'PlaceNewSection', [ $this, $oldtext, $subject, &$text ] ) ) {
                                $text = strlen( trim( $oldtext ) ) > 0
                                        ? "{$oldtext}\n\n{$subject}{$text}"
                                        : "{$subject}{$text}";
@@ -138,7 +137,6 @@ class WikitextContent extends TextContent {
 
                $text = $this->getNativeData();
                $pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
-               rtrim( $pst );
 
                return ( $text === $pst ) ? $this : new static( $pst );
        }
@@ -153,7 +151,7 @@ class WikitextContent extends TextContent {
         *
         * @return Content
         */
-       public function preloadTransform( Title $title, ParserOptions $popts, $params = array() ) {
+       public function preloadTransform( Title $title, ParserOptions $popts, $params = [] ) {
                global $wgParser;
 
                $text = $this->getNativeData();
@@ -180,7 +178,7 @@ class WikitextContent extends TextContent {
 
                if ( $wgMaxRedirects < 1 ) {
                        // redirects are disabled, so quit early
-                       $this->redirectTargetAndText = array( null, $this->getNativeData() );
+                       $this->redirectTargetAndText = [ null, $this->getNativeData() ];
                        return $this->redirectTargetAndText;
                }
 
@@ -190,7 +188,7 @@ class WikitextContent extends TextContent {
                        // Extract the first link and see if it's usable
                        // Ensure that it really does come directly after #REDIRECT
                        // Some older redirects included a colon, so don't freak about that!
-                       $m = array();
+                       $m = [];
                        if ( preg_match( '!^\s*:?\s*\[{2}(.*?)(?:\|.*?)?\]{2}\s*!', $text, $m ) ) {
                                // Strip preceding colon used to "escape" categories, etc.
                                // and URL-decode links
@@ -201,16 +199,16 @@ class WikitextContent extends TextContent {
                                $title = Title::newFromText( $m[1] );
                                // If the title is a redirect to bad special pages or is invalid, return null
                                if ( !$title instanceof Title || !$title->isValidRedirectTarget() ) {
-                                       $this->redirectTargetAndText = array( null, $this->getNativeData() );
+                                       $this->redirectTargetAndText = [ null, $this->getNativeData() ];
                                        return $this->redirectTargetAndText;
                                }
 
-                               $this->redirectTargetAndText = array( $title, substr( $text, strlen( $m[0] ) ) );
+                               $this->redirectTargetAndText = [ $title, substr( $text, strlen( $m[0] ) ) ];
                                return $this->redirectTargetAndText;
                        }
                }
 
-               $this->redirectTargetAndText = array( null, $this->getNativeData() );
+               $this->redirectTargetAndText = [ null, $this->getNativeData() ];
                return $this->redirectTargetAndText;
        }
 
@@ -258,10 +256,10 @@ class WikitextContent extends TextContent {
         * Returns true if this content is not a redirect, and this content's text
         * is countable according to the criteria defined by $wgArticleCountMethod.
         *
-        * @param bool $hasLinks If it is known whether this content contains
+        * @param bool|null $hasLinks If it is known whether this content contains
         *    links, provide this information here, to avoid redundant parsing to
         *    find out (default: null).
-        * @param Title $title Optional title, defaults to the title from the current main request.
+        * @param Title|null $title Optional title, defaults to the title from the current main request.
         *
         * @return bool
         */