Make phpcs-strict pass on includes/ (7/7)
authorSiebrand Mazeland <siebrand@kitano.nl>
Thu, 15 May 2014 15:38:28 +0000 (17:38 +0200)
committerSiebrand Mazeland <siebrand@kitano.nl>
Thu, 15 May 2014 18:07:09 +0000 (20:07 +0200)
Change-Id: Ia9baaf0b3cdbe1a3c6b50ef8c4fe86fead88f909

12 files changed:
includes/Article.php
includes/CategoryViewer.php
includes/DeprecatedGlobal.php
includes/EditPage.php
includes/Export.php
includes/Feed.php
includes/HistoryBlob.php
includes/Import.php
includes/Linker.php
includes/Revision.php
includes/installer/WebInstaller.php
includes/parser/Preprocessor_DOM.php

index 3bb1563..09d843d 100644 (file)
  * @internal documentation reviewed 15 Mar 2010
  */
 class Article implements Page {
-       /**@{{
-        * @private
-        */
-
-       /**
-        * The context this Article is executed in
-        * @var IContextSource $mContext
-        */
+       /** @var IContextSource The context this Article is executed in */
        protected $mContext;
 
-       /**
-        * The WikiPage object of this instance
-        * @var WikiPage $mPage
-        */
+       /** @var WikiPage The WikiPage object of this instance */
        protected $mPage;
 
-       /**
-        * ParserOptions object for $wgUser articles
-        * @var ParserOptions $mParserOptions
-        */
+       /** @var ParserOptions ParserOptions object for $wgUser articles */
        public $mParserOptions;
 
        /**
-        * Text of the revision we are working on
-        * @var string $mContent
+        * @var string Text of the revision we are working on
+        * @todo BC cruft
         */
-       var $mContent;                    // !< #BC cruft
+       public $mContent;
 
        /**
-        * Content of the revision we are working on
-        * @var Content
+        * @var Content Content of the revision we are working on
         * @since 1.21
         */
-       var $mContentObject;              // !<
+       protected $mContentObject;
 
-       /**
-        * Is the content ($mContent) already loaded?
-        * @var bool $mContentLoaded
-        */
-       var $mContentLoaded = false;      // !<
+       /** @var bool Is the content ($mContent) already loaded? */
+       protected $mContentLoaded = false;
 
-       /**
-        * The oldid of the article that is to be shown, 0 for the
-        * current revision
-        * @var int|null $mOldId
-        */
-       var $mOldId;                      // !<
+       /** @var int|null The oldid of the article that is to be shown, 0 for the current revision */
+       protected $mOldId;
 
-       /**
-        * Title from which we were redirected here
-        * @var Title $mRedirectedFrom
-        */
-       var $mRedirectedFrom = null;
+       /** @var Title Title from which we were redirected here */
+       protected $mRedirectedFrom = null;
 
-       /**
-        * URL to redirect to or false if none
-        * @var string|bool $mRedirectUrl
-        */
-       var $mRedirectUrl = false;        // !<
+       /** @var string|bool URL to redirect to or false if none */
+       protected $mRedirectUrl = false;
 
-       /**
-        * Revision ID of revision we are working on
-        * @var int $mRevIdFetched
-        */
-       var $mRevIdFetched = 0;           // !<
+       /** @var int Revision ID of revision we are working on */
+       protected $mRevIdFetched = 0;
 
-       /**
-        * Revision we are working on
-        * @var Revision $mRevision
-        */
-       var $mRevision = null;
-
-       /**
-        * ParserOutput object
-        * @var ParserOutput $mParserOutput
-        */
-       var $mParserOutput;
+       /** @var Revision Revision we are working on */
+       protected $mRevision = null;
 
-       /**@}}*/
+       /** @var ParserOutput */
+       public $mParserOutput;
 
        /**
         * Constructor and clear the article
index 305a8e5..49818e6 100644 (file)
  */
 
 class CategoryViewer extends ContextSource {
-       var $limit, $from, $until,
-               $articles, $articles_start_char,
-               $children, $children_start_char,
-               $showGallery, $imgsNoGalley,
-               $imgsNoGallery_start_char,
-               $imgsNoGallery;
+       /** @var int */
+       public $limit;
 
-       /**
-        * @var array
-        */
-       var $nextPage;
+       /** @var array */
+       protected $from;
 
-       /**
-        * @var array
-        */
-       var $flip;
+       /** @var array */
+       protected $until;
 
-       /**
-        * @var Title
-        */
-       var $title;
+       /** @var string[] */
+       public $articles;
 
-       /**
-        * @var Collation
-        */
-       var $collation;
+       /** @var array */
+       public $articles_start_char;
 
-       /**
-        * @var ImageGallery
-        */
-       var $gallery;
+       /** @var array */
+       protected $children;
 
-       /**
-        * Category object for this page
-        * @var Category
-        */
+       /** @var array */
+       protected $children_start_char;
+
+       /** @var bool */
+       protected $showGallery;
+
+       /** @var array */
+       protected $imgsNoGallery_start_char;
+
+       /** @var array */
+       protected $imgsNoGallery;
+
+       /** @var array */
+       protected $nextPage;
+
+       /** @var array */
+       protected $flip;
+
+       /** @var Title */
+       protected $title;
+
+       /** @var Collation */
+       protected $collation;
+
+       /** @var ImageGallery */
+       protected $gallery;
+
+       /** @var Category Category object for this page. */
        private $cat;
 
-       /**
-        * The original query array, to be used in generating paging links.
-        * @var array
-        */
+       /** @var array The original query array, to be used in generating paging links. */
        private $query;
 
        /**
-        * Constructor
-        *
         * @since 1.19 $context is a second, required parameter
         * @param Title $title
         * @param IContextSource $context
index 8a63786..d1fda2e 100644 (file)
@@ -35,7 +35,11 @@ class DeprecatedGlobal extends StubObject {
                $this->mVersion = $version;
        }
 
+       // @codingStandardsIgnoreStart
+       // PSR2.Methods.MethodDeclaration.Underscore
+       // PSR2.Classes.PropertyDeclaration.ScopeMissing
        function _newObject() {
+
                /* Put the caller offset for wfDeprecated as 6, as
                 * that gives the function that uses this object, since:
                 * 1 = this function ( _newObject )
@@ -51,4 +55,5 @@ class DeprecatedGlobal extends StubObject {
                wfDeprecated( '$' . $this->mGlobal, $this->mVersion, false, 6 );
                return $this->mRealValue;
        }
+       // @codingStandardsIgnoreEnd
 }
index dac2d55..5789a2a 100644 (file)
@@ -175,8 +175,9 @@ class EditPage {
         * The cookie will be removed instantly if the JavaScript runs.
         *
         * Otherwise, though, we don't want the cookies to accumulate.
-        * RFC 2109 ( https://www.ietf.org/rfc/rfc2109.txt ) specifies a possible limit of only 20 cookies per domain.
-        * This still applies at least to some versions of IE without full updates:
+        * RFC 2109 ( https://www.ietf.org/rfc/rfc2109.txt ) specifies a possible
+        * limit of only 20 cookies per domain. This still applies at least to some
+        * versions of IE without full updates:
         * https://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx
         *
         * A value of 20 minutes should be enough to take into account slow loads and minor
@@ -184,65 +185,160 @@ class EditPage {
         */
        const POST_EDIT_COOKIE_DURATION = 1200;
 
-       /**
-        * @var Article
-        */
-       var $mArticle;
+       /** @var Article */
+       public $mArticle;
 
-       /**
-        * @var Title
-        */
-       var $mTitle;
+       /** @var Title */
+       public $mTitle;
+
+       /** @var null|Title */
        private $mContextTitle = null;
-       var $action = 'submit';
-       var $isConflict = false;
-       var $isCssJsSubpage = false;
-       var $isCssSubpage = false;
-       var $isJsSubpage = false;
-       var $isWrongCaseCssJsPage = false;
-       var $isNew = false; // new page or new section
-       var $deletedSinceEdit;
-       var $formtype;
-       var $firsttime;
-       var $lastDelete;
-       var $mTokenOk = false;
-       var $mTokenOkExceptSuffix = false;
-       var $mTriedSave = false;
-       var $incompleteForm = false;
-       var $tooBig = false;
-       var $kblength = false;
-       var $missingComment = false;
-       var $missingSummary = false;
-       var $allowBlankSummary = false;
-       var $autoSumm = '';
-       var $hookError = '';
-       #var $mPreviewTemplates;
-
-       /**
-        * @var ParserOutput
-        */
-       var $mParserOutput;
-
-       /**
-        * Has a summary been preset using GET parameter &summary= ?
-        * @var bool
-        */
-       var $hasPresetSummary = false;
-
-       var $mBaseRevision = false;
-       var $mShowSummaryField = true;
+
+       /** @var string */
+       protected $action = 'submit';
+
+       /** @var bool */
+       public $isConflict = false;
+
+       /** @var bool */
+       public $isCssJsSubpage = false;
+
+       /** @var bool */
+       public $isCssSubpage = false;
+
+       /** @var bool */
+       public $isJsSubpage = false;
+
+       /** @var bool */
+       protected $isWrongCaseCssJsPage = false;
+
+       /** @var bool New page or new section */
+       protected $isNew = false;
+
+       /** @var bool */
+       protected $deletedSinceEdit;
+
+       /** @var string */
+       public $formtype;
+
+       /** @var bool */
+       public $firsttime;
+
+       /** @var bool|stdClass */
+       protected $lastDelete;
+
+       /** @var bool */
+       protected $mTokenOk = false;
+
+       /** @var bool */
+       protected $mTokenOkExceptSuffix = false;
+
+       /** @var bool */
+       protected $mTriedSave = false;
+
+       /** @var bool */
+       protected $incompleteForm = false;
+
+       /** @var bool */
+       protected $tooBig = false;
+
+       /** @var bool */
+       protected $kblength = false;
+
+       /** @var bool */
+       protected $missingComment = false;
+
+       /** @var bool */
+       protected $missingSummary = false;
+
+       /** @var bool */
+       protected $allowBlankSummary = false;
+
+       /** @var string */
+       protected $autoSumm = '';
+
+       /** @var string */
+       public $hookError = '';
+
+       /** @var ParserOutput */
+       protected $mParserOutput;
+
+       /** @var bool Has a summary been preset using GET parameter &summary= ? */
+       protected $hasPresetSummary = false;
+
+       /** @var bool */
+       protected $mBaseRevision = false;
+
+       /** @var bool */
+       public $mShowSummaryField = true;
 
        # Form values
-       var $save = false, $preview = false, $diff = false;
-       var $minoredit = false, $watchthis = false, $recreate = false;
-       var $textbox1 = '', $textbox2 = '', $summary = '', $nosummary = false;
-       var $edittime = '', $section = '', $sectiontitle = '', $starttime = '';
-       var $oldid = 0, $editintro = '', $scrolltop = null, $bot = true;
-       var $contentModel = null, $contentFormat = null;
+
+       /** @var bool */
+       public $save = false;
+
+       /** @var bool */
+       public $preview = false;
+
+       /** @var bool */
+       protected $diff = false;
+
+       /** @var bool */
+       public $minoredit = false;
+
+       /** @var bool */
+       protected $watchthis = false;
+
+       /** @var bool */
+       protected $recreate = false;
+
+       /** @var string */
+       public $textbox1 = '';
+
+       /** @var string */
+       public $textbox2 = '';
+
+       /** @var string */
+       public $summary = '';
+
+       /** @var bool */
+       protected $nosummary = false;
+
+       /** @var string */
+       public $edittime = '';
+
+       /** @var string */
+       public $section = '';
+
+       /** @var string */
+       public $sectiontitle = '';
+
+       /** @var string */
+       protected $starttime = '';
+
+       /** @var int */
+       public $oldid = 0;
+
+       /** @var string */
+       protected $editintro = '';
+
+       /** @var null */
+       public $scrolltop = null;
+
+       /** @var bool */
+       public $bot = true;
+
+       /** @var null|string */
+       public $contentModel = null;
+
+       /** @var null|string */
+       public $contentFormat = null;
 
        # Placeholders for text injection by hooks (must be HTML)
        # extensions should take care to _append_ to the present value
-       public $editFormPageTop = ''; // Before even the preview
+
+       /** @var string Before even the preview */
+       public $editFormPageTop = '';
        public $editFormTextTop = '';
        public $editFormTextBeforeContent = '';
        public $editFormTextAfterWarn = '';
@@ -258,13 +354,15 @@ class EditPage {
 
        public $suppressIntro = false;
 
-       /**
-        * Set to true to allow editing of non-text content types.
-        *
-        * @var bool
-        */
+       /** @var bool Set to true to allow editing of non-text content types. */
        public $allowNonTextContent = false;
 
+       /** @var bool */
+       protected $edit;
+
+       /** @var bool */
+       public $live;
+
        /**
         * @param Article $article
         */
@@ -411,6 +509,7 @@ class EditPage {
                $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
                $this->isCssSubpage = $this->mTitle->isCssSubpage();
                $this->isJsSubpage = $this->mTitle->isJsSubpage();
+               // @todo FIXME: Silly assignment.
                $this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
 
                # Show applicable editing introductions
@@ -514,7 +613,10 @@ class EditPage {
                wfRunHooks( 'EditPage::showReadOnlyForm:initial', array( $this, &$wgOut ) );
 
                $wgOut->setRobotPolicy( 'noindex,nofollow' );
-               $wgOut->setPageTitle( wfMessage( 'viewsource-title', $this->getContextTitle()->getPrefixedText() ) );
+               $wgOut->setPageTitle( wfMessage(
+                       'viewsource-title',
+                       $this->getContextTitle()->getPrefixedText()
+               ) );
                $wgOut->addBacklinkSubtitle( $this->getContextTitle() );
                $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $permErrors, 'edit' ) );
                $wgOut->addHTML( "<hr />\n" );
@@ -577,7 +679,9 @@ class EditPage {
                } elseif ( $this->section == 'new' ) {
                        // Nothing *to* preview for new sections
                        return false;
-               } elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() ) && $wgUser->getOption( 'previewonfirst' ) ) {
+               } elseif ( ( $wgRequest->getVal( 'preload' ) !== null || $this->mTitle->exists() )
+                       && $wgUser->getOption( 'previewonfirst' )
+               ) {
                        // Standard preference behavior
                        return true;
                } elseif ( !$this->mTitle->exists()
@@ -747,7 +851,8 @@ class EditPage {
                        ) {
                                $this->allowBlankSummary = true;
                        } else {
-                               $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' ) || !$wgUser->getOption( 'forceeditsummary' );
+                               $this->allowBlankSummary = $request->getBool( 'wpIgnoreBlankSummary' )
+                                       || !$wgUser->getOption( 'forceeditsummary' );
                        }
 
                        $this->autoSumm = $request->getText( 'wpAutoSummary' );
@@ -764,7 +869,8 @@ class EditPage {
                        $this->save = false;
                        $this->diff = false;
                        $this->minoredit = false;
-                       $this->watchthis = $request->getBool( 'watchthis', false ); // Watch may be overridden by request parameters
+                       // Watch may be overridden by request parameters
+                       $this->watchthis = $request->getBool( 'watchthis', false );
                        $this->recreate = false;
 
                        // When creating a new section, we can preload a section title by passing it as the
@@ -790,17 +896,26 @@ class EditPage {
                $this->bot = $request->getBool( 'bot', true );
                $this->nosummary = $request->getBool( 'nosummary' );
 
-               $this->contentModel = $request->getText( 'model', $this->contentModel ); #may be overridden by revision
-               $this->contentFormat = $request->getText( 'format', $this->contentFormat ); #may be overridden by revision
+               // May be overridden by revision.
+               $this->contentModel = $request->getText( 'model', $this->contentModel );
+               // May be overridden by revision.
+               $this->contentFormat = $request->getText( 'format', $this->contentFormat );
 
-               if ( !ContentHandler::getForModelID( $this->contentModel )->isSupportedFormat( $this->contentFormat ) ) {
+               if ( !ContentHandler::getForModelID( $this->contentModel )
+                       ->isSupportedFormat( $this->contentFormat )
+               ) {
                        throw new ErrorPageError(
                                'editpage-notsupportedcontentformat-title',
                                'editpage-notsupportedcontentformat-text',
                                array( $this->contentFormat, ContentHandler::getLocalizedName( $this->contentModel ) )
                        );
                }
-               #TODO: check if the desired model is allowed in this namespace, and if a transition from the page's current model to the new model is allowed
+
+               /**
+                * @todo Check if the desired model is allowed in this namespace, and if
+                *   a transition from the page's current model to the new model is
+                *   allowed.
+                */
 
                $this->live = $request->getCheck( 'live' );
                $this->editintro = $request->getText( 'editintro',
@@ -1257,13 +1372,18 @@ class EditPage {
         * @param array|bool $resultDetails
         *
         * @throws ErrorPageError
-        * return bool false, if output is done, true if rest of the form should be displayed
+        * @return bool false, if output is done, true if rest of the form should be displayed
         */
        private function handleStatus( Status $status, $resultDetails ) {
                global $wgUser, $wgOut;
 
-               // FIXME: once the interface for internalAttemptSave() is made nicer, this should use the message in $status
-               if ( $status->value == self::AS_SUCCESS_UPDATE || $status->value == self::AS_SUCCESS_NEW_ARTICLE ) {
+               /**
+                * @todo FIXME: once the interface for internalAttemptSave() is made
+                *   nicer, this should use the message in $status
+                */
+               if ( $status->value == self::AS_SUCCESS_UPDATE
+                       || $status->value == self::AS_SUCCESS_NEW_ARTICLE
+               ) {
                        $this->didSave = true;
                        if ( !$resultDetails['nullEdit'] ) {
                                $this->setPostEditCookie( $status->value );
@@ -1299,7 +1419,10 @@ class EditPage {
                                $sectionanchor = $resultDetails['sectionanchor'];
 
                                // Give extensions a chance to modify URL query on update
-                               wfRunHooks( 'ArticleUpdateBeforeRedirect', array( $this->mArticle, &$sectionanchor, &$extraQuery ) );
+                               wfRunHooks(
+                                       'ArticleUpdateBeforeRedirect',
+                                       array( $this->mArticle, &$sectionanchor, &$extraQuery )
+                               );
 
                                if ( $resultDetails['redirect'] ) {
                                        if ( $extraQuery == '' ) {
@@ -1402,18 +1525,26 @@ class EditPage {
        /**
         * Attempt submission (no UI)
         *
-        * @param array $result Array to add statuses to, currently with the possible keys:
-        *  spam - string - Spam string from content if any spam is detected by matchSpamRegex
-        *  sectionanchor - string - Section anchor for a section save
-        *  nullEdit - boolean - Set if doEditContent is OK.  True if null edit, false otherwise.
-        *  redirect - boolean -  Set if doEditContent is OK.  True if resulting revision is a redirect
+        * @param array $result Array to add statuses to, currently with the
+        *   possible keys:
+        *   - spam (string): Spam string from content if any spam is detected by
+        *     matchSpamRegex.
+        *   - sectionanchor (string): Section anchor for a section save.
+        *   - nullEdit (boolean): Set if doEditContent is OK.  True if null edit,
+        *     false otherwise.
+        *   - redirect (bool): Set if doEditContent is OK. True if resulting
+        *     revision is a redirect.
         * @param bool $bot True if edit is being made under the bot right.
         *
-        * @return Status Status object, possibly with a message, but always with one of the AS_* constants in $status->value,
+        * @return Status Status object, possibly with a message, but always with
+        *   one of the AS_* constants in $status->value,
         *
-        * FIXME: This interface is TERRIBLE, but hard to get rid of due to various error display idiosyncrasies. There are
-        * also lots of cases where error metadata is set in the object and retrieved later instead of being returned, e.g.
-        * AS_CONTENT_TOO_BIG and AS_BLOCKED_PAGE_FOR_USER. All that stuff needs to be cleaned up some time.
+        * @todo FIXME: This interface is TERRIBLE, but hard to get rid of due to
+        *   various error display idiosyncrasies. There are also lots of cases
+        *   where error metadata is set in the object and retrieved later instead
+        *   of being returned, e.g. AS_CONTENT_TOO_BIG and
+        *   AS_BLOCKED_PAGE_FOR_USER. All that stuff needs to be cleaned up some
+        * time.
         */
        function internalAttemptSave( &$result, $bot = false ) {
                global $wgUser, $wgRequest, $wgParser, $wgMaxArticleSize;
@@ -1454,7 +1585,12 @@ class EditPage {
                        # Construct Content object
                        $textbox_content = $this->toEditContent( $this->textbox1 );
                } catch ( MWContentSerializationException $ex ) {
-                       $status->fatal( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
+                       $status->fatal(
+                               'content-failed-to-parse',
+                               $this->contentModel,
+                               $this->contentFormat,
+                               $ex->getMessage()
+                       );
                        $status->value = self::AS_PARSE_ERROR;
                        wfProfileOut( __METHOD__ . '-checks' );
                        wfProfileOut( __METHOD__ );
@@ -1503,7 +1639,10 @@ class EditPage {
                        wfProfileOut( __METHOD__ );
                        return $status;
                }
-               if ( !wfRunHooks( 'EditFilter', array( $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ) ) ) {
+               if ( !wfRunHooks(
+                       'EditFilter',
+                       array( $this, $this->textbox1, $this->section, &$this->hookError, $this->summary ) )
+               ) {
                        # Error messages etc. could be handled within the hook...
                        $status->fatal( 'hookaborted' );
                        $status->value = self::AS_HOOK_ERROR;
@@ -1625,7 +1764,8 @@ class EditPage {
                                        $content = $content->addSectionHeader( $this->sectiontitle );
 
                                        // Jump to the new section
-                                       $result['sectionanchor'] = $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
+                                       $result['sectionanchor'] =
+                                               $wgParser->guessLegacySectionNameFromWikiText( $this->sectiontitle );
 
                                        // If no edit summary was specified, create one automatically from the section
                                        // title and have it link to the new section. Otherwise, respect the summary as
@@ -1668,14 +1808,19 @@ class EditPage {
                                                // Probably a duplicate submission of a new comment.
                                                // This can happen when squid resends a request after
                                                // a timeout but the first one actually went through.
-                                               wfDebug( __METHOD__ . ": duplicate new section submission; trigger edit conflict!\n" );
+                                               wfDebug( __METHOD__
+                                                       . ": duplicate new section submission; trigger edit conflict!\n" );
                                        } else {
                                                // New comment; suppress conflict.
                                                $this->isConflict = false;
                                                wfDebug( __METHOD__ . ": conflict suppressed; new section\n" );
                                        }
-                               } elseif ( $this->section == '' && Revision::userWasLastToEdit( DB_MASTER, $this->mTitle->getArticleID(),
-                                                       $wgUser->getId(), $this->edittime ) ) {
+                               } elseif ( $this->section == ''
+                                       && Revision::userWasLastToEdit(
+                                               DB_MASTER, $this->mTitle->getArticleID(),
+                                               $wgUser->getId(), $this->edittime
+                                       )
+                               ) {
                                        # Suppress edit conflict with self, except for section edits where merging is required.
                                        wfDebug( __METHOD__ . ": Suppressing edit conflict, same user.\n" );
                                        $this->isConflict = false;
@@ -1692,13 +1837,23 @@ class EditPage {
                        $content = null;
 
                        if ( $this->isConflict ) {
-                               wfDebug( __METHOD__ . ": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
-                                               . " (article time '{$timestamp}')\n" );
-
-                               $content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle, $this->edittime );
+                               wfDebug( __METHOD__
+                                       . ": conflict! getting section '{$this->section}' for time '{$this->edittime}'"
+                                       . " (article time '{$timestamp}')\n" );
+
+                               $content = $this->mArticle->replaceSectionContent(
+                                       $this->section,
+                                       $textbox_content,
+                                       $sectionTitle,
+                                       $this->edittime
+                               );
                        } else {
                                wfDebug( __METHOD__ . ": getting section '{$this->section}'\n" );
-                               $content = $this->mArticle->replaceSectionContent( $this->section, $textbox_content, $sectionTitle );
+                               $content = $this->mArticle->replaceSectionContent(
+                                       $this->section,
+                                       $textbox_content,
+                                       $sectionTitle
+                               );
                        }
 
                        if ( is_null( $content ) ) {
@@ -1782,12 +1937,13 @@ class EditPage {
                                                ->rawParams( $cleanSummary )->inContentLanguage()->text();
                                }
                        } elseif ( $this->section != '' ) {
-                               # Try to get a section anchor from the section source, redirect to edited section if header found
-                               # XXX: might be better to integrate this into Article::replaceSection
-                               # for duplicate heading checking and maybe parsing
+                               # Try to get a section anchor from the section source, redirect
+                               # to edited section if header found.
+                               # XXX: Might be better to integrate this into Article::replaceSection
+                               # for duplicate heading checking and maybe parsing.
                                $hasmatch = preg_match( "/^ *([=]{1,6})(.*?)(\\1) *\\n/i", $this->textbox1, $matches );
-                               # we can't deal with anchors, includes, html etc in the header for now,
-                               # headline would need to be parsed to improve this
+                               # We can't deal with anchors, includes, html etc in the header for now,
+                               # headline would need to be parsed to improve this.
                                if ( $hasmatch && strlen( $matches[2] ) > 0 ) {
                                        $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $matches[2] );
                                }
@@ -2021,9 +2177,14 @@ class EditPage {
                } elseif ( $contextTitle->exists() && $this->section != '' ) {
                        $msg = $this->section == 'new' ? 'editingcomment' : 'editingsection';
                } else {
-                       $msg = $contextTitle->exists() || ( $contextTitle->getNamespace() == NS_MEDIAWIKI && $contextTitle->getDefaultMessageText() !== false ) ?
-                               'editing' : 'creating';
+                       $msg = $contextTitle->exists()
+                               || ( $contextTitle->getNamespace() == NS_MEDIAWIKI
+                                       && $contextTitle->getDefaultMessageText() !== false
+                               )
+                               ? 'editing'
+                               : 'creating';
                }
+
                # Use the title defined by DISPLAYTITLE magic word when present
                $displayTitle = isset( $this->mParserOutput ) ? $this->mParserOutput->getDisplayTitle() : false;
                if ( $displayTitle === false ) {
@@ -2157,14 +2318,16 @@ class EditPage {
         *
         * If $content is null or false or a string, $content is returned unchanged.
         *
-        * If the given Content object is not of a type that can be edited using the text base EditPage,
-        * an exception will be raised. Set $this->allowNonTextContent to true to allow editing of non-textual
+        * If the given Content object is not of a type that can be edited using
+        * the text base EditPage, an exception will be raised. Set
+        * $this->allowNonTextContent to true to allow editing of non-textual
         * content.
         *
         * @param Content|null|bool|string $content
         * @return string The editable text form of the content.
         *
-        * @throws MWException if $content is not an instance of TextContent and $this->allowNonTextContent is not true.
+        * @throws MWException if $content is not an instance of TextContent and
+        *   $this->allowNonTextContent is not true.
         */
        protected function toEditText( $content ) {
                if ( $content === null || $content === false ) {
@@ -2186,16 +2349,18 @@ class EditPage {
        /**
         * Turns the given text into a Content object by unserializing it.
         *
-        * If the resulting Content object is not of a type that can be edited using the text base EditPage,
-        * an exception will be raised. Set $this->allowNonTextContent to true to allow editing of non-textual
+        * If the resulting Content object is not of a type that can be edited using
+        * the text base EditPage, an exception will be raised. Set
+        * $this->allowNonTextContent to true to allow editing of non-textual
         * content.
         *
         * @param string|null|bool $text Text to unserialize
-        * @return Content The content object created from $text. If $text was false or null, false resp. null will be
-        *                 returned instead.
+        * @return Content The content object created from $text. If $text was false
+        *   or null, false resp. null will be  returned instead.
         *
-        * @throws MWException if unserializing the text results in a Content object that is not an instance of TextContent
-        *          and $this->allowNonTextContent is not true.
+        * @throws MWException if unserializing the text results in a Content
+        *   object that is not an instance of TextContent and
+        *   $this->allowNonTextContent is not true.
         */
        protected function toEditContent( $text ) {
                if ( $text === false || $text === null ) {
@@ -2263,9 +2428,16 @@ class EditPage {
 
                // @todo add EditForm plugin interface and use it here!
                //       search for textarea1 and textares2, and allow EditForm to override all uses.
-               $wgOut->addHTML( Html::openElement( 'form', array( 'id' => self::EDITFORM_ID, 'name' => self::EDITFORM_ID,
-                       'method' => 'post', 'action' => $this->getActionURL( $this->getContextTitle() ),
-                       'enctype' => 'multipart/form-data' ) ) );
+               $wgOut->addHTML( Html::openElement(
+                       'form',
+                       array(
+                               'id' => self::EDITFORM_ID,
+                               'name' => self::EDITFORM_ID,
+                               'method' => 'post',
+                               'action' => $this->getActionURL( $this->getContextTitle() ),
+                               'enctype' => 'multipart/form-data'
+                       )
+               ) );
 
                if ( is_callable( $formCallback ) ) {
                        call_user_func_array( $formCallback, array( &$wgOut ) );
@@ -2274,8 +2446,20 @@ class EditPage {
                // Add an empty field to trip up spambots
                $wgOut->addHTML(
                        Xml::openElement( 'div', array( 'id' => 'antispam-container', 'style' => 'display: none;' ) )
-                       . Html::rawElement( 'label', array( 'for' => 'wpAntiSpam' ), wfMessage( 'simpleantispam-label' )->parse() )
-                       . Xml::element( 'input', array( 'type' => 'text', 'name' => 'wpAntispam', 'id' => 'wpAntispam', 'value' => '' ) )
+                       . Html::rawElement(
+                               'label',
+                               array( 'for' => 'wpAntiSpam' ),
+                               wfMessage( 'simpleantispam-label' )->parse()
+                       )
+                       . Xml::element(
+                               'input',
+                               array(
+                                       'type' => 'text',
+                                       'name' => 'wpAntispam',
+                                       'id' => 'wpAntispam',
+                                       'value' => ''
+                               )
+                       )
                        . Xml::closeElement( 'div' )
                );
 
@@ -2392,7 +2576,12 @@ class EditPage {
                                $this->showConflict();
                        } catch ( MWContentSerializationException $ex ) {
                                // this can't really happen, but be nice if it does.
-                               $msg = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
+                               $msg = wfMessage(
+                                       'content-failed-to-parse',
+                                       $this->contentModel,
+                                       $this->contentFormat,
+                                       $ex->getMessage()
+                               );
                                $wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>' );
                        }
                }
@@ -2422,6 +2611,9 @@ class EditPage {
                }
        }
 
+       /**
+        * @return bool
+        */
        protected function showHeader() {
                global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
 
@@ -2479,9 +2671,15 @@ class EditPage {
                                        // Let sysop know that this will make private content public if saved
 
                                        if ( !$revision->userCan( Revision::DELETED_TEXT, $wgUser ) ) {
-                                               $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-permission' );
+                                               $wgOut->wrapWikiMsg(
+                                                       "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
+                                                       'rev-deleted-text-permission'
+                                               );
                                        } elseif ( $revision->isDeleted( Revision::DELETED_TEXT ) ) {
-                                               $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1\n</div>\n", 'rev-deleted-text-view' );
+                                               $wgOut->wrapWikiMsg(
+                                                       "<div class='mw-warning plainlinks'>\n$1\n</div>\n",
+                                                       'rev-deleted-text-view'
+                                               );
                                        }
 
                                        if ( !$revision->isCurrent() ) {
@@ -2498,7 +2696,10 @@ class EditPage {
                }
 
                if ( wfReadOnly() ) {
-                       $wgOut->wrapWikiMsg( "<div id=\"mw-read-only-warning\">\n$1\n</div>", array( 'readonlywarning', wfReadOnlyReason() ) );
+                       $wgOut->wrapWikiMsg(
+                               "<div id=\"mw-read-only-warning\">\n$1\n</div>",
+                               array( 'readonlywarning', wfReadOnlyReason() )
+                       );
                } elseif ( $wgUser->isAnon() ) {
                        if ( $this->formtype != 'preview' ) {
                                $wgOut->wrapWikiMsg( "<div id=\"mw-anon-edit-warning\">\n$1</div>", 'anoneditwarning' );
@@ -2509,15 +2710,24 @@ class EditPage {
                        if ( $this->isCssJsSubpage ) {
                                # Check the skin exists
                                if ( $this->isWrongCaseCssJsPage ) {
-                                       $wgOut->wrapWikiMsg( "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>", array( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() ) );
+                                       $wgOut->wrapWikiMsg(
+                                               "<div class='error' id='mw-userinvalidcssjstitle'>\n$1\n</div>",
+                                               array( 'userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage() )
+                                       );
                                }
                                if ( $this->formtype !== 'preview' ) {
                                        if ( $this->isCssSubpage ) {
-                                               $wgOut->wrapWikiMsg( "<div id='mw-usercssyoucanpreview'>\n$1\n</div>", array( 'usercssyoucanpreview' ) );
+                                               $wgOut->wrapWikiMsg(
+                                                       "<div id='mw-usercssyoucanpreview'>\n$1\n</div>",
+                                                       array( 'usercssyoucanpreview' )
+                                               );
                                        }
 
                                        if ( $this->isJsSubpage ) {
-                                               $wgOut->wrapWikiMsg( "<div id='mw-userjsyoucanpreview'>\n$1\n</div>", array( 'userjsyoucanpreview' ) );
+                                               $wgOut->wrapWikiMsg(
+                                                       "<div id='mw-userjsyoucanpreview'>\n$1\n</div>",
+                                                       array( 'userjsyoucanpreview' )
+                                               );
                                        }
                                }
                        }
@@ -2564,16 +2774,27 @@ class EditPage {
 
                if ( $this->tooBig || $this->kblength > $wgMaxArticleSize ) {
                        $wgOut->wrapWikiMsg( "<div class='error' id='mw-edit-longpageerror'>\n$1\n</div>",
-                               array( 'longpageerror', $wgLang->formatNum( $this->kblength ), $wgLang->formatNum( $wgMaxArticleSize ) ) );
+                               array(
+                                       'longpageerror',
+                                       $wgLang->formatNum( $this->kblength ),
+                                       $wgLang->formatNum( $wgMaxArticleSize )
+                               )
+                       );
                } else {
                        if ( !wfMessage( 'longpage-hint' )->isDisabled() ) {
                                $wgOut->wrapWikiMsg( "<div id='mw-edit-longpage-hint'>\n$1\n</div>",
-                                       array( 'longpage-hint', $wgLang->formatSize( strlen( $this->textbox1 ) ), strlen( $this->textbox1 ) )
+                                       array(
+                                               'longpage-hint',
+                                               $wgLang->formatSize( strlen( $this->textbox1 ) ),
+                                               strlen( $this->textbox1 )
+                                       )
                                );
                        }
                }
                # Add header copyright warning
                $this->showHeaderCopyrightWarning();
+
+               return true;
        }
 
        /**
@@ -2590,7 +2811,9 @@ class EditPage {
         *
         * @return array An array in the format array( $label, $input )
         */
-       function getSummaryInput( $summary = "", $labelText = null, $inputAttrs = null, $spanLabelAttrs = null ) {
+       function getSummaryInput( $summary = "", $labelText = null,
+               $inputAttrs = null, $spanLabelAttrs = null
+       ) {
                // Note: the maxlength is overridden in JS to 255 and to make it use UTF-8 bytes, not characters.
                $inputAttrs = ( is_array( $inputAttrs ) ? $inputAttrs : array() ) + array(
                        'id' => 'wpSummary',
@@ -2607,7 +2830,11 @@ class EditPage {
 
                $label = null;
                if ( $labelText ) {
-                       $label = Xml::tags( 'label', $inputAttrs['id'] ? array( 'for' => $inputAttrs['id'] ) : null, $labelText );
+                       $label = Xml::tags(
+                               'label',
+                               $inputAttrs['id'] ? array( 'for' => $inputAttrs['id'] ) : null,
+                               $labelText
+                       );
                        $label = Xml::tags( 'span', $spanLabelAttrs, $label );
                }
 
@@ -2638,7 +2865,12 @@ class EditPage {
                }
                $summary = $wgContLang->recodeForEdit( $summary );
                $labelText = wfMessage( $isSubjectPreview ? 'subject' : 'summary' )->parse();
-               list( $label, $input ) = $this->getSummaryInput( $summary, $labelText, array( 'class' => $summaryClass ), array() );
+               list( $label, $input ) = $this->getSummaryInput(
+                       $summary,
+                       $labelText,
+                       array( 'class' => $summaryClass ),
+                       array()
+               );
                $wgOut->addHTML( "{$label} {$input}" );
        }
 
@@ -2665,7 +2897,8 @@ class EditPage {
 
                $message = $isSubjectPreview ? 'subject-preview' : 'summary-preview';
 
-               $summary = wfMessage( $message )->parse() . Linker::commentBlock( $summary, $this->mTitle, $isSubjectPreview );
+               $summary = wfMessage( $message )->parse()
+                       . Linker::commentBlock( $summary, $this->mTitle, $isSubjectPreview );
                return Xml::tags( 'div', array( 'class' => 'mw-summary-preview' ), $summary );
        }
 
@@ -2757,7 +2990,11 @@ HTML
                        }
                }
 
-               $this->showTextbox( $textoverride !== null ? $textoverride : $this->textbox1, 'wpTextbox1', $attribs );
+               $this->showTextbox(
+                       $textoverride !== null ? $textoverride : $this->textbox1,
+                       'wpTextbox1',
+                       $attribs
+               );
        }
 
        protected function showTextbox2() {
@@ -2781,7 +3018,9 @@ HTML
                        'id' => $name,
                        'cols' => $wgUser->getIntOption( 'cols' ),
                        'rows' => $wgUser->getIntOption( 'rows' ),
-                       'style' => '' // avoid php notices when appending preferences (appending allows customAttribs['style'] to still work
+                       // Avoid PHP notices when appending preferences
+                       // (appending allows customAttribs['style'] to still work).
+                       'style' => ''
                );
 
                $pageLang = $this->mTitle->getPageLanguage();
@@ -2816,7 +3055,12 @@ HTML
                        try {
                                $this->showDiff();
                        } catch ( MWContentSerializationException $ex ) {
-                               $msg = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
+                               $msg = wfMessage(
+                                       'content-failed-to-parse',
+                                       $this->contentModel,
+                                       $this->contentFormat,
+                                       $ex->getMessage()
+                               );
                                $wgOut->addWikiText( '<div class="error">' . $msg->text() . '</div>' );
                        }
                }
@@ -3054,14 +3298,19 @@ HTML
                                array( 'class' => 'mw-editButtons-pipe-separator' ),
                                wfMessage( 'pipe-separator' )->text() );
                }
-               $edithelpurl = Skin::makeInternalOrExternalUrl( wfMessage( 'edithelppage' )->inContentLanguage()->text() );
+
+               $message = wfMessage( 'edithelppage' )->inContentLanguage()->text();
+               $edithelpurl = Skin::makeInternalOrExternalUrl( $message );
                $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .
                        wfMessage( 'edithelp' )->escaped() . '</a> ' .
                        wfMessage( 'newwindow' )->parse();
+
                $wgOut->addHTML( "      <span class='cancelLink'>{$cancel}</span>\n" );
                $wgOut->addHTML( "      <span class='editHelp'>{$edithelp}</span>\n" );
                $wgOut->addHTML( "</div><!-- editButtons -->\n" );
+
                wfRunHooks( 'EditPage::showStandardInputs:options', array( $this, $wgOut, &$tabindex ) );
+
                $wgOut->addHTML( "</div><!-- editOptions -->\n" );
        }
 
@@ -3148,6 +3397,9 @@ HTML
                return $this->deletedSinceEdit;
        }
 
+       /**
+        * @return bool|stdClass
+        */
        protected function getLastDelete() {
                $dbr = wfGetDB( DB_SLAVE );
                $data = $dbr->selectRow(
@@ -3183,6 +3435,7 @@ HTML
                                $data->log_comment = wfMessage( 'rev-deleted-comment' )->escaped();
                        }
                }
+
                return $data;
        }
 
@@ -3217,7 +3470,10 @@ HTML
                        $content = $this->toEditContent( $this->textbox1 );
 
                        $previewHTML = '';
-                       if ( !wfRunHooks( 'AlternateEditPreview', array( $this, &$content, &$previewHTML, &$this->mParserOutput ) ) ) {
+                       if ( !wfRunHooks(
+                               'AlternateEditPreview',
+                               array( $this, &$content, &$previewHTML, &$this->mParserOutput ) )
+                       ) {
                                wfProfileOut( __METHOD__ );
                                return $previewHTML;
                        }
@@ -3287,7 +3543,11 @@ HTML
                        # But it's now deprecated, so never mind
 
                        $content = $content->preSaveTransform( $this->mTitle, $wgUser, $parserOptions );
-                       $parserOutput = $content->getParserOutput( $this->getArticle()->getTitle(), null, $parserOptions );
+                       $parserOutput = $content->getParserOutput(
+                               $this->getArticle()->getTitle(),
+                               null,
+                               $parserOptions
+                       );
 
                        $previewHTML = $parserOutput->getText();
                        $this->mParserOutput = $parserOutput;
@@ -3297,13 +3557,19 @@ HTML
                                $note .= "\n\n" . implode( "\n\n", $parserOutput->getWarnings() );
                        }
                } catch ( MWContentSerializationException $ex ) {
-                       $m = wfMessage( 'content-failed-to-parse', $this->contentModel, $this->contentFormat, $ex->getMessage() );
+                       $m = wfMessage(
+                               'content-failed-to-parse',
+                               $this->contentModel,
+                               $this->contentFormat,
+                               $ex->getMessage()
+                       );
                        $note .= "\n\n" . $m->parse();
                        $previewHTML = '';
                }
 
                if ( $this->isConflict ) {
-                       $conflict = '<h2 id="mw-previewconflict">' . wfMessage( 'previewconflict' )->escaped() . "</h2>\n";
+                       $conflict = '<h2 id="mw-previewconflict">'
+                               . wfMessage( 'previewconflict' )->escaped() . "</h2>\n";
                } else {
                        $conflict = '<hr />';
                }
@@ -3560,6 +3826,7 @@ HTML
        public function getEditButtons( &$tabindex ) {
                $buttons = array();
 
+               // @todo FIXME: Hardcoded square brackets.
                $temp = array(
                        'id' => 'wpSave',
                        'name' => 'wpSave',
@@ -3567,11 +3834,13 @@ HTML
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'savearticle' )->text(),
                        'accesskey' => wfMessage( 'accesskey-save' )->text(),
-                       'title' => wfMessage( 'tooltip-save' )->text() . ' [' . wfMessage( 'accesskey-save' )->text() . ']',
+                       'title' => wfMessage( 'tooltip-save' )->text()
+                               . ' [' . wfMessage( 'accesskey-save' )->text() . ']',
                );
                $buttons['save'] = Xml::element( 'input', $temp, '' );
 
                ++$tabindex; // use the same for preview and live preview
+               // @todo FIXME: Hardcoded square brackets.
                $temp = array(
                        'id' => 'wpPreview',
                        'name' => 'wpPreview',
@@ -3579,11 +3848,13 @@ HTML
                        'tabindex' => $tabindex,
                        'value' => wfMessage( 'showpreview' )->text(),
                        'accesskey' => wfMessage( 'accesskey-preview' )->text(),
-                       'title' => wfMessage( 'tooltip-preview' )->text() . ' [' . wfMessage( 'accesskey-preview' )->text() . ']',
+                       'title' => wfMessage( 'tooltip-preview' )->text()
+                               . ' [' . wfMessage( 'accesskey-preview' )->text() . ']',
                );
                $buttons['preview'] = Xml::element( 'input', $temp, '' );
                $buttons['live'] = '';
 
+               // @todo FIXME: Hardcoded square brackets.
                $temp = array(
                        'id' => 'wpDiff',
                        'name' => 'wpDiff',
@@ -3591,7 +3862,8 @@ HTML
                        'tabindex' => ++$tabindex,
                        'value' => wfMessage( 'showdiff' )->text(),
                        'accesskey' => wfMessage( 'accesskey-diff' )->text(),
-                       'title' => wfMessage( 'tooltip-diff' )->text() . ' [' . wfMessage( 'accesskey-diff' )->text() . ']',
+                       'title' => wfMessage( 'tooltip-diff' )->text()
+                               . ' [' . wfMessage( 'accesskey-diff' )->text() . ']',
                );
                $buttons['diff'] = Xml::element( 'input', $temp, '' );
 
@@ -3781,7 +4053,8 @@ HTML
                $bytesleft = 0;
                $result = "";
                $working = 0;
-               for ( $i = 0; $i < strlen( $invalue ); $i++ ) {
+               $valueLength = strlen( $invalue );
+               for ( $i = 0; $i < $valueLength; $i++ ) {
                        $bytevalue = ord( $invalue[$i] );
                        if ( $bytevalue <= 0x7F ) { // 0xxx xxxx
                                $result .= chr( $bytevalue );
index 7295a76..4c71eb9 100644 (file)
  * @ingroup SpecialPage Dump
  */
 class WikiExporter {
-       var $list_authors = false; # Return distinct author list (when not returning full history)
-       var $author_list = "";
+       /** @var bool Return distinct author list (when not returning full history) */
+       public $list_authors = false;
 
-       var $dumpUploads = false;
-       var $dumpUploadFileContents = false;
+       /** @var bool */
+       public $dumpUploads = false;
+
+       /** @var bool */
+       public $dumpUploadFileContents = false;
+
+       /** @var string */
+       protected $author_list = "";
 
        const FULL = 1;
        const CURRENT = 2;
@@ -49,14 +55,14 @@ class WikiExporter {
        const TEXT = 0;
        const STUB = 1;
 
-       var $buffer;
+       /** @var int */
+       protected $buffer;
 
-       var $text;
+       /** @var int */
+       protected $text;
 
-       /**
-        * @var DumpOutput
-        */
-       var $sink;
+       /** @var DumpOutput */
+       protected $sink;
 
        /**
         * Returns the export schema version.
@@ -1144,7 +1150,6 @@ class DumpPipeOutput extends DumpFileOutput {
                        }
                }
        }
-
 }
 
 /**
@@ -1152,7 +1157,6 @@ class DumpPipeOutput extends DumpFileOutput {
  * @ingroup Dump
  */
 class DumpGZipOutput extends DumpPipeOutput {
-
        /**
         * @param string $file
         */
@@ -1166,7 +1170,6 @@ class DumpGZipOutput extends DumpPipeOutput {
  * @ingroup Dump
  */
 class DumpBZip2Output extends DumpPipeOutput {
-
        /**
         * @param string $file
         */
@@ -1180,7 +1183,6 @@ class DumpBZip2Output extends DumpPipeOutput {
  * @ingroup Dump
  */
 class Dump7ZipOutput extends DumpPipeOutput {
-
        /**
         * @param string $file
         */
@@ -1227,7 +1229,6 @@ class Dump7ZipOutput extends DumpPipeOutput {
  * @ingroup Dump
  */
 class DumpFilter {
-
        /**
         * @var DumpOutput
         * FIXME will need to be made protected whenever legacy code
@@ -1337,7 +1338,6 @@ class DumpFilter {
  * @ingroup Dump
  */
 class DumpNotalkFilter extends DumpFilter {
-
        /**
         * @param object $page
         * @return bool
@@ -1352,8 +1352,11 @@ class DumpNotalkFilter extends DumpFilter {
  * @ingroup Dump
  */
 class DumpNamespaceFilter extends DumpFilter {
-       var $invert = false;
-       var $namespaces = array();
+       /** @var bool */
+       protected $invert = false;
+
+       /** @var array */
+       protected $namespaces = array();
 
        /**
         * @param DumpOutput $sink
@@ -1417,7 +1420,13 @@ class DumpNamespaceFilter extends DumpFilter {
  * @ingroup Dump
  */
 class DumpLatestFilter extends DumpFilter {
-       var $page, $pageString, $rev, $revString;
+       protected $page;
+
+       protected $pageString;
+
+       protected $rev;
+
+       protected $revString;
 
        /**
         * @param object $page
@@ -1543,12 +1552,12 @@ class DumpMultiWriter {
                }
                return $filenames;
        }
-
 }
 
 /**
  * @param string $string
  * @return string
+ * @todo FIXME: Only used in OAI extension. Move over there.
  */
 function xmlsafe( $string ) {
        wfProfileIn( __FUNCTION__ );
index 7089c92..1674b13 100644 (file)
  * @ingroup Feed
  */
 class FeedItem {
-       /**
-        * @var Title
-        */
-       var $title;
+       /** @var Title */
+       protected $title;
+
+       protected $description;
+
+       protected $url;
+
+       protected $date;
 
-       var $description;
-       var $url;
-       var $date;
-       var $author;
-       var $uniqueId;
-       var $comments;
-       var $rssIsPermalink = false;
+       protected $author;
+
+       protected $uniqueId;
+
+       protected $comments;
+
+       public $rssIsPermalink = false;
 
        /**
         * Constructor
@@ -238,27 +242,35 @@ abstract class ChannelFeed extends FeedItem {
         * Return an internet media type to be sent in the headers.
         *
         * @return string
-        * @private
         */
-       function contentType() {
+       private function contentType() {
                global $wgRequest;
+
                $ctype = $wgRequest->getVal( 'ctype', 'application/xml' );
-               $allowedctypes = array( 'application/xml', 'text/xml', 'application/rss+xml', 'application/atom+xml' );
+               $allowedctypes = array(
+                       'application/xml',
+                       'text/xml',
+                       'application/rss+xml',
+                       'application/atom+xml'
+               );
+
                return ( in_array( $ctype, $allowedctypes ) ? $ctype : 'application/xml' );
        }
 
        /**
         * Output the initial XML headers with a stylesheet for legibility
         * if someone finds it in a browser.
-        * @private
         */
-       function outXmlHeader() {
+       protected function outXmlHeader() {
                global $wgStylePath, $wgStyleVersion;
 
                $this->httpHeaders();
                echo '<?xml version="1.0"?>' . "\n";
                echo '<?xml-stylesheet type="text/css" href="' .
-                       htmlspecialchars( wfExpandUrl( "$wgStylePath/common/feed.css?$wgStyleVersion", PROTO_CURRENT ) ) .
+                       htmlspecialchars( wfExpandUrl(
+                               "$wgStylePath/common/feed.css?$wgStyleVersion",
+                               PROTO_CURRENT
+                       ) ) .
                        '"?' . ">\n";
        }
 }
@@ -303,6 +315,7 @@ class RSSFeed extends ChannelFeed {
         * @param FeedItem $item Item to be output
         */
        function outItem( $item ) {
+               // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
        ?>
                <item>
                        <title><?php print $item->getTitle(); ?></title>
@@ -314,6 +327,7 @@ class RSSFeed extends ChannelFeed {
                        <?php if ( $item->getComments() ) { ?><comments><?php print wfExpandUrl( $item->getComments(), PROTO_CURRENT ); ?></comments><?php }?>
                </item>
 <?php
+               // @codingStandardsIgnoreEnd
        }
 
        /**
@@ -348,6 +362,7 @@ class AtomFeed extends ChannelFeed {
                global $wgVersion;
 
                $this->outXmlHeader();
+               // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
                ?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="<?php print $this->getLanguage() ?>">
                <id><?php print $this->getFeedId() ?></id>
                <title><?php print $this->getTitle() ?></title>
@@ -358,6 +373,7 @@ class AtomFeed extends ChannelFeed {
                <generator>MediaWiki <?php print $wgVersion ?></generator>
 
 <?php
+               // @codingStandardsIgnoreEnd
        }
 
        /**
@@ -367,18 +383,16 @@ class AtomFeed extends ChannelFeed {
         * have to change the id? Maybe? Maybe not.
         *
         * @return string
-        * @private
         */
-       function getFeedId() {
+       private function getFeedId() {
                return $this->getSelfUrl();
        }
 
        /**
         * Atom 1.0 requests a self-reference to the feed.
         * @return string
-        * @private
         */
-       function getSelfUrl() {
+       private function getSelfUrl() {
                global $wgRequest;
                return htmlspecialchars( $wgRequest->getFullRequestURL() );
        }
@@ -389,6 +403,7 @@ class AtomFeed extends ChannelFeed {
         */
        function outItem( $item ) {
                global $wgMimeType;
+               // @codingStandardsIgnoreStart Ignore long lines and formatting issues.
        ?>
        <entry>
                <id><?php print $item->getUniqueId(); ?></id>
@@ -412,5 +427,6 @@ class AtomFeed extends ChannelFeed {
         */
        function outFooter() {?>
        </feed><?php
+               // @codingStandardsIgnoreEnd
        }
 }
index da54673..e95536a 100644 (file)
@@ -25,8 +25,7 @@
  * two-part external storage URLs. Used for represent efficient concatenated
  * storage, and migration-related pointer objects.
  */
-interface HistoryBlob
-{
+interface HistoryBlob {
        /**
         * Adds an item of text, returns a stub object which points to the item.
         * You must call setLocation() on the stub object before storing it to the
@@ -71,8 +70,7 @@ interface HistoryBlob
  * Concatenated gzip (CGZ) storage
  * Improves compression ratio by concatenating like objects before gzipping
  */
-class ConcatenatedGzipHistoryBlob implements HistoryBlob
-{
+class ConcatenatedGzipHistoryBlob implements HistoryBlob {
        public $mVersion = 0, $mCompressed = false, $mItems = array(), $mDefaultHash = '';
        public $mSize = 0;
        public $mMaxSize = 10000000;
@@ -83,7 +81,8 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
         */
        public function __construct() {
                if ( !function_exists( 'gzdeflate' ) ) {
-                       throw new MWException( "Need zlib support to read or write this kind of history object (ConcatenatedGzipHistoryBlob)\n" );
+                       throw new MWException( "Need zlib support to read or write this "
+                               . "kind of history object (ConcatenatedGzipHistoryBlob)\n" );
                }
        }
 
@@ -190,14 +189,21 @@ class ConcatenatedGzipHistoryBlob implements HistoryBlob
  */
 class HistoryBlobStub {
        /**
-        * One-step cache variable to hold base blobs; operations that
-        * pull multiple revisions may often pull multiple times from
-        * the same blob. By keeping the last-used one open, we avoid
-        * redundant unserialization and decompression overhead.
+        * @var array One-step cache variable to hold base blobs; operations that
+        * pull multiple revisions may often pull multiple times from the same
+        * blob. By keeping the last-used one open, we avoid redundant
+        * unserialization and decompression overhead.
         */
        protected static $blobCache = array();
 
-       var $mOldId, $mHash, $mRef;
+       /** @var int */
+       protected $mOldId;
+
+       /** @var string */
+       protected $mHash;
+
+       /** @var  */
+       protected $mRef;
 
        /**
         * @param string $hash The content hash of the text
@@ -240,10 +246,16 @@ class HistoryBlobStub {
                        $obj = self::$blobCache[$this->mOldId];
                } else {
                        $dbr = wfGetDB( DB_SLAVE );
-                       $row = $dbr->selectRow( 'text', array( 'old_flags', 'old_text' ), array( 'old_id' => $this->mOldId ) );
+                       $row = $dbr->selectRow(
+                               'text',
+                               array( 'old_flags', 'old_text' ),
+                               array( 'old_id' => $this->mOldId )
+                       );
+
                        if ( !$row ) {
                                return false;
                        }
+
                        $flags = explode( ',', $row->old_flags );
                        if ( in_array( 'external', $flags ) ) {
                                $url = $row->old_text;
@@ -254,6 +266,7 @@ class HistoryBlobStub {
                                $row->old_text = ExternalStore::fetchFromUrl( $url );
 
                        }
+
                        if ( !in_array( 'object', $flags ) ) {
                                return false;
                        }
@@ -276,6 +289,7 @@ class HistoryBlobStub {
                        $obj->uncompress();
                        self::$blobCache = array( $this->mOldId => $obj );
                }
+
                return $obj->getItem( $this->mHash );
        }
 
@@ -298,7 +312,8 @@ class HistoryBlobStub {
  * on conversion if $wgLegacySchemaConversion is set to true.
  */
 class HistoryBlobCurStub {
-       var $mCurId;
+       /** @var int */
+       private $mCurId;
 
        /**
         * @param int $curid The cur_id pointed to
@@ -335,50 +350,43 @@ class HistoryBlobCurStub {
  * Requires xdiff 1.5+ and zlib
  */
 class DiffHistoryBlob implements HistoryBlob {
-       /** Uncompressed item cache */
-       var $mItems = array();
+       /** @var array Uncompressed item cache */
+       protected $mItems = array();
 
-       /** Total uncompressed size */
-       var $mSize = 0;
+       /** @var int Total uncompressed size */
+       protected $mSize = 0;
 
        /**
-        * Array of diffs. If a diff D from A to B is notated D = B - A, and Z is
-        * an empty string:
+        * @var array Array of diffs. If a diff D from A to B is notated D = B - A,
+        * and Z is an empty string:
         *
         *              { item[map[i]] - item[map[i-1]]   where i > 0
         *    diff[i] = {
         *              { item[map[i]] - Z                where i = 0
         */
-       var $mDiffs;
+       protected $mDiffs;
 
-       /** The diff map, see above */
-       var $mDiffMap;
+       /** @var array The diff map, see above */
+       protected $mDiffMap;
 
-       /**
-        * The key for getText()
+       /** @var int The key for getText()
         */
-       var $mDefaultKey;
+       protected $mDefaultKey;
 
-       /**
-        * Compressed storage
-        */
-       var $mCompressed;
+       /** @var string Compressed storage */
+       protected $mCompressed;
 
-       /**
-        * True if the object is locked against further writes
-        */
-       var $mFrozen = false;
+       /** @var bool True if the object is locked against further writes */
+       protected $mFrozen = false;
 
        /**
-        * The maximum uncompressed size before the object becomes sad
+        * @var int The maximum uncompressed size before the object becomes sad
         * Should be less than max_allowed_packet
         */
-       var $mMaxSize = 10000000;
+       public $mMaxSize = 10000000;
 
-       /**
-        * The maximum number of text items before the object becomes sad
-        */
-       var $mMaxCount = 100;
+       /** @var int The maximum number of text items before the object becomes sad */
+       public $mMaxCount = 100;
 
        /** Constants from xdiff.h */
        const XDL_BDOP_INS = 1;
@@ -460,7 +468,8 @@ class DiffHistoryBlob implements HistoryBlob {
                );
                $smallFactor = 0.5;
 
-               for ( $i = 0; $i < count( $this->mItems ); $i++ ) {
+               $mItemsCount = count( $this->mItems );
+               for ( $i = 0; $i < $mItemsCount; $i++ ) {
                        $text = $this->mItems[$i];
                        if ( $i == 0 ) {
                                $seqName = 'main';
@@ -496,7 +505,8 @@ class DiffHistoryBlob implements HistoryBlob {
                                $this->mDiffs[] = $this->diff( $tail, $head );
                        }
                        $this->mDiffMap[] = $seq['map'][0];
-                       for ( $i = 1; $i < count( $seq['diffs'] ); $i++ ) {
+                       $diffsCount = count( $seq['diffs'] );
+                       for ( $i = 1; $i < $diffsCount; $i++ ) {
                                $this->mDiffs[] = $seq['diffs'][$i];
                                $this->mDiffMap[] = $seq['map'][$i];
                        }
@@ -606,7 +616,8 @@ class DiffHistoryBlob implements HistoryBlob {
                        return;
                }
                $tail = '';
-               for ( $diffKey = 0; $diffKey < count( $this->mDiffs ); $diffKey++ ) {
+               $mDiffsCount = count( $this->mDiffs );
+               for ( $diffKey = 0; $diffKey < $mDiffsCount; $diffKey++ ) {
                        $textKey = $this->mDiffMap[$diffKey];
                        $text = $this->patch( $tail, $this->mDiffs[$diffKey] );
                        $this->mItems[$textKey] = $text;
index 59fa583..743037c 100644 (file)
@@ -218,7 +218,11 @@ class WikiImporter {
                        $this->mTargetRootPage = null;
                } elseif ( $rootpage !== '' ) {
                        $rootpage = rtrim( $rootpage, '/' ); //avoid double slashes
-                       $title = Title::newFromText( $rootpage, !is_null( $this->mTargetNamespace ) ? $this->mTargetNamespace : NS_MAIN );
+                       $title = Title::newFromText( $rootpage, !is_null( $this->mTargetNamespace )
+                               ? $this->mTargetNamespace
+                               : NS_MAIN
+                       );
+
                        if ( !$title || $title->isExternal() ) {
                                $status->fatal( 'import-rootpage-invalid' );
                        } else {
@@ -285,12 +289,12 @@ class WikiImporter {
 
        /**
         * Default per-revision callback, performs the import.
-        * @param WikiRevision $rev
+        * @param WikiRevision $revision
         * @return bool
         */
-       public function importLogItem( $rev ) {
+       public function importLogItem( $revision ) {
                $dbw = wfGetDB( DB_MASTER );
-               return $dbw->deadlockLoop( array( $rev, 'importLogItem' ) );
+               return $dbw->deadlockLoop( array( $revision, 'importLogItem' ) );
        }
 
        /**
@@ -310,7 +314,7 @@ class WikiImporter {
         * @param int $revCount
         * @param int $sRevCount
         * @param array $pageInfo
-        * @return
+        * @return bool
         */
        public function finishImportPage( $title, $origTitle, $revCount, $sRevCount, $pageInfo ) {
                $args = func_get_args();
@@ -900,10 +904,16 @@ class WikiImporter {
 
 /** This is a horrible hack used to keep source compatibility */
 class UploadSourceAdapter {
-       static $sourceRegistrations = array();
+       /** @var array */
+       private static $sourceRegistrations = array();
 
+       /** @var string */
        private $mSource;
+
+       /** @var string */
        private $mBuffer;
+
+       /** @var int */
        private $mPosition;
 
        /**
@@ -1042,30 +1052,80 @@ class XMLReader2 extends XMLReader {
  * @ingroup SpecialPage
  */
 class WikiRevision {
-       var $importer = null;
-
-       /**
-        * @var Title
-        */
-       var $title = null;
-       var $id = 0;
-       var $timestamp = "20010115000000";
-       var $user = 0;
-       var $user_text = "";
-       var $model = null;
-       var $format = null;
-       var $text = "";
-       var $content = null;
-       var $comment = "";
-       var $minor = false;
-       var $type = "";
-       var $action = "";
-       var $params = "";
-       var $fileSrc = '';
-       var $sha1base36 = false;
-       var $isTemp = false;
-       var $archiveName = '';
-       var $fileIsTemp;
+       /** @todo Unused? */
+       private $importer = null;
+
+       /** @var Title */
+       public $title = null;
+
+       /** @var int */
+       private $id = 0;
+
+       /** @var string */
+       public $timestamp = "20010115000000";
+
+       /**
+        * @var int
+        * @todo Can't find any uses. Public, because that's suspicious. Get clarity. */
+       public $user = 0;
+
+       /** @var string */
+       public $user_text = "";
+
+       /** @var string */
+       protected $model = null;
+
+       /** @var string */
+       protected $format = null;
+
+       /** @var string */
+       public $text = "";
+
+       /** @var int */
+       protected $size;
+
+       /** @var Content */
+       protected $content = null;
+
+       /** @var string */
+       public $comment = "";
+
+       /** @var bool */
+       protected $minor = false;
+
+       /** @var string */
+       protected $type = "";
+
+       /** @var string */
+       protected $action = "";
+
+       /** @var string */
+       protected $params = "";
+
+       /** @var string */
+       protected $fileSrc = '';
+
+       /** @var bool|string */
+       protected $sha1base36 = false;
+
+       /**
+        * @var bool
+        * @todo Unused?
+        */
+       private $isTemp = false;
+
+       /** @var string */
+       protected $archiveName = '';
+
+       protected $filename;
+
+       /** @var mixed */
+       protected $src;
+
+       /** @todo Unused? */
+       private $fileIsTemp;
+
+       /** @var bool */
        private $mNoUpdates = false;
 
        /**
@@ -1076,7 +1136,8 @@ class WikiRevision {
                if ( is_object( $title ) ) {
                        $this->title = $title;
                } elseif ( is_null( $title ) ) {
-                       throw new MWException( "WikiRevision given a null title in import. You may need to adjust \$wgLegalTitleChars." );
+                       throw new MWException( "WikiRevision given a null title in import. "
+                               . "You may need to adjust \$wgLegalTitleChars." );
                } else {
                        throw new MWException( "WikiRevision given non-object title in import." );
                }
@@ -1438,7 +1499,8 @@ class WikiRevision {
                        'page' => $pageId,
                        'content_model' => $this->getModel(),
                        'content_format' => $this->getFormat(),
-                       'text' => $this->getContent()->serialize( $this->getFormat() ), //XXX: just set 'content' => $this->getContent()?
+                       //XXX: just set 'content' => $this->getContent()?
+                       'text' => $this->getContent()->serialize( $this->getFormat() ),
                        'comment' => $this->getComment(),
                        'user' => $userId,
                        'user_text' => $userText,
@@ -1450,7 +1512,11 @@ class WikiRevision {
 
                if ( $changed !== false && !$this->mNoUpdates ) {
                        wfDebug( __METHOD__ . ": running updates\n" );
-                       $page->doEditUpdates( $revision, $userObj, array( 'created' => $created, 'oldcountable' => $oldcountable ) );
+                       $page->doEditUpdates(
+                               $revision,
+                               $userObj,
+                               array( 'created' => $created, 'oldcountable' => $oldcountable )
+                       );
                }
 
                return true;
@@ -1482,8 +1548,9 @@ class WikiRevision {
                );
                // @todo FIXME: This could fail slightly for multiple matches :P
                if ( $prior ) {
-                       wfDebug( __METHOD__ . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp " .
-                               $this->timestamp . "\n" );
+                       wfDebug( __METHOD__
+                               . ": skipping existing item for Log:{$this->type}/{$this->action}, timestamp "
+                               . $this->timestamp . "\n" );
                        return;
                }
                $log_id = $dbw->nextSequenceValue( 'logging_log_id_seq' );
@@ -1680,13 +1747,18 @@ class ImportStreamSource {
                }
                if ( !empty( $upload['error'] ) ) {
                        switch ( $upload['error'] ) {
-                               case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini.
+                               case 1:
+                                       # The uploaded file exceeds the upload_max_filesize directive in php.ini.
                                        return Status::newFatal( 'importuploaderrorsize' );
-                               case 2: # The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
+                               case 2:
+                                       # The uploaded file exceeds the MAX_FILE_SIZE directive that
+                                       # was specified in the HTML form.
                                        return Status::newFatal( 'importuploaderrorsize' );
-                               case 3: # The uploaded file was only partially uploaded
+                               case 3:
+                                       # The uploaded file was only partially uploaded
                                        return Status::newFatal( 'importuploaderrorpartial' );
-                               case 6: #Missing a temporary folder.
+                               case 6:
+                                       # Missing a temporary folder.
                                        return Status::newFatal( 'importuploaderrortemp' );
                                # case else: # Currently impossible
                        }
@@ -1731,7 +1803,9 @@ class ImportStreamSource {
         * @param int $pageLinkDepth
         * @return Status
         */
-       public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) {
+       public static function newFromInterwiki( $interwiki, $page, $history = false,
+               $templates = false, $pageLinkDepth = 0
+       ) {
                if ( $page == '' ) {
                        return Status::newFatal( 'import-noarticle' );
                }
index 894c97d..d0759ed 100644 (file)
@@ -30,7 +30,6 @@
  * @ingroup Skins
  */
 class Linker {
-
        /**
         * Flags for userToolLinks()
         */
@@ -44,7 +43,8 @@ class Linker {
         * @param string $class The contents of the class attribute; if an empty
         *   string is passed, which is the default value, defaults to 'external'.
         * @return string
-        * @deprecated since 1.18 Just pass the external class directly to something using Html::expandAttributes
+        * @deprecated since 1.18 Just pass the external class directly to something
+        *   using Html::expandAttributes.
         */
        static function getExternalLinkAttributes( $class = 'external' ) {
                wfDeprecated( __METHOD__, '1.18' );
@@ -389,13 +389,15 @@ class Linker {
                if ( $target->getPrefixedText() === '' && $target->hasFragment() ) {
                        return htmlspecialchars( $target->getFragment() );
                }
+
                return htmlspecialchars( $target->getPrefixedText() );
        }
 
        /**
-        * Make appropriate markup for a link to the current article. This is currently rendered
-        * as the bold link text. The calling sequence is the same as the other make*LinkObj static functions,
-        * despite $query not being used.
+        * Make appropriate markup for a link to the current article. This is
+        * currently rendered as the bold link text. The calling sequence is the
+        * same as the other make*LinkObj static functions, despite $query not
+        * being used.
         *
         * @param Title $nt
         * @param string $html [optional]
@@ -403,7 +405,6 @@ class Linker {
         * @param string $trail [optional]
         * @param string $prefix [optional]
         *
-        *
         * @return string
         */
        public static function makeSelfLinkObj( $nt, $html = '', $query = '', $trail = '', $prefix = '' ) {
@@ -491,7 +492,8 @@ class Linker {
                $img = '';
                $success = wfRunHooks( 'LinkerMakeExternalImage', array( &$url, &$alt, &$img ) );
                if ( !$success ) {
-                       wfDebug( "Hook LinkerMakeExternalImage changed the output of external image with url {$url} and alt text {$alt} to {$img}\n", true );
+                       wfDebug( "Hook LinkerMakeExternalImage changed the output of external image "
+                               . "with url {$url} and alt text {$alt} to {$img}\n", true );
                        return $img;
                }
                return Html::element( 'img',
@@ -536,8 +538,9 @@ class Linker {
         * @since 1.20
         * @return string HTML for an image, with links, wrappers, etc.
         */
-       public static function makeImageLink( /*Parser*/ $parser, Title $title, $file, $frameParams = array(),
-               $handlerParams = array(), $time = false, $query = "", $widthOption = null
+       public static function makeImageLink( /*Parser*/ $parser, Title $title,
+               $file, $frameParams = array(), $handlerParams = array(), $time = false,
+               $query = "", $widthOption = null
        ) {
                $res = null;
                $dummy = new DummyLinker;
@@ -587,8 +590,14 @@ class Linker {
                                $hp['width'] = $file->getWidth( $page );
                        }
 
-                       if ( isset( $fp['thumbnail'] ) || isset( $fp['manualthumb'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
+                       if ( isset( $fp['thumbnail'] )
+                               || isset( $fp['manualthumb'] )
+                               || isset( $fp['framed'] )
+                               || isset( $fp['frameless'] )
+                               || !$hp['width']
+                       ) {
                                global $wgThumbLimits, $wgThumbUpright;
+
                                if ( $widthOption === null || !isset( $wgThumbLimits[$widthOption] ) ) {
                                        $widthOption = User::getDefaultOption( 'thumbsize' );
                                }
@@ -597,7 +606,10 @@ class Linker {
                                if ( isset( $fp['upright'] ) && $fp['upright'] == 0 ) {
                                        $fp['upright'] = $wgThumbUpright;
                                }
-                               // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
+
+                               // For caching health: If width scaled down due to upright
+                               // parameter, round to full __0 pixel to avoid the creation of a
+                               // lot of odd thumbs.
                                $prefWidth = isset( $fp['upright'] ) ?
                                        round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
                                        $wgThumbLimits[$widthOption];
@@ -632,8 +644,9 @@ class Linker {
 
                if ( $file && isset( $fp['frameless'] ) ) {
                        $srcWidth = $file->getWidth( $page );
-                       # For "frameless" option: do not present an image bigger than the source (for bitmap-style images)
-                       # This is the same behavior as the "thumb" option does it already.
+                       # For "frameless" option: do not present an image bigger than the
+                       # source (for bitmap-style images). This is the same behavior as the
+                       # "thumb" option does it already.
                        if ( $srcWidth && !$file->mustRender() && $hp['width'] > $srcWidth ) {
                                $hp['width'] = $srcWidth;
                        }
@@ -831,7 +844,9 @@ class Linker {
                        $fp['link-url'] = $url;
                }
 
-               $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
+               $s = "<div class=\"thumb t{$fp['align']}\">"
+                       . "<div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
+
                if ( !$exists ) {
                        $s .= self::makeBrokenImageLinkObj( $title, $fp['title'], '', '', '', $time == true );
                        $zoomIcon = '';
@@ -845,7 +860,9 @@ class Linker {
                        $params = array(
                                'alt' => $fp['alt'],
                                'title' => $fp['title'],
-                               'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== '' ? $fp['class'] . ' ' : '' ) . 'thumbimage'
+                               'img-class' => ( isset( $fp['class'] ) && $fp['class'] !== ''
+                                       ? $fp['class'] . ' '
+                                       : '' ) . 'thumbimage'
                        );
                        $params = self::getImageLinkMTOParams( $fp, $query ) + $params;
                        $s .= $thumb->toHtml( $params );
@@ -858,7 +875,8 @@ class Linker {
                                                'class' => 'internal',
                                                'title' => wfMessage( 'thumbnail-more' )->text() ),
                                                Html::element( 'img', array(
-                                                       'src' => $wgStylePath . '/common/images/magnify-clip' . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png',
+                                                       'src' => $wgStylePath . '/common/images/magnify-clip'
+                                                               . ( $wgContLang->isRTL() ? '-rtl' : '' ) . '.png',
                                                        'width' => 15,
                                                        'height' => 11,
                                                        'alt' => "" ) ) ) );
@@ -910,7 +928,9 @@ class Linker {
         * @param bool $time A file of a certain timestamp was requested
         * @return string
         */
-       public static function makeBrokenImageLinkObj( $title, $label = '', $query = '', $unused1 = '', $unused2 = '', $time = false ) {
+       public static function makeBrokenImageLinkObj( $title, $label = '',
+               $query = '', $unused1 = '', $unused2 = '', $time = false
+       ) {
                global $wgEnableUploads, $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
                if ( ! $title instanceof Title ) {
                        return "<!-- ERROR -->" . htmlspecialchars( $label );
@@ -922,7 +942,9 @@ class Linker {
                $encLabel = htmlspecialchars( $label );
                $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
 
-               if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads ) && !$currentExists ) {
+               if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
+                       && !$currentExists
+               ) {
                        $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
 
                        if ( $redir ) {
@@ -1013,7 +1035,8 @@ class Linker {
 
                if ( !wfRunHooks( 'LinkerMakeMediaLinkFile',
                        array( $title, $file, &$html, &$attribs, &$ret ) ) ) {
-                       wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link with url {$url} and text {$html} to {$ret}\n", true );
+                       wfDebug( "Hook LinkerMakeMediaLinkFile changed the output of link "
+                               . "with url {$url} and text {$html} to {$ret}\n", true );
                        return $ret;
                }
 
@@ -1047,7 +1070,9 @@ class Linker {
         * @param Title|null $title Title object used for title specific link attributes
         * @return string
         */
-       public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = array(), $title = null ) {
+       public static function makeExternalLink( $url, $text, $escape = true,
+               $linktype = '', $attribs = array(), $title = null
+       ) {
                global $wgTitle;
                $class = "external";
                if ( $linktype ) {
@@ -1070,7 +1095,8 @@ class Linker {
                $success = wfRunHooks( 'LinkerMakeExternalLink',
                        array( &$url, &$text, &$link, &$attribs, $linktype ) );
                if ( !$success ) {
-                       wfDebug( "Hook LinkerMakeExternalLink changed the output of link with url {$url} and text {$text} to {$link}\n", true );
+                       wfDebug( "Hook LinkerMakeExternalLink changed the output of link "
+                               . "with url {$url} and text {$text} to {$link}\n", true );
                        return $link;
                }
                $attribs['href'] = $url;
@@ -1111,7 +1137,8 @@ class Linker {
         * @param string $userText User name or IP address
         * @param bool $redContribsWhenNoEdits Should the contributions link be
         *   red if the user has no edits?
-        * @param int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK and Linker::TOOL_LINKS_EMAIL)
+        * @param int $flags Customisation flags (e.g. Linker::TOOL_LINKS_NOBLOCK
+        *   and Linker::TOOL_LINKS_EMAIL).
         * @param int $edits User edit count (optional, for performance)
         * @return string HTML fragment
         */
@@ -1285,11 +1312,11 @@ class Linker {
                return $comment;
        }
 
-       /**
-        * @var Title
-        */
-       static $autocommentTitle;
-       static $autocommentLocal;
+       /** @var Title */
+       private static $autocommentTitle;
+
+       /** @var bool Whether section links should refer to local page */
+       private static $autocommentLocal;
 
        /**
         * Converts autogenerated comments in edit summaries into section links.
@@ -1367,16 +1394,17 @@ class Linker {
                                $auto .= wfMessage( 'colon-separator' )->inContentLanguage()->escaped();
                        }
                        $auto = '<span class="autocomment">' . $auto . '</span>';
-                       $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
+                       $comment = $pre . $link . $wgLang->getDirMark()
+                               . '<span dir="auto">' . $auto . $post . '</span>';
                }
                return $comment;
        }
 
-       /**
-        * @var Title
-        */
-       static $commentContextTitle;
-       static $commentLocal;
+       /** @var Title */
+       private static $commentContextTitle;
+
+       /** @var bool Whether section links should refer to local page */
+       private static $commentLocal;
 
        /**
         * Formats wiki links and media links in text; all other wiki formatting
@@ -1477,7 +1505,12 @@ class Linker {
                }
                if ( $thelink ) {
                        // If the link is still valid, go ahead and replace it in!
-                       $comment = preg_replace( $linkRegexp, StringUtils::escapeRegexReplacement( $thelink ), $comment, 1 );
+                       $comment = preg_replace(
+                               $linkRegexp,
+                               StringUtils::escapeRegexReplacement( $thelink ),
+                               $comment,
+                               1
+                       );
                }
 
                return $comment;
@@ -1736,7 +1769,9 @@ class Linker {
         *
         * @return string HTML headline
         */
-       public static function makeHeadline( $level, $attribs, $anchor, $html, $link, $legacyAnchor = false ) {
+       public static function makeHeadline( $level, $attribs, $anchor, $html,
+               $link, $legacyAnchor = false
+       ) {
                $ret = "<h$level$attribs"
                        . "<span class=\"mw-headline\" id=\"$anchor\">$html</span>"
                        . $link
@@ -1792,10 +1827,13 @@ class Linker {
         * @param array $options
         * @return string
         */
-       public static function generateRollback( $rev, IContextSource $context = null, $options = array( 'verify' ) ) {
+       public static function generateRollback( $rev, IContextSource $context = null,
+               $options = array( 'verify' )
+       ) {
                if ( $context === null ) {
                        $context = RequestContext::getMain();
                }
+
                $editCount = false;
                if ( in_array( 'verify', $options ) ) {
                        $editCount = self::getRollbackEditCount( $rev, true );
@@ -1855,9 +1893,13 @@ class Linker {
                $moreRevs = false;
                foreach ( $res as $row ) {
                        if ( $rev->getRawUserText() != $row->rev_user_text ) {
-                               if ( $verify && ( $row->rev_deleted & Revision::DELETED_TEXT || $row->rev_deleted & Revision::DELETED_USER ) ) {
-                                       // If the user or the text of the revision we might rollback to is deleted in some way we can't rollback
-                                       // Similar to the sanity checks in WikiPage::commitRollback
+                               if ( $verify &&
+                                       ( $row->rev_deleted & Revision::DELETED_TEXT
+                                               || $row->rev_deleted & Revision::DELETED_USER
+                               ) ) {
+                                       // If the user or the text of the revision we might rollback
+                                       // to is deleted in some way we can't rollback. Similar to
+                                       // the sanity checks in WikiPage::commitRollback.
                                        return false;
                                }
                                $moreRevs = true;
@@ -1883,7 +1925,9 @@ class Linker {
         * @param int $editCount Number of edits that would be reverted
         * @return string HTML fragment
         */
-       public static function buildRollbackLink( $rev, IContextSource $context = null, $editCount = false ) {
+       public static function buildRollbackLink( $rev, IContextSource $context = null,
+               $editCount = false
+       ) {
                global $wgShowRollbackEditCount, $wgMiserMode;
 
                // To config which pages are effected by miser mode
@@ -1897,7 +1941,10 @@ class Linker {
                $query = array(
                        'action' => 'rollback',
                        'from' => $rev->getUserText(),
-                       'token' => $context->getUser()->getEditToken( array( $title->getPrefixedText(), $rev->getUserText() ) ),
+                       'token' => $context->getUser()->getEditToken( array(
+                               $title->getPrefixedText(),
+                               $rev->getUserText()
+                       ) ),
                );
                if ( $context->getRequest()->getBool( 'bot' ) ) {
                        $query['bot'] = '1';
@@ -1914,13 +1961,17 @@ class Linker {
                        }
                }
 
-               if ( !$disableRollbackEditCount && is_int( $wgShowRollbackEditCount ) && $wgShowRollbackEditCount > 0 ) {
+               if ( !$disableRollbackEditCount
+                       && is_int( $wgShowRollbackEditCount )
+                       && $wgShowRollbackEditCount > 0
+               ) {
                        if ( !is_numeric( $editCount ) ) {
                                $editCount = self::getRollbackEditCount( $rev, false );
                        }
 
                        if ( $editCount > $wgShowRollbackEditCount ) {
-                               $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )->numParams( $wgShowRollbackEditCount )->parse();
+                               $editCount_output = $context->msg( 'rollbacklinkcount-morethan' )
+                                       ->numParams( $wgShowRollbackEditCount )->parse();
                        } else {
                                $editCount_output = $context->msg( 'rollbacklinkcount' )->numParams( $editCount )->parse();
                        }
@@ -1958,7 +2009,9 @@ class Linker {
         * @param Title|Message|string|null $more An escaped link for "More..." of the templates
         * @return string HTML output
         */
-       public static function formatTemplates( $templates, $preview = false, $section = false, $more = null ) {
+       public static function formatTemplates( $templates, $preview = false,
+               $section = false, $more = null
+       ) {
                global $wgLang;
                wfProfileIn( __METHOD__ );
 
@@ -2062,7 +2115,10 @@ class Linker {
                        $outText .= "</div><ul>\n";
 
                        foreach ( $hiddencats as $titleObj ) {
-                               $outText .= '<li>' . self::link( $titleObj, null, array(), array(), 'known' ) . "</li>\n"; # If it's hidden, it must exist - no need to check with a LinkBatch
+                               # If it's hidden, it must exist - no need to check with a LinkBatch
+                               $outText .= '<li>'
+                                       . self::link( $titleObj, null, array(), array(), 'known' )
+                                       . "</li>\n";
                        }
                        $outText .= '</ul>';
                }
@@ -2128,7 +2184,7 @@ class Linker {
                return $tooltip;
        }
 
-       static $accesskeycache;
+       private static $accesskeycache;
 
        /**
         * Given the id of an interface element, constructs the appropriate
@@ -2225,7 +2281,11 @@ class Linker {
                $html = wfMessage( $msgKey )->escaped();
                $tag = $restricted ? 'strong' : 'span';
                $link = self::link( $sp, $html, array(), $query, array( 'known', 'noclasses' ) );
-               return Xml::tags( $tag, array( 'class' => 'mw-revdelundel-link' ), wfMessage( 'parentheses' )->rawParams( $link )->escaped() );
+               return Xml::tags(
+                       $tag,
+                       array( 'class' => 'mw-revdelundel-link' ),
+                       wfMessage( 'parentheses' )->rawParams( $link )->escaped()
+               );
        }
 
        /**
index b0423fb..86c3057 100644 (file)
@@ -524,7 +524,7 @@ class Revision implements IDBAccessObject {
        /**
         * Constructor
         *
-        * @param object $row Either a database row or an array
+        * @param object|array $row Either a database row or an array
         * @throws MWException
         * @access private
         */
index 085404b..c07fc3a 100644 (file)
@@ -702,7 +702,8 @@ class WebInstaller extends Installer {
                $html = $this->parse( $text, true );
 
                return "<div class=\"mw-help-field-container\">\n" .
-                       "<span class=\"mw-help-field-hint\" title=\"" .  wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
+                       "<span class=\"mw-help-field-hint\" title=\"" .
+                       wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
                        wfMessage( 'config-help' )->escaped() . "</span>\n" .
                        "<span class=\"mw-help-field-data\">" . $html . "</span>\n" .
                        "</div>\n";
index 7d8a0b6..7887447 100644 (file)
@@ -88,7 +88,8 @@ class Preprocessor_DOM implements Preprocessor {
                if ( !$result ) {
                        // Try running the XML through UtfNormal to get rid of invalid characters
                        $xml = UtfNormal::cleanUp( $xml );
-                       // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep
+                       // 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2
+                       // don't barf when the XML is >256 levels deep
                        $result = $dom->loadXML( $xml, 1 << 19 );
                }
                wfProfileOut( __METHOD__ . '-loadXML' );