Merge "Fixed job miscounting bug when a string digit is returned"
[lhc/web/wiklou.git] / includes / WikiPage.php
index 0dec766..9a26c15 100644 (file)
@@ -59,7 +59,7 @@ class WikiPage implements Page, IDBAccessObject {
        protected $mId = null;
 
        /**
-        * @var int; one of the READ_* constants
+        * @var int One of the READ_* constants
         */
        protected $mDataLoadedFrom = self::READ_NONE;
 
@@ -74,7 +74,7 @@ class WikiPage implements Page, IDBAccessObject {
        protected $mLastRevision = null;
 
        /**
-        * @var string; timestamp of the current revision or empty string if not loaded
+        * @var string Timestamp of the current revision or empty string if not loaded
         */
        protected $mTimestamp = '';
 
@@ -95,7 +95,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Constructor and clear the article
-        * @param $title Title Reference to a Title object.
+        * @param Title $title Reference to a Title object.
         */
        public function __construct( Title $title ) {
                $this->mTitle = $title;
@@ -135,8 +135,8 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Constructor from a page id
         *
-        * @param int $id article ID to load
-        * @param string|int $from one of the following values:
+        * @param int $id Article ID to load
+        * @param string|int $from One of the following values:
         *        - "fromdb" or WikiPage::READ_NORMAL to select from a slave database
         *        - "fromdbmaster" or WikiPage::READ_LATEST to select from the master database
         *
@@ -161,9 +161,8 @@ class WikiPage implements Page, IDBAccessObject {
         * Constructor from a database row
         *
         * @since 1.20
-        * @param $row object: database row containing at least fields returned
-        *        by selectFields().
-        * @param string|int $from source of $data:
+        * @param object $row Database row containing at least fields returned by selectFields().
+        * @param string|int $from Source of $data:
         *        - "fromdb" or WikiPage::READ_NORMAL: from a slave DB
         *        - "fromdbmaster" or WikiPage::READ_LATEST: from the master DB
         *        - "forupdate" or WikiPage::READ_LOCKING: from the master DB using SELECT FOR UPDATE
@@ -178,7 +177,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Convert 'fromdb', 'fromdbmaster' and 'forupdate' to READ_* constants.
         *
-        * @param $type object|string|int
+        * @param object|string|int $type
         * @return mixed
         */
        private static function convertSelectType( $type ) {
@@ -203,7 +202,7 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * @todo Move this UI stuff somewhere else
         *
-        * @return Array
+        * @return array
         */
        public function getActionOverrides() {
                $content_handler = $this->getContentHandler();
@@ -225,7 +224,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Get the title object of the article
-        * @return Title object of this page
+        * @return Title Title object of this page
         */
        public function getTitle() {
                return $this->mTitle;
@@ -304,10 +303,10 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Fetch a page record with the given conditions
-        * @param $dbr DatabaseBase object
-        * @param $conditions Array
-        * @param $options Array
-        * @return mixed Database result resource, or false on failure
+        * @param DatabaseBase $dbr
+        * @param array $conditions
+        * @param array $options
+        * @return object|bool Database result resource, or false on failure
         */
        protected function pageData( $dbr, $conditions, $options = array() ) {
                $fields = self::selectFields();
@@ -325,10 +324,10 @@ class WikiPage implements Page, IDBAccessObject {
         * Fetch a page record matching the Title object's namespace and title
         * using a sanitized title string
         *
-        * @param $dbr DatabaseBase object
-        * @param $title Title object
-        * @param $options Array
-        * @return mixed Database result resource, or false on failure
+        * @param DatabaseBase $dbr
+        * @param Title $title
+        * @param array $options
+        * @return object|bool Database result resource, or false on failure
         */
        public function pageDataFromTitle( $dbr, $title, $options = array() ) {
                return $this->pageData( $dbr, array(
@@ -339,10 +338,10 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Fetch a page record matching the requested ID
         *
-        * @param $dbr DatabaseBase
-        * @param $id Integer
-        * @param $options Array
-        * @return mixed Database result resource, or false on failure
+        * @param DatabaseBase $dbr
+        * @param int $id
+        * @param array $options
+        * @return object|bool Database result resource, or false on failure
         */
        public function pageDataFromId( $dbr, $id, $options = array() ) {
                return $this->pageData( $dbr, array( 'page_id' => $id ), $options );
@@ -352,11 +351,12 @@ class WikiPage implements Page, IDBAccessObject {
         * Set the general counter, title etc data loaded from
         * some source.
         *
-        * @param $from object|string|int One of the following:
-        *        - A DB query result object
-        *        - "fromdb" or WikiPage::READ_NORMAL to get from a slave DB
-        *        - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB
-        *        - "forupdate"  or WikiPage::READ_LOCKING to get from the master DB using SELECT FOR UPDATE
+        * @param object|string|int $from One of the following:
+        *   - A DB query result object.
+        *   - "fromdb" or WikiPage::READ_NORMAL to get from a slave DB.
+        *   - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB.
+        *   - "forupdate"  or WikiPage::READ_LOCKING to get from the master DB
+        *     using SELECT FOR UPDATE.
         *
         * @return void
         */
@@ -395,8 +395,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Load the object from a database row
         *
         * @since 1.20
-        * @param $data object: database row containing at least fields returned
-        *        by selectFields()
+        * @param object $data Database row containing at least fields returned by selectFields()
         * @param string|int $from One of the following:
         *        - "fromdb" or WikiPage::READ_NORMAL if the data comes from a slave DB
         *        - "fromdbmaster" or WikiPage::READ_LATEST if the data comes from the master DB
@@ -504,7 +503,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Will use the revisions actual content model if the page exists,
         * and the page's default if the page doesn't exist yet.
         *
-        * @return String
+        * @return string
         *
         * @since 1.21
         */
@@ -527,7 +526,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Loads page_touched and returns a value indicating if it should be used
-        * @return boolean true if not a redirect
+        * @return bool true if not a redirect
         */
        public function checkTouched() {
                if ( !$this->mDataLoaded ) {
@@ -538,7 +537,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Get the page_touched field
-        * @return string containing GMT timestamp
+        * @return string Containing GMT timestamp
         */
        public function getTouched() {
                if ( !$this->mDataLoaded ) {
@@ -549,7 +548,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Get the page_links_updated field
-        * @return string|null containing GMT timestamp
+        * @return string|null Containing GMT timestamp
         */
        public function getLinksTimestamp() {
                if ( !$this->mDataLoaded ) {
@@ -560,7 +559,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Get the page_latest field
-        * @return integer rev_id of current revision
+        * @return int rev_id of current revision
         */
        public function getLatest() {
                if ( !$this->mDataLoaded ) {
@@ -638,6 +637,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Set the latest revision
+        * @param Revision $revision
         */
        protected function setLastEdit( Revision $revision ) {
                $this->mLastRevision = $revision;
@@ -659,12 +659,12 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Get the content of the current revision. No side-effects...
         *
-        * @param $audience Integer: one of:
-        *      Revision::FOR_PUBLIC       to be displayed to all users
-        *      Revision::FOR_THIS_USER    to be displayed to $wgUser
-        *      Revision::RAW              get the text regardless of permissions
-        * @param $user User object to check for, only if FOR_THIS_USER is passed
-        *              to the $audience parameter
+        * @param int $audience int One of:
+        *   Revision::FOR_PUBLIC       to be displayed to all users
+        *   Revision::FOR_THIS_USER    to be displayed to $wgUser
+        *   Revision::RAW              get the text regardless of permissions
+        * @param User $user User object to check for, only if FOR_THIS_USER is passed
+        *   to the $audience parameter
         * @return Content|null The content of the current revision
         *
         * @since 1.21
@@ -680,16 +680,16 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Get the text of the current revision. No side-effects...
         *
-        * @param $audience Integer: one of:
-        *      Revision::FOR_PUBLIC       to be displayed to all users
-        *      Revision::FOR_THIS_USER    to be displayed to the given user
-        *      Revision::RAW              get the text regardless of permissions
-        * @param $user User object to check for, only if FOR_THIS_USER is passed
-        *              to the $audience parameter
-        * @return String|false The text of the current revision
+        * @param int $audience One of:
+        *   Revision::FOR_PUBLIC       to be displayed to all users
+        *   Revision::FOR_THIS_USER    to be displayed to the given user
+        *   Revision::RAW              get the text regardless of permissions
+        * @param User $user User object to check for, only if FOR_THIS_USER is passed
+        *   to the $audience parameter
+        * @return string|bool The text of the current revision
         * @deprecated since 1.21, getContent() should be used instead.
         */
-       public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { // @todo deprecated, replace usage!
+       public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                ContentHandler::deprecated( __METHOD__, '1.21' );
 
                $this->loadLastEdit();
@@ -702,7 +702,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Get the text of the current revision. No side-effects...
         *
-        * @return String|bool The text of the current revision. False on failure
+        * @return string|bool The text of the current revision. False on failure
         * @deprecated since 1.21, getContent() should be used instead.
         */
        public function getRawText() {
@@ -733,12 +733,12 @@ class WikiPage implements Page, IDBAccessObject {
        }
 
        /**
-        * @param $audience Integer: one of:
-        *      Revision::FOR_PUBLIC       to be displayed to all users
-        *      Revision::FOR_THIS_USER    to be displayed to the given user
-        *      Revision::RAW              get the text regardless of permissions
-        * @param $user User object to check for, only if FOR_THIS_USER is passed
-        *              to the $audience parameter
+        * @param int $audience One of:
+        *   Revision::FOR_PUBLIC       to be displayed to all users
+        *   Revision::FOR_THIS_USER    to be displayed to the given user
+        *   Revision::RAW              get the text regardless of permissions
+        * @param User $user User object to check for, only if FOR_THIS_USER is passed
+        *   to the $audience parameter
         * @return int user ID for the user that made the last article revision
         */
        public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
@@ -752,12 +752,12 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Get the User object of the user who created the page
-        * @param $audience Integer: one of:
-        *      Revision::FOR_PUBLIC       to be displayed to all users
-        *      Revision::FOR_THIS_USER    to be displayed to the given user
-        *      Revision::RAW              get the text regardless of permissions
-        * @param $user User object to check for, only if FOR_THIS_USER is passed
-        *              to the $audience parameter
+        * @param int $audience One of:
+        *   Revision::FOR_PUBLIC       to be displayed to all users
+        *   Revision::FOR_THIS_USER    to be displayed to the given user
+        *   Revision::RAW              get the text regardless of permissions
+        * @param User $user User object to check for, only if FOR_THIS_USER is passed
+        *   to the $audience parameter
         * @return User|null
         */
        public function getCreator( $audience = Revision::FOR_PUBLIC, User $user = null ) {
@@ -771,12 +771,12 @@ class WikiPage implements Page, IDBAccessObject {
        }
 
        /**
-        * @param $audience Integer: one of:
-        *      Revision::FOR_PUBLIC       to be displayed to all users
-        *      Revision::FOR_THIS_USER    to be displayed to the given user
-        *      Revision::RAW              get the text regardless of permissions
-        * @param $user User object to check for, only if FOR_THIS_USER is passed
-        *              to the $audience parameter
+        * @param int $audience One of:
+        *   Revision::FOR_PUBLIC       to be displayed to all users
+        *   Revision::FOR_THIS_USER    to be displayed to the given user
+        *   Revision::RAW              get the text regardless of permissions
+        * @param User $user User object to check for, only if FOR_THIS_USER is passed
+        *   to the $audience parameter
         * @return string username of the user that made the last article revision
         */
        public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
@@ -789,12 +789,12 @@ class WikiPage implements Page, IDBAccessObject {
        }
 
        /**
-        * @param $audience Integer: one of:
-        *      Revision::FOR_PUBLIC       to be displayed to all users
-        *      Revision::FOR_THIS_USER    to be displayed to the given user
-        *      Revision::RAW              get the text regardless of permissions
-        * @param $user User object to check for, only if FOR_THIS_USER is passed
-        *              to the $audience parameter
+        * @param int $audience One of:
+        *   Revision::FOR_PUBLIC       to be displayed to all users
+        *   Revision::FOR_THIS_USER    to be displayed to the given user
+        *   Revision::RAW              get the text regardless of permissions
+        * @param User $user User object to check for, only if FOR_THIS_USER is passed
+        *   to the $audience parameter
         * @return string Comment stored for the last article revision
         */
        public function getComment( $audience = Revision::FOR_PUBLIC, User $user = null ) {
@@ -809,7 +809,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Returns true if last revision was marked as "minor edit"
         *
-        * @return boolean Minor edit indicator for the last article revision.
+        * @return bool Minor edit indicator for the last article revision.
         */
        public function getMinorEdit() {
                $this->loadLastEdit();
@@ -834,7 +834,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Set the cached timestamp for the last time the page changed.
         * This is only used to help handle slave lag by comparing to page_touched.
-        * @param $timestamp string
+        * @param string $timestamp
         * @return void
         */
        public function setCachedLastEditTime( $timestamp ) {
@@ -847,9 +847,9 @@ class WikiPage implements Page, IDBAccessObject {
         * Determine whether a page would be suitable for being counted as an
         * article in the site_stats table based on the title & its content
         *
-        * @param $editInfo Object|bool (false): object returned by prepareTextForEdit(),
-        *        if false, the current database state will be used
-        * @return Boolean
+        * @param object|bool $editInfo (false): object returned by prepareTextForEdit(),
+        *   if false, the current database state will be used
+        * @return bool
         */
        public function isCountable( $editInfo = false ) {
                global $wgArticleCountMethod;
@@ -893,7 +893,7 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * The target will be fetched from the redirect table if possible.
         * If this page doesn't have an entry there, call insertRedirect()
-        * @return Title|mixed object, or null if this page is not a redirect
+        * @return Title|null Title object, or null if this page is not a redirect
         */
        public function getRedirectTarget() {
                if ( !$this->mTitle->isRedirect() ) {
@@ -929,7 +929,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Insert an entry for this page into the redirect table.
         *
         * Don't call this function directly unless you know what you're doing.
-        * @return Title object or null if not a redirect
+        * @return Title|null Title object or null if not a redirect
         */
        public function insertRedirect() {
                // recurse through to only get the final target
@@ -945,7 +945,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Insert or update the redirect table entry for this page to indicate
         * it redirects to $rt .
-        * @param $rt Title redirect target
+        * @param Title $rt Redirect target
         */
        public function insertRedirectEntry( $rt ) {
                $dbw = wfGetDB( DB_MASTER );
@@ -964,7 +964,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Get the Title object or URL this page redirects to
         *
-        * @return mixed false, Title of in-wiki target, or string with URL
+        * @return bool|Title|string false, Title of in-wiki target, or string with URL
         */
        public function followRedirect() {
                return $this->getRedirectURL( $this->getRedirectTarget() );
@@ -974,8 +974,8 @@ class WikiPage implements Page, IDBAccessObject {
         * Get the Title object or URL to use for a redirect. We use Title
         * objects for same-wiki, non-special redirects and URLs for everything
         * else.
-        * @param $rt Title Redirect target
-        * @return mixed false, Title object of local target, or string with URL
+        * @param Title $rt Redirect target
+        * @return bool|Title|string false, Title object of local target, or string with URL
         */
        public function getRedirectURL( $rt ) {
                if ( !$rt ) {
@@ -1067,7 +1067,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Get the last N authors
         * @param int $num Number of revisions to get
-        * @param int|string $revLatest the latest rev_id, selected from the master (optional)
+        * @param int|string $revLatest The latest rev_id, selected from the master (optional)
         * @return array Array of authors, duplicates not removed
         */
        public function getLastNAuthors( $num, $revLatest = 0 ) {
@@ -1119,9 +1119,9 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Should the parser cache be used?
         *
-        * @param $parserOptions ParserOptions to check
-        * @param $oldid int
-        * @return boolean
+        * @param ParserOptions $parserOptions ParserOptions to check
+        * @param int $oldid
+        * @return bool
         */
        public function isParserCacheUsed( ParserOptions $parserOptions, $oldid ) {
                global $wgEnableParserCache;
@@ -1140,9 +1140,9 @@ class WikiPage implements Page, IDBAccessObject {
         * @since 1.19
         * @param ParserOptions $parserOptions ParserOptions to use for the parse operation
         * @param null|int $oldid Revision ID to get the text from, passing null or 0 will
-        *               get the current revision (default value)
+        *   get the current revision (default value)
         *
-        * @return ParserOutput or false if the revision was not found
+        * @return ParserOutput|bool ParserOutput or false if the revision was not found
         */
        public function getParserOutput( ParserOptions $parserOptions, $oldid = null ) {
                wfProfileIn( __METHOD__ );
@@ -1247,7 +1247,7 @@ class WikiPage implements Page, IDBAccessObject {
         * or else the record will be left in a funky state.
         * Best if all done inside a transaction.
         *
-        * @param $dbw DatabaseBase
+        * @param DatabaseBase $dbw
         * @return int The newly created page_id key, or false if the title already existed
         */
        public function insertOn( $dbw ) {
@@ -1283,19 +1283,19 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Update the page record to point to a newly saved revision.
         *
-        * @param $dbw DatabaseBase: object
-        * @param $revision Revision: For ID number, and text used to set
-        *                  length and redirect status fields
-        * @param $lastRevision Integer: if given, will not overwrite the page field
-        *                      when different from the currently set value.
-        *                      Giving 0 indicates the new page flag should be set
-        *                      on.
-        * @param $lastRevIsRedirect Boolean: if given, will optimize adding and
-        *                           removing rows in redirect table.
+        * @param DatabaseBase $dbw
+        * @param Revision $revision For ID number, and text used to set
+        *   length and redirect status fields
+        * @param int $lastRevision If given, will not overwrite the page field
+        *   when different from the currently set value.
+        *   Giving 0 indicates the new page flag should be set on.
+        * @param bool $lastRevIsRedirect If given, will optimize adding and
+        *   removing rows in redirect table.
         * @return bool true on success, false on failure
-        * @private
         */
-       public function updateRevisionOn( $dbw, $revision, $lastRevision = null, $lastRevIsRedirect = null ) {
+       public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
+               $lastRevIsRedirect = null
+       ) {
                global $wgContentHandlerUseDB;
 
                wfProfileIn( __METHOD__ );
@@ -1348,11 +1348,11 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Add row to the redirect table if this is a redirect, remove otherwise.
         *
-        * @param $dbw DatabaseBase
-        * @param $redirectTitle Title object pointing to the redirect target,
-        *                       or NULL if this is not a redirect
-        * @param $lastRevIsRedirect null|bool If given, will optimize adding and
-        *                           removing rows in redirect table.
+        * @param DatabaseBase $dbw
+        * @param Title $redirectTitle Title object pointing to the redirect target,
+        *   or NULL if this is not a redirect
+        * @param null|bool $lastRevIsRedirect If given, will optimize adding and
+        *   removing rows in redirect table.
         * @return bool true on success, false on failure
         * @private
         */
@@ -1387,9 +1387,9 @@ class WikiPage implements Page, IDBAccessObject {
         * If the given revision is newer than the currently set page_latest,
         * update the page record. Otherwise, do nothing.
         *
-        * @param $dbw DatabaseBase object
-        * @param $revision Revision object
-        * @return mixed
+        * @param DatabaseBase $dbw
+        * @param Revision $revision
+        * @return bool
         */
        public function updateIfNewerOn( $dbw, $revision ) {
                wfProfileIn( __METHOD__ );
@@ -1425,8 +1425,8 @@ class WikiPage implements Page, IDBAccessObject {
         * Get the content that needs to be saved in order to undo all revisions
         * between $undo and $undoafter. Revisions must belong to the same page,
         * must exist and must not be deleted
-        * @param $undo Revision
-        * @param $undoafter Revision Must be an earlier revision than $undo
+        * @param Revision $undo
+        * @param Revision $undoafter Must be an earlier revision than $undo
         * @return mixed string on success, false on failure
         * @since 1.21
         * Before we had the Content object, this was done in getUndoText
@@ -1440,9 +1440,9 @@ class WikiPage implements Page, IDBAccessObject {
         * Get the text that needs to be saved in order to undo all revisions
         * between $undo and $undoafter. Revisions must belong to the same page,
         * must exist and must not be deleted
-        * @param $undo Revision
-        * @param $undoafter Revision Must be an earlier revision than $undo
-        * @return mixed string on success, false on failure
+        * @param Revision $undo
+        * @param Revision $undoafter Must be an earlier revision than $undo
+        * @return string|bool string on success, false on failure
         * @deprecated since 1.21: use ContentHandler::getUndoContent() instead.
         */
        public function getUndoText( Revision $undo, Revision $undoafter = null ) {
@@ -1469,7 +1469,7 @@ class WikiPage implements Page, IDBAccessObject {
        }
 
        /**
-        * @param mixed $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
+        * @param string|null|bool $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
         * @param string $text New text of the section.
         * @param string $sectionTitle New section's subject, only if $section is "new".
         * @param string $edittime Revision timestamp or null to use the current revision.
@@ -1479,10 +1479,13 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * @deprecated since 1.21, use replaceSectionContent() instead
         */
-       public function replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) {
+       public function replaceSection( $section, $text, $sectionTitle = '',
+               $edittime = null
+       ) {
                ContentHandler::deprecated( __METHOD__, '1.21' );
 
-               if ( strval( $section ) == '' ) { //NOTE: keep condition in sync with condition in replaceSectionContent!
+               //NOTE: keep condition in sync with condition in replaceSectionContent!
+               if ( strval( $section ) == '' ) {
                        // Whole-page edit; let the whole text through
                        return $text;
                }
@@ -1506,15 +1509,17 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * @return bool
         *
-        * @todo The skin should check this and not offer section functionality if sections are not supported.
-        * @todo The EditPage should check this and not offer section functionality if sections are not supported.
+        * @todo The skin should check this and not offer section functionality if
+        *   sections are not supported.
+        * @todo The EditPage should check this and not offer section functionality
+        *   if sections are not supported.
         */
        public function supportsSections() {
                return $this->getContentHandler()->supportsSections();
        }
 
        /**
-        * @param mixed $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
+        * @param string|null|bool $section Null/false, a section number (0, 1, 2, T1, T2, ...) or "new".
         * @param Content $sectionContent New content of the section.
         * @param string $sectionTitle New section's subject, only if $section is "new".
         * @param string $edittime Revision timestamp or null to use the current revision.
@@ -1571,8 +1576,8 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Check flags and add EDIT_NEW or EDIT_UPDATE to them as needed.
-        * @param $flags Int
-        * @return Int updated $flags
+        * @param int $flags
+        * @return int Updated $flags
         */
        public function checkFlags( $flags ) {
                if ( !( $flags & EDIT_NEW ) && !( $flags & EDIT_UPDATE ) ) {
@@ -1590,9 +1595,9 @@ class WikiPage implements Page, IDBAccessObject {
         * Change an existing article or create a new article. Updates RC and all necessary caches,
         * optionally via the deferred update array.
         *
-        * @param string $text new text
-        * @param string $summary edit summary
-        * @param $flags Integer bitfield:
+        * @param string $text New text
+        * @param string $summary Edit summary
+        * @param int $flags Bitfield:
         *      EDIT_NEW
         *          Article is known or assumed to be non-existent, create a new one
         *      EDIT_UPDATE
@@ -1608,30 +1613,33 @@ class WikiPage implements Page, IDBAccessObject {
         *      EDIT_AUTOSUMMARY
         *          Fill in blank summaries with generated text where possible
         *
-        * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected.
-        * If EDIT_UPDATE is specified and the article doesn't exist, the function will return an
-        * edit-gone-missing error. If EDIT_NEW is specified and the article does exist, an
-        * edit-already-exists error will be returned. These two conditions are also possible with
+        * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the
+        * article will be detected. If EDIT_UPDATE is specified and the article
+        * doesn't exist, the function will return an edit-gone-missing error. If
+        * EDIT_NEW is specified and the article does exist, an edit-already-exists
+        * error will be returned. These two conditions are also possible with
         * auto-detection due to MediaWiki's performance-optimised locking strategy.
         *
-        * @param bool|int $baseRevId int the revision ID this edit was based off, if any
-        * @param $user User the user doing the edit
+        * @param bool|int $baseRevId The revision ID this edit was based off, if any
+        * @param User $user The user doing the edit
         *
         * @throws MWException
         * @return Status object. Possible errors:
-        *     edit-hook-aborted:       The ArticleSave hook aborted the edit but didn't set the fatal flag of $status
-        *     edit-gone-missing:       In update mode, but the article didn't exist
-        *     edit-conflict:           In update mode, the article changed unexpectedly
-        *     edit-no-change:          Warning that the text was the same as before
-        *     edit-already-exists:     In creation mode, but the article already exists
+        *   edit-hook-aborted: The ArticleSave hook aborted the edit but didn't
+        *     set the fatal flag of $status
+        *   edit-gone-missing: In update mode, but the article didn't exist.
+        *   edit-conflict: In update mode, the article changed unexpectedly.
+        *   edit-no-change: Warning that the text was the same as before.
+        *   edit-already-exists: In creation mode, but the article already exists.
         *
-        *  Extensions may define additional errors.
+        * Extensions may define additional errors.
         *
-        *  $return->value will contain an associative array with members as follows:
-        *     new:                     Boolean indicating if the function attempted to create a new article
-        *     revision:                The revision object for the inserted revision, or null
+        * $return->value will contain an associative array with members as follows:
+        *     new: Boolean indicating if the function attempted to create a new article.
+        *     revision: The revision object for the inserted revision, or null.
         *
-        *  Compatibility note: this function previously returned a boolean value indicating success/failure
+        * Compatibility note: this function previously returned a boolean value
+        * indicating success/failure
         *
         * @deprecated since 1.21: use doEditContent() instead.
         */
@@ -1647,9 +1655,9 @@ class WikiPage implements Page, IDBAccessObject {
         * Change an existing article or create a new article. Updates RC and all necessary caches,
         * optionally via the deferred update array.
         *
-        * @param $content Content: new content
-        * @param string $summary edit summary
-        * @param $flags Integer bitfield:
+        * @param Content $content New content
+        * @param string $summary Edit summary
+        * @param int $flags Bitfield:
         *      EDIT_NEW
         *          Article is known or assumed to be non-existent, create a new one
         *      EDIT_UPDATE
@@ -1665,29 +1673,32 @@ class WikiPage implements Page, IDBAccessObject {
         *      EDIT_AUTOSUMMARY
         *          Fill in blank summaries with generated text where possible
         *
-        * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the article will be detected.
-        * If EDIT_UPDATE is specified and the article doesn't exist, the function will return an
-        * edit-gone-missing error. If EDIT_NEW is specified and the article does exist, an
-        * edit-already-exists error will be returned. These two conditions are also possible with
+        * If neither EDIT_NEW nor EDIT_UPDATE is specified, the status of the
+        * article will be detected. If EDIT_UPDATE is specified and the article
+        * doesn't exist, the function will return an edit-gone-missing error. If
+        * EDIT_NEW is specified and the article does exist, an edit-already-exists
+        * error will be returned. These two conditions are also possible with
         * auto-detection due to MediaWiki's performance-optimised locking strategy.
         *
-        * @param bool|int $baseRevId the revision ID this edit was based off, if any
-        * @param $user User the user doing the edit
-        * @param $serialisation_format String: format for storing the content in the database
+        * @param bool|int $baseRevId The revision ID this edit was based off, if any
+        * @param User $user The user doing the edit
+        * @param string $serialisation_format Format for storing the content in the
+        *   database.
         *
         * @throws MWException
         * @return Status object. Possible errors:
-        *     edit-hook-aborted:       The ArticleSave hook aborted the edit but didn't set the fatal flag of $status
-        *     edit-gone-missing:       In update mode, but the article didn't exist
-        *     edit-conflict:           In update mode, the article changed unexpectedly
-        *     edit-no-change:          Warning that the text was the same as before
-        *     edit-already-exists:     In creation mode, but the article already exists
+        *     edit-hook-aborted: The ArticleSave hook aborted the edit but didn't
+        *       set the fatal flag of $status.
+        *     edit-gone-missing: In update mode, but the article didn't exist.
+        *     edit-conflict: In update mode, the article changed unexpectedly.
+        *     edit-no-change: Warning that the text was the same as before.
+        *     edit-already-exists: In creation mode, but the article already exists.
         *
         *  Extensions may define additional errors.
         *
         *  $return->value will contain an associative array with members as follows:
-        *     new:                     Boolean indicating if the function attempted to create a new article
-        *     revision:                The revision object for the inserted revision, or null
+        *     new: Boolean indicating if the function attempted to create a new article.
+        *     revision: The revision object for the inserted revision, or null.
         *
         * @since 1.21
         */
@@ -2022,7 +2033,8 @@ class WikiPage implements Page, IDBAccessObject {
                $options = $this->getContentHandler()->makeParserOptions( $context );
 
                if ( $this->getTitle()->isConversionTable() ) {
-                       // @todo ConversionTable should become a separate content model, so we don't need special cases like this one.
+                       // @todo ConversionTable should become a separate content model, so
+                       // we don't need special cases like this one.
                        $options->disableContentConversion();
                }
 
@@ -2034,6 +2046,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Returns a stdclass with source, pst and output members
         *
         * @deprecated since 1.21: use prepareContentForEdit instead.
+        * @return object
         */
        public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
                ContentHandler::deprecated( __METHOD__, '1.21' );
@@ -2088,7 +2101,9 @@ class WikiPage implements Page, IDBAccessObject {
 
                $edit->format = $serialization_format;
                $edit->popts = $this->makeParserOptions( 'canonical' );
-               $edit->output = $edit->pstContent ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts ) : null;
+               $edit->output = $edit->pstContent
+                       ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts )
+                       : null;
 
                $edit->newContent = $content;
                $edit->oldContent = $this->getContent( Revision::RAW );
@@ -2108,9 +2123,9 @@ class WikiPage implements Page, IDBAccessObject {
         * Purges pages that include this page if the text was changed here.
         * Every 100th edit, prune the recent changes table.
         *
-        * @param $revision Revision object
-        * @param $user User object that did the revision
-        * @param array $options of options, following indexes are used:
+        * @param Revision $revision
+        * @param User $user User object that did the revision
+        * @param array $options Array of options, following indexes are used:
         * - changed: boolean, whether the revision changed the content (default true)
         * - created: boolean, whether the revision created the page (default false)
         * - oldcountable: boolean or null (default null):
@@ -2174,19 +2189,17 @@ class WikiPage implements Page, IDBAccessObject {
 
                if ( !$options['changed'] ) {
                        $good = 0;
-                       $total = 0;
                } elseif ( $options['created'] ) {
                        $good = (int)$this->isCountable( $editInfo );
-                       $total = 1;
                } elseif ( $options['oldcountable'] !== null ) {
                        $good = (int)$this->isCountable( $editInfo ) - (int)$options['oldcountable'];
-                       $total = 0;
                } else {
                        $good = 0;
-                       $total = 0;
                }
+               $edits = $options['changed'] ? 1 : 0;
+               $total = $options['created'] ? 1 : 0;
 
-               DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
+               DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, $edits, $good, $total ) );
                DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content ) );
 
                // If this is another user's talk page, update newtalk.
@@ -2227,7 +2240,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                if ( $options['created'] ) {
                        self::onArticleCreate( $this->mTitle );
-               } else {
+               } elseif ( $options['changed'] ) { // bug 50785
                        self::onArticleEdit( $this->mTitle );
                }
 
@@ -2239,10 +2252,10 @@ class WikiPage implements Page, IDBAccessObject {
         * The article must already exist; link tables etc
         * are not updated, caches are not flushed.
         *
-        * @param string $text text submitted
-        * @param $user User The relevant user
-        * @param string $comment comment submitted
-        * @param $minor Boolean: whereas it's a minor modification
+        * @param string $text Text submitted
+        * @param User $user The relevant user
+        * @param string $comment Comment submitted
+        * @param bool $minor Whereas it's a minor modification
         *
         * @deprecated since 1.21, use doEditContent() instead.
         */
@@ -2275,6 +2288,8 @@ class WikiPage implements Page, IDBAccessObject {
                $revision = new Revision( array(
                        'title'      => $this->getTitle(), // for determining the default content model
                        'page'       => $this->getId(),
+                       'user_text'  => $user->getName(),
+                       'user'       => $user->getId(),
                        'text'       => $serialized,
                        'length'     => $content->getSize(),
                        'comment'    => $comment,
@@ -2292,14 +2307,16 @@ class WikiPage implements Page, IDBAccessObject {
         * Update the article's restriction field, and leave a log entry.
         * This works for protection both existing and non-existing pages.
         *
-        * @param array $limit set of restriction keys
-        * @param array $expiry per restriction type expiration
+        * @param array $limit Set of restriction keys
+        * @param array $expiry Per restriction type expiration
         * @param int &$cascade Set to false if cascading protection isn't allowed.
         * @param string $reason
         * @param User $user The user updating the restrictions
         * @return Status
         */
-       public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
+       public function doUpdateRestrictions( array $limit, array $expiry,
+               &$cascade, $reason, User $user
+       ) {
                global $wgCascadingRestrictionLevels, $wgContLang;
 
                if ( wfReadOnly() ) {
@@ -2385,7 +2402,9 @@ class WikiPage implements Page, IDBAccessObject {
                        }
 
                        // Only certain restrictions can cascade...
-                       $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
+                       $editrestriction = isset( $limit['edit'] )
+                               ? array( $limit['edit'] )
+                               : $this->mTitle->getRestrictions( 'edit' );
                        foreach ( array_keys( $editrestriction, 'sysop' ) as $key ) {
                                $editrestriction[$key] = 'editprotected'; // backwards compatibility
                        }
@@ -2408,7 +2427,15 @@ class WikiPage implements Page, IDBAccessObject {
 
                        // insert null revision to identify the page protection change as edit summary
                        $latest = $this->getLatest();
-                       $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason );
+                       $nullRevision = $this->insertProtectNullRevision(
+                               $revCommentMsg,
+                               $limit,
+                               $expiry,
+                               $cascade,
+                               $reason,
+                               $user
+                       );
+
                        if ( $nullRevision === null ) {
                                return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() );
                        }
@@ -2502,14 +2529,17 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Insert a new null revision for this page.
         *
-        * @param string $revCommentMsg comment message key for the revision
-        * @param array $limit set of restriction keys
-        * @param array $expiry per restriction type expiration
+        * @param string $revCommentMsg Comment message key for the revision
+        * @param array $limit Set of restriction keys
+        * @param array $expiry Per restriction type expiration
         * @param int $cascade Set to false if cascading protection isn't allowed.
         * @param string $reason
-        * @return Revision|null on error
+        * @param User|null $user
+        * @return Revision|null Null on error
         */
-       public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason ) {
+       public function insertProtectNullRevision( $revCommentMsg, array $limit,
+               array $expiry, $cascade, $reason, $user = null
+       ) {
                global $wgContLang;
                $dbw = wfGetDB( DB_MASTER );
 
@@ -2526,7 +2556,8 @@ class WikiPage implements Page, IDBAccessObject {
                $protectDescription = $this->protectDescription( $limit, $expiry );
                if ( $protectDescription ) {
                        $editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text();
-                       $editComment .= wfMessage( 'parentheses' )->params( $protectDescription )->inContentLanguage()->text();
+                       $editComment .= wfMessage( 'parentheses' )->params( $protectDescription )
+                               ->inContentLanguage()->text();
                }
                if ( $cascade ) {
                        $editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text();
@@ -2535,7 +2566,7 @@ class WikiPage implements Page, IDBAccessObject {
                        )->inContentLanguage()->text();
                }
 
-               $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true );
+               $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true, $user );
                if ( $nullRev ) {
                        $nullRev->insertOn( $dbw );
 
@@ -2572,8 +2603,8 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Builds the description to serve as comment for the edit.
         *
-        * @param array $limit set of restriction keys
-        * @param array $expiry per restriction type expiration
+        * @param array $limit Set of restriction keys
+        * @param array $expiry Per restriction type expiration
         * @return string
         */
        public function protectDescription( array $limit, array $expiry ) {
@@ -2613,8 +2644,8 @@ class WikiPage implements Page, IDBAccessObject {
         * protect description text. Keep them in old format to avoid breaking compatibility.
         * TODO: Fix protection log to store structured description and format it on-the-fly.
         *
-        * @param array $limit set of restriction keys
-        * @param array $expiry per restriction type expiration
+        * @param array $limit Set of restriction keys
+        * @param array $expiry Per restriction type expiration
         * @return string
         */
        public function protectDescriptionLog( array $limit, array $expiry ) {
@@ -2661,14 +2692,14 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * Deletes the article with database consistency, writes logs, purges caches
         *
-        * @param string $reason delete reason for deletion log
-        * @param $suppress boolean suppress all revisions and log the deletion in
+        * @param string $reason Delete reason for deletion log
+        * @param bool $suppress Suppress all revisions and log the deletion in
         *        the suppression log instead of the deletion log
-        * @param int $id article ID
-        * @param $commit boolean defaults to true, triggers transaction end
-        * @param &$error Array of errors to append to
-        * @param $user User The deleting user
-        * @return boolean true if successful
+        * @param int $id Article ID
+        * @param bool $commit Defaults to true, triggers transaction end
+        * @param array &$error Array of errors to append to
+        * @param User $user The deleting user
+        * @return bool true if successful
         */
        public function doDeleteArticle(
                $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
@@ -2683,16 +2714,16 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * @since 1.19
         *
-        * @param string $reason delete reason for deletion log
-        * @param $suppress boolean suppress all revisions and log the deletion in
-        *        the suppression log instead of the deletion log
-        * @param int $id article ID
-        * @param $commit boolean defaults to true, triggers transaction end
-        * @param &$error Array of errors to append to
-        * @param $user User The deleting user
-        * @return Status: Status object; if successful, $status->value is the log_id of the
-        *                 deletion log entry. If the page couldn't be deleted because it wasn't
-        *                 found, $status is a non-fatal 'cannotdelete' error
+        * @param string $reason Delete reason for deletion log
+        * @param bool $suppress Suppress all revisions and log the deletion in
+        *   the suppression log instead of the deletion log
+        * @param int $id Article ID
+        * @param bool $commit Defaults to true, triggers transaction end
+        * @param array &$error Array of errors to append to
+        * @param User $user The deleting user
+        * @return Status Status object; if successful, $status->value is the log_id of the
+        *   deletion log entry. If the page couldn't be deleted because it wasn't
+        *   found, $status is a non-fatal 'cannotdelete' error
         */
        public function doDeleteArticleReal(
                $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
@@ -2825,8 +2856,9 @@ class WikiPage implements Page, IDBAccessObject {
         * Do some database updates after deletion
         *
         * @param int $id page_id value of the page being deleted
-        * @param $content Content: optional page content to be used when determining the required updates.
-        *        This may be needed because $this->getContent() may already return null when the page proper was deleted.
+        * @param Content $content Optional page content to be used when determining
+        *   the required updates. This may be needed because $this->getContent()
+        *   may already return null when the page proper was deleted.
         */
        public function doDeleteUpdates( $id, Content $content = null ) {
                // update site status
@@ -2866,14 +2898,14 @@ class WikiPage implements Page, IDBAccessObject {
         * @param string $fromP Name of the user whose edits to rollback.
         * @param string $summary Custom summary. Set to default summary if empty.
         * @param string $token Rollback token.
-        * @param $bot Boolean: If true, mark all reverted edits as bot.
+        * @param bool $bot If true, mark all reverted edits as bot.
         *
         * @param array $resultDetails contains result-specific array of additional values
         *    'alreadyrolled' : 'current' (rev)
         *    success        : 'summary' (str), 'current' (rev), 'target' (rev)
         *
-        * @param $user User The user performing the rollback
-        * @return array of errors, each error formatted as
+        * @param User $user The user performing the rollback
+        * @return array Array of errors, each error formatted as
         *   array(messagekey, param1, param2, ...).
         * On success, the array is empty.  This array can also be passed to
         * OutputPage::showPermissionsErrorPage().
@@ -2914,10 +2946,10 @@ class WikiPage implements Page, IDBAccessObject {
         * doRollback() instead.
         * @param string $fromP Name of the user whose edits to rollback.
         * @param string $summary Custom summary. Set to default summary if empty.
-        * @param $bot Boolean: If true, mark all reverted edits as bot.
+        * @param bool $bot If true, mark all reverted edits as bot.
         *
-        * @param array $resultDetails contains result-specific array of additional values
-        * @param $guser User The user performing the rollback
+        * @param array $resultDetails Contains result-specific array of additional values
+        * @param User $guser The user performing the rollback
         * @return array
         */
        public function commitRollback( $fromP, $summary, $bot, &$resultDetails, User $guser ) {
@@ -2963,7 +2995,9 @@ class WikiPage implements Page, IDBAccessObject {
                if ( $s === false ) {
                        // No one else ever edited this page
                        return array( array( 'cantrollback' ) );
-               } elseif ( $s->rev_deleted & Revision::DELETED_TEXT || $s->rev_deleted & Revision::DELETED_USER ) {
+               } elseif ( $s->rev_deleted & Revision::DELETED_TEXT
+                       || $s->rev_deleted & Revision::DELETED_USER
+               ) {
                        // Only admins can see this text
                        return array( array( 'notvisiblerev' ) );
                }
@@ -3031,7 +3065,13 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                // Actually store the edit
-               $status = $this->doEditContent( $target->getContent(), $summary, $flags, $target->getId(), $guser );
+               $status = $this->doEditContent(
+                       $target->getContent(),
+                       $summary,
+                       $flags,
+                       $target->getId(),
+                       $guser
+               );
 
                if ( !$status->isOK() ) {
                        return $status->getErrorsArray();
@@ -3070,7 +3110,7 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * This is called on page move and undelete, as well as edit
         *
-        * @param $title Title object
+        * @param Title $title
         */
        public static function onArticleCreate( $title ) {
                // Update existence markers on article/talk tabs...
@@ -3091,7 +3131,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Clears caches when article is deleted
         *
-        * @param $title Title
+        * @param Title $title
         */
        public static function onArticleDelete( $title ) {
                // Update existence markers on article/talk tabs...
@@ -3137,8 +3177,9 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Purge caches on page update etc
         *
-        * @param $title Title object
-        * @todo Verify that $title is always a Title object (and never false or null), add Title hint to parameter $title
+        * @param Title $title
+        * @todo Verify that $title is always a Title object (and never false or
+        *   null), add Title hint to parameter $title.
         */
        public static function onArticleEdit( $title ) {
                // Invalidate caches of articles which include this page
@@ -3184,7 +3225,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Returns a list of hidden categories this page is a member of.
         * Uses the page_props and categorylinks tables.
         *
-        * @return Array of Title objects
+        * @return array Array of Title objects
         */
        public function getHiddenCategories() {
                $result = array();
@@ -3212,15 +3253,16 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Return an applicable autosummary if one exists for the given edit.
-        * @param string|null $oldtext the previous text of the page.
+        * @param string|null $oldtext The previous text of the page.
         * @param string|null $newtext The submitted text of the page.
-        * @param int $flags bitmask: a bitmask of flags submitted for the edit.
+        * @param int $flags Bitmask: a bitmask of flags submitted for the edit.
         * @return string An appropriate autosummary, or an empty string.
         *
         * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
         */
        public static function getAutosummary( $oldtext, $newtext, $flags ) {
-               // NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
+               // NOTE: stub for backwards-compatibility. assumes the given text is
+               // wikitext. will break horribly if it isn't.
 
                ContentHandler::deprecated( __METHOD__, '1.21' );
 
@@ -3234,8 +3276,8 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Auto-generates a deletion reason
         *
-        * @param &$hasHistory Boolean: whether the page has a history
-        * @return mixed String containing deletion reason or empty string, or boolean false
+        * @param bool &$hasHistory Whether the page has a history
+        * @return string|bool String containing deletion reason or empty string, or boolean false
         *    if no revision occurred
         */
        public function getAutoDeleteReason( &$hasHistory ) {
@@ -3246,7 +3288,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Update all the appropriate counts in the category table, given that
         * we've added the categories $added and deleted the categories $deleted.
         *
-        * @param array $added   The names of categories that were added
+        * @param array $added The names of categories that were added
         * @param array $deleted The names of categories that were deleted
         */
        public function updateCategoryCounts( array $added, array $deleted ) {
@@ -3313,7 +3355,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Updates cascading protections
         *
-        * @param $parserOutput ParserOutput object for the current version
+        * @param ParserOutput $parserOutput ParserOutput object for the current version
         */
        public function doCascadeProtectionUpdates( ParserOutput $parserOutput ) {
                if ( wfReadOnly() || !$this->mTitle->areRestrictionsCascading() ) {
@@ -3370,7 +3412,8 @@ class WikiPage implements Page, IDBAccessObject {
 
                if ( count( $links_diff ) > 0 ) {
                        // Whee, link updates time.
-                       // Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
+                       // Note: we are only interested in links here. We don't need to get
+                       // other DataUpdate items from the parser output.
                        $u = new LinksUpdate( $this->mTitle, $parserOutput, false );
                        $u->doUpdate();
                }
@@ -3381,7 +3424,7 @@ class WikiPage implements Page, IDBAccessObject {
         * Uses the templatelinks table
         *
         * @deprecated since 1.19; use Title::getTemplateLinksFrom()
-        * @return Array of Title objects
+        * @return array Array of Title objects
         */
        public function getUsedTemplates() {
                return $this->mTitle->getTemplateLinksFrom();
@@ -3392,11 +3435,11 @@ class WikiPage implements Page, IDBAccessObject {
         * so we can do things like signatures and links-in-context.
         *
         * @deprecated since 1.19; use Parser::preSaveTransform() instead
-        * @param string $text article contents
-        * @param $user User object: user doing the edit
-        * @param $popts ParserOptions object: parser options, default options for
-        *               the user loaded if null given
-        * @return string article contents with altered wikitext markup (signatures
+        * @param string $text Article contents
+        * @param User $user User doing the edit
+        * @param ParserOptions $popts Parser options, default options for
+        *   the user loaded if null given
+        * @return string Article contents with altered wikitext markup (signatures
         *      converted, {{subst:}}, templates, etc.)
         */
        public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) {
@@ -3439,11 +3482,11 @@ class WikiPage implements Page, IDBAccessObject {
         * Update the article's restriction field, and leave a log entry.
         *
         * @deprecated since 1.19
-        * @param array $limit set of restriction keys
-        * @param $reason String
-        * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
-        * @param array $expiry per restriction type expiration
-        * @param $user User The user updating the restrictions
+        * @param array $limit Set of restriction keys
+        * @param string $reason
+        * @param int &$cascade Set to false if cascading protection isn't allowed.
+        * @param array $expiry Per restriction type expiration
+        * @param User $user The user updating the restrictions
         * @return bool true on success
         */
        public function updateRestrictions(
@@ -3457,11 +3500,13 @@ class WikiPage implements Page, IDBAccessObject {
        }
 
        /**
-        * Returns a list of updates to be performed when this page is deleted. The updates should remove any information
-        * about this page from secondary data stores such as links tables.
+        * Returns a list of updates to be performed when this page is deleted. The
+        * updates should remove any information about this page from secondary data
+        * stores such as links tables.
         *
-        * @param Content|null $content optional Content object for determining the necessary updates
-        * @return Array an array of DataUpdates objects
+        * @param Content|null $content Optional Content object for determining the
+        *   necessary updates.
+        * @return array An array of DataUpdates objects
         */
        public function getDeletionUpdates( Content $content = null ) {
                if ( !$content ) {
@@ -3483,57 +3528,42 @@ class WikiPage implements Page, IDBAccessObject {
 }
 
 class PoolWorkArticleView extends PoolCounterWork {
-
-       /**
-        * @var Page
-        */
+       /** @var Page */
        private $page;
 
-       /**
-        * @var string
-        */
+       /** @var string */
        private $cacheKey;
 
-       /**
-        * @var integer
-        */
+       /** @var int */
        private $revid;
 
-       /**
-        * @var ParserOptions
-        */
+       /** @var ParserOptions */
        private $parserOptions;
 
-       /**
-        * @var Content|null
-        */
+       /** @var Content|null */
        private $content = null;
 
-       /**
-        * @var ParserOutput|bool
-        */
+       /** @var ParserOutput|bool */
        private $parserOutput = false;
 
-       /**
-        * @var bool
-        */
+       /** @var bool */
        private $isDirty = false;
 
-       /**
-        * @var Status|bool
-        */
+       /** @var Status|bool */
        private $error = false;
 
        /**
-        * Constructor
-        *
-        * @param $page Page|WikiPage
-        * @param $revid Integer: ID of the revision being parsed
-        * @param $useParserCache Boolean: whether to use the parser cache
-        * @param $parserOptions parserOptions to use for the parse operation
-        * @param $content Content|String: content to parse or null to load it; may also be given as a wikitext string, for BC
+        * @param Page $page
+        * @param int $revid ID of the revision being parsed.
+        * @param bool $useParserCache Whether to use the parser cache.
+        * @param ParserOptions $parserOptions ParserOptions to use for the parse
+        *   operation.
+        * @param Content|string $content Content to parse or null to load it; may
+        *   also be given as a wikitext string, for BC.
         */
-       public function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null ) {
+       public function __construct( Page $page, ParserOptions $parserOptions,
+               $revid, $useParserCache, $content = null
+       ) {
                if ( is_string( $content ) ) { // BC: old style call
                        $modelId = $page->getRevision()->getContentModel();
                        $format = $page->getRevision()->getContentFormat();
@@ -3611,7 +3641,11 @@ class PoolWorkArticleView extends PoolCounterWork {
                $cacheTime = wfTimestampNow();
 
                $time = - microtime( true );
-               $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
+               $this->parserOutput = $content->getParserOutput(
+                       $this->page->getTitle(),
+                       $this->revid,
+                       $this->parserOptions
+               );
                $time += microtime( true );
 
                // Timing hack
@@ -3673,7 +3707,7 @@ class PoolWorkArticleView extends PoolCounterWork {
        }
 
        /**
-        * @param $status Status
+        * @param Status $status
         * @return bool
         */
        public function error( $status ) {