http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89664

Revision: 89664
Author:   reedy
Date:     2011-06-07 17:46:15 +0000 (Tue, 07 Jun 2011)
Log Message:
-----------
Commenty tweaky stuffs

Modified Paths:
--------------
    trunk/extensions/CodeReview/backend/CodeComment.php
    trunk/extensions/CodeReview/backend/CodeCommentLinker.php
    trunk/extensions/CodeReview/backend/CodePropChange.php
    trunk/extensions/CodeReview/backend/CodeRepository.php
    trunk/extensions/CodeReview/backend/CodeRevision.php
    trunk/extensions/CodeReview/backend/CodeSignoff.php
    trunk/extensions/CodeReview/backend/RepoStats.php
    trunk/extensions/CodeReview/ui/CodeRevisionView.php

Modified: trunk/extensions/CodeReview/backend/CodeComment.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodeComment.php 2011-06-07 17:34:43 UTC 
(rev 89663)
+++ trunk/extensions/CodeReview/backend/CodeComment.php 2011-06-07 17:46:15 UTC 
(rev 89664)
@@ -3,14 +3,32 @@
 class CodeComment {
        public $id, $text, $user, $userText, $timestamp, $review, $sortkey, 
$attrib, $removed, $added;
 
+       /**
+        * @var CodeRevision
+        */
+       public $rev;
+
+       /**
+        * @param $rev CodeRevision
+        */
        function __construct( $rev ) {
                $this->rev = $rev;
        }
 
+       /**
+        * @param $rev Revision
+        * @param $row
+        * @return CodeComment
+        */
        static function newFromRow( $rev, $row ) {
                return self::newFromData( $rev, get_object_vars( $row ) );
        }
 
+       /**
+        * @param $rev Revision
+        * @param $data array
+        * @return CodeComment
+        */
        static function newFromData( $rev, $data ) {
                $comment = new CodeComment( $rev );
                $comment->id = intval( $data['cc_id'] );
@@ -23,6 +41,9 @@
                return $comment;
        }
 
+       /**
+        * @return int
+        */
        function threadDepth() {
                $timestamps = explode( ",", $this->sortkey );
                return count( $timestamps );

Modified: trunk/extensions/CodeReview/backend/CodeCommentLinker.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodeCommentLinker.php   2011-06-07 
17:34:43 UTC (rev 89663)
+++ trunk/extensions/CodeReview/backend/CodeCommentLinker.php   2011-06-07 
17:46:15 UTC (rev 89664)
@@ -12,12 +12,19 @@
         */
        protected $mRepo;
 
+       /**
+        * @param $repo CodeRepository
+        */
        function __construct( $repo ) {
                global $wgUser;
                $this->skin = $wgUser->getSkin();
                $this->mRepo = $repo;
        }
 
+       /**
+        * @param $text string
+        * @return string
+        */
        function link( $text ) {
                # Catch links like 
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/44245#c829
                # Ended by space or brackets (like those pesky <br /> tags)
@@ -30,12 +37,20 @@
                return $text;
        }
 
+       /**
+        * @param $arr array
+        * @return string
+        */
        function generalLink( $arr ) {
                $url = $arr[2] . $arr[3];
                // Re-add the surrounding space/punctuation
                return $arr[1] . $this->makeExternalLink( $url, $url );
        }
 
+       /**
+        * @param $arr array
+        * @return string
+        */
        function messageBugLink( $arr ) {
                $text = $arr[0];
                $bugNo = intval( $arr[1] );
@@ -47,6 +62,9 @@
                }
        }
 
+       /**
+        * @param $matches array
+        */
        function messageRevLink( $matches ) {
                $text = $matches[0];
                $rev = intval( $matches[1] );
@@ -57,29 +75,50 @@
                return $this->makeInternalLink( $title, $text );
        }
 
+       /**
+        * @param $url string
+        * @param $text string
+        * @return string
+        */
        abstract function makeExternalLink( $url, $text );
 
        abstract function makeInternalLink( $title, $text );
 }
 
 class CodeCommentLinkerHtml extends CodeCommentLinker {
+
+       /**
+        * @param $url string
+        * @param $text string
+        * @return string
+        */
        function makeExternalLink( $url, $text ) {
                return $this->skin->makeExternalLink( $url, $text );
        }
 
+       /**
+        * @param $title Title
+        * @param $text string
+        * @return  string
+        */
        function makeInternalLink( $title, $text ) {
                return $this->skin->link( $title, $text );
        }
 }
 
 class CodeCommentLinkerWiki extends CodeCommentLinker {
+       /**
+        * @param $url string
+        * @param $text string
+        * @return string
+        */
        function makeExternalLink( $url, $text ) {
                return "[$url $text]";
        }
 
        /**
-        * @param Title $title
-        * @param  $text
+        * @param $title Title
+        * @param $text string
         * @return string
         */
        function makeInternalLink( $title, $text ) {

Modified: trunk/extensions/CodeReview/backend/CodePropChange.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodePropChange.php      2011-06-07 
17:34:43 UTC (rev 89663)
+++ trunk/extensions/CodeReview/backend/CodePropChange.php      2011-06-07 
17:46:15 UTC (rev 89664)
@@ -9,14 +9,27 @@
         */
        public $rev;
 
+       /**
+        * @param $rev CodeRevision
+        */
        function __construct( $rev ) {
                $this->rev = $rev;
        }
 
+       /**
+        * @param $rev CodeRevision
+        * @param $row
+        * @return CodePropChange
+        */
        static function newFromRow( $rev, $row ) {
                return self::newFromData( $rev, get_object_vars( $row ) );
        }
 
+       /**
+        * @param $rev CodeRevision
+        * @param $data
+        * @return CodePropChange
+        */
        static function newFromData( $rev, $data ) {
                $change = new CodePropChange( $rev );
                $change->attrib = $data['cpc_attrib'];

Modified: trunk/extensions/CodeReview/backend/CodeRepository.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodeRepository.php      2011-06-07 
17:34:43 UTC (rev 89663)
+++ trunk/extensions/CodeReview/backend/CodeRepository.php      2011-06-07 
17:46:15 UTC (rev 89664)
@@ -33,7 +33,7 @@
         * @param $id Int Database id for the repo
         * @param $name String User-defined name for the repository
         * @param $path String Path to SVN
-        * @param $viewVc String Base path to ViewVC URLs
+        * @param $viewvc String Base path to ViewVC URLs
         * @param $bugzilla String Base path to Bugzilla
         */
        public function  __construct( $id, $name, $path, $viewvc, $bugzilla ) {
@@ -44,6 +44,10 @@
                $this->bugzilla = $bugzilla;
        }
 
+       /**
+        * @param $name string
+        * @return CodeRepository|null
+        */
        public static function newFromName( $name ) {
                $dbw = wfGetDB( DB_MASTER );
                $row = $dbw->selectRow(
@@ -64,6 +68,10 @@
                }
        }
 
+       /**
+        * @param $id int
+        * @return CodeRepository|null
+        */
        public static function newFromId( $id ) {
                $dbw = wfGetDB( DB_MASTER );
                $row = $dbw->selectRow(
@@ -84,6 +92,10 @@
                }
        }
 
+       /**
+        * @param $row
+        * @return CodeRepository
+        */
        static function newFromRow( $row ) {
                return new CodeRepository(
                        intval( $row->repo_id ),
@@ -94,6 +106,9 @@
                );
        }
 
+       /**
+        * @return array
+        */
        static function getRepoList() {
                $dbr = wfGetDB( DB_SLAVE );
                $options = array( 'ORDER BY' => 'repo_name' );
@@ -105,28 +120,46 @@
                return $repos;
        }
 
+       /**
+        * @return int
+        */
        public function getId() {
                return intval( $this->id );
        }
 
+       /**
+        * @return String
+        */
        public function getName() {
                return $this->name;
        }
 
+       /**
+        * @return String
+        */
        public function getPath() {
                return $this->path;
        }
 
+       /**
+        * @return String
+        */
        public function getViewVcBase() {
                return $this->viewVc;
        }
 
+       /**
+        * @return String
+        */
        public function getBugzillaBase() {
                return $this->bugzilla;
        }
 
        /**
-        * Return a bug URL or false.
+        * Return a bug URL or false
+        *
+        * @param $bugId int|string
+        * @return string|false.
         */
        public function getBugPath( $bugId ) {
                if ( $this->bugzilla ) {
@@ -136,6 +169,9 @@
                return false;
        }
 
+       /**
+        * @return int
+        */
        public function getLastStoredRev() {
                $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectField(
@@ -147,6 +183,9 @@
                return intval( $row );
        }
 
+       /**
+        * @return array
+        */
        public function getAuthorList() {
                global $wgMemc;
                $key = wfMemcKey( 'codereview', 'authors', $this->getId() );
@@ -173,6 +212,9 @@
                return $authors;
        }
 
+       /**
+        * @return int
+        */
        public function getAuthorCount() {
                return count( $this->getAuthorList() );
        }
@@ -208,6 +250,8 @@
 
        /**
         * Load a particular revision out of the DB
+        * @param $id int|string
+        * @return CodeRevision
         */
        public function getRevision( $id ) {
                if ( !$this->isValidRev( $id ) ) {
@@ -231,6 +275,9 @@
        /**
         * Returns the supplied revision ID as a string ready for output, 
including the
         * appropriate (localisable) prefix (e.g. "r123" instead of 123).
+        *
+        * @param $id string
+        * @return string
         */
        public function getRevIdString( $id ) {
                return wfMsg( 'code-rev-id', $id );
@@ -244,6 +291,9 @@
         * confusing (e.g. in e-mails, page titles etc.).  If only one 
repository is
         * defined then this returns the same as getRevIdString() as there
         * is no ambiguity.
+        *
+        * @param $id string
+        * @return string
         */
        public function getRevIdStringUnique( $id ) {
                $id = wfMsg( 'code-rev-id', $id );
@@ -258,8 +308,8 @@
        }
 
        /**
-        * @param int $rev Revision ID
-        * @param $useCache 'skipcache' to avoid caching
+        * @param $rev int Revision ID
+        * @param $useCache string 'skipcache' to avoid caching
         *                   'cached' to *only* fetch if cached
         * @return string|int The diff text on success, a DIFFRESULT_* constant 
on failure.
         */
@@ -471,6 +521,9 @@
        /**
         * returns a User object if $author has a wikiuser associated,
         * or false
+        *
+        * @param $author string
+        *
         * @return User|bool
         */
        public function authorWikiUser( $author ) {
@@ -503,6 +556,10 @@
        /**
         * returns an author name if $name wikiuser has an author associated,
         * or false
+        *
+        * @param $name string
+        *
+        * @return string|false
         */
        public function wikiUserAuthor( $name ) {
                if ( isset( self::$authorLinks[$name] ) )

Modified: trunk/extensions/CodeReview/backend/CodeRevision.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodeRevision.php        2011-06-07 
17:34:43 UTC (rev 89663)
+++ trunk/extensions/CodeReview/backend/CodeRevision.php        2011-06-07 
17:46:15 UTC (rev 89664)
@@ -165,8 +165,8 @@
         * confusing (e.g. in e-mails, page titles etc.).  If only one 
repository is
         * defined then this returns the same as getIdString() as there is no 
ambiguity.
         *
-        * @param null $id
-        * @return
+        * @param $id int
+        * @return string
         */
        public function getIdStringUnique( $id = null ) {
                if ( $id === null ) {
@@ -743,7 +743,7 @@
                return $comments;
        }
 
-       /*
+       /**
         * @return int
         */
        public function getCommentCount() {
@@ -813,8 +813,10 @@
        }
 
        /**
-       * "Review" being revision commenters, and people who set/removed tags 
and changed the status
-       */
+        * "Review" being revision commenters, and people who set/removed tags 
and changed the status
+        *
+        * @return array
+        */
        public function getReviewContributingUsers() {
                return array_merge( $this->getCommentingUsers(), 
$this->getPropChangeUsers() );
        }
@@ -936,7 +938,7 @@
 
        /**
         * Get all sign-offs for this revision
-        * @param $from DB_SLAVE or DB_MASTER
+        * @param $from int DB_SLAVE or DB_MASTER
         * @return array of CodeSignoff objects
         */
        public function getSignoffs( $from = DB_SLAVE ) {
@@ -1018,10 +1020,9 @@
        }
 
        /**
-        * @param  $addTags
-        * @param  $removeTags
-        * @param null $user
-        * @return void
+        * @param $addTags array
+        * @param $removeTags array
+        * @param $user User
         */
        public function changeTags( $addTags, $removeTags, $user = null ) {
                // Get the current tags and see what changes
@@ -1258,9 +1259,8 @@
        }
 
        /**
-        * @param  $status
-        * @param  $oldStatus
-        * @return void
+        * @param $status string
+        * @param $oldStatus string
         */
        protected function sendStatusToUDP( $status, $oldStatus ) {
                global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, 
$wgCodeReviewUDPPrefix, $wgUser;

Modified: trunk/extensions/CodeReview/backend/CodeSignoff.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodeSignoff.php 2011-06-07 17:34:43 UTC 
(rev 89663)
+++ trunk/extensions/CodeReview/backend/CodeSignoff.php 2011-06-07 17:46:15 UTC 
(rev 89664)
@@ -98,7 +98,7 @@
        /**
         * Create a CodeSignoff object from a revision and a database row in 
array format
         * @param $rev CodeRevision object the signoff belongs to
-        * @param $row array Database row with cs_* fields from code_signoffs
+        * @param $data array Database row with cs_* fields from code_signoffs
         * @return CodeSignoff
         */
        public static function newFromData( $rev, $data ) {

Modified: trunk/extensions/CodeReview/backend/RepoStats.php
===================================================================
--- trunk/extensions/CodeReview/backend/RepoStats.php   2011-06-07 17:34:43 UTC 
(rev 89663)
+++ trunk/extensions/CodeReview/backend/RepoStats.php   2011-06-07 17:46:15 UTC 
(rev 89664)
@@ -1,6 +1,10 @@
 <?php
 
 class RepoStats {
+
+       /**
+        * @var CodeRepository
+        */
        private $repo;
 
        public $time;
@@ -11,6 +15,10 @@
                $states,
                $fixmes;
 
+       /**
+        * @param CodeRepository $repo
+        * @return RepoStats
+        */
        public static function newFromRepo( CodeRepository $repo ) {
                global $wgMemc, $wgCodeReviewRepoStatsCacheTime;
 
@@ -28,6 +36,9 @@
                return $stats;
        }
 
+       /**
+        * @param $repo CodeRepository
+        */
        public function __construct( CodeRepository $repo ) {
                $this->repo = $repo;
                $this->time = wfTimestamp( TS_MW );

Modified: trunk/extensions/CodeReview/ui/CodeRevisionView.php
===================================================================
--- trunk/extensions/CodeReview/ui/CodeRevisionView.php 2011-06-07 17:34:43 UTC 
(rev 89663)
+++ trunk/extensions/CodeReview/ui/CodeRevisionView.php 2011-06-07 17:46:15 UTC 
(rev 89664)
@@ -9,7 +9,6 @@
         * @param string|CodeRepository $repo
         * @param string|CodeRevision $rev
         * @param null $replyTarget
-        *
         */
        function __construct( $repo, $rev, $replyTarget = null ) {
                parent::__construct( $repo );
@@ -57,6 +56,10 @@
                        $wgRequest->getIntArray( 'wpReferences', array() ) : 
array();
        }
 
+       /**
+        * @param $item string
+        * @return int
+        */
        private function ltrimIntval( $item ) {
                $item = ltrim( $item, 'r' );
                return intval( $item );
@@ -240,6 +243,9 @@
                return false;
        }
 
+       /**
+        * @return bool
+        */
        protected function canPostComments() {
                global $wgUser;
                return $wgUser->isAllowed( 'codereview-post-comment' ) && 
!$wgUser->isBlocked();
@@ -332,6 +338,10 @@
                return $tags;
        }
 
+       /**
+        * @param $tags array
+        * @return string
+        */
        static function listTags( $tags ) {
                if ( empty( $tags ) ) {
                        return "";
@@ -339,6 +349,9 @@
                return implode( ",", $tags );
        }
 
+       /**
+        * @return string
+        */
        protected function statusForm() {
                global $wgUser;
                if ( $wgUser->isAllowed( 'codereview-set-status' ) ) {
@@ -366,7 +379,12 @@
                return $out;
        }
 
-       /** Parameters are the tags to be added/removed sent with the request */
+       /**
+        * Parameters are the tags to be added/removed sent with the request
+        * @param $addTags array
+        * @param $removeTags array
+        * @return string
+        */
        static function addTagForm( $addTags, $removeTags ) {
                return '<div><table><tr><td>' .
                        Xml::inputLabel( wfMsg( 'code-rev-tag-add' ), 'wpTag', 
'wpTag', 20,
@@ -375,12 +393,19 @@
                                self::listTags( $removeTags ) ) . 
'</td></tr></table></div>';
        }
 
+       /**
+        * @param $tag string
+        * @return string
+        */
        protected function formatTag( $tag ) {
                $repo = $this->mRepo->getName();
                $special = SpecialPage::getTitleFor( 'Code', "$repo/tag/$tag" );
                return $this->skin->link( $special, htmlspecialchars( $tag ) );
        }
 
+       /**
+        * @return string
+        */
        protected function formatDiff() {
                global $wgEnableAPI, $wgCodeReviewMaxDiffSize;
 
@@ -413,6 +438,9 @@
                }
        }
 
+       /**
+        * @return string
+        */
        protected function formatImgDiff() {
                global $wgCodeReviewImgRegex;
                // Get image diffs
@@ -445,6 +473,12 @@
                return $html;
        }
 
+       /**
+        * @param $path
+        * @param $rev
+        * @param $message
+        * @return string
+        */
        protected function formatImgCell( $path, $rev, $message ) {
                $viewvc = $this->mRepo->getViewVcBase();
                $safePath = wfUrlEncode( $path );
@@ -464,6 +498,9 @@
                                                'border' => '0' ) ) ) );
        }
 
+       /**
+        * @return bool|string
+        */
        protected function stubDiffLoader() {
                global $wgOut;
                $encRepo = Xml::encodeJsVar( $this->mRepo->getName() );
@@ -480,6 +517,7 @@
        
        /**
         * Format the sign-offs table
+        * @param $signOffs array
         * @param $showButtons bool Whether the buttons to strike and submit 
sign-offs should be shown
         * @return string HTML
         */
@@ -500,6 +538,9 @@
                return "<table border='1' 
class='TablePager'><tr>$header</tr>$signoffs$buttonrow</table>";
        }
 
+       /**
+        * @return bool|string
+        */
        protected function formatComments() {
                $comments = implode( "\n",
                        array_map( array( $this, 'formatCommentInline' ), 
$this->mRev->getComments() )
@@ -513,6 +554,9 @@
                return "<div class='mw-codereview-comments'>$comments</div>";
        }
 
+       /**
+        * @return bool|string
+        */
        protected function formatPropChanges() {
                $changes = implode( "\n",
                        array_map( array( $this, 'formatChangeInline' ), 
$this->mRev->getPropChanges() )
@@ -523,6 +567,11 @@
                return "<ul class='mw-codereview-changes'>$changes</ul>";
        }
 
+       /**
+        * @param $references array
+        * @param $showButtons bool
+        * @return string
+        */
        protected function formatReferences( $references, $showButtons ) {
                $this->showButtonsFormatReference = $showButtons;
                $refs = implode( "\n",
@@ -583,7 +632,7 @@
        }
 
        /**
-        * @param  $change CodePropChange
+        * @param $change CodePropChange
         * @return string
         */
        protected function formatChangeInline( $change ) {
@@ -623,6 +672,10 @@
                return "<li>$line</li>";
        }
 
+       /**
+        * @param $row
+        * @return string
+        */
        protected function formatReferenceInline( $row ) {
                global $wgLang;
                $rev = intval( $row->cr_id );
@@ -644,6 +697,10 @@
                return $ret;
        }
 
+       /**
+        * @param $commentId int
+        * @return Title
+        */
        protected function commentLink( $commentId ) {
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();
@@ -652,6 +709,9 @@
                return $title;
        }
 
+       /**
+        * @return Title
+        */
        protected function revLink() {
                $repo = $this->mRepo->getName();
                $rev = $this->mRev->getId();
@@ -659,6 +719,11 @@
                return $title;
        }
 
+       /**
+        * @param $text string
+        * @param $review int
+        * @return string
+        */
        protected function previewComment( $text, $review = 0 ) {
                $comment = $this->mRev->previewComment( $text, $review );
                return $this->formatComment( $comment );
@@ -716,6 +781,10 @@
                return "margin-left: ${margin}px";
        }
 
+       /**
+        * @param $id int
+        * @return string
+        */
        protected function commentReplyLink( $id ) {
                if ( !$this->canPostComments() ) {
                        return '';
@@ -760,6 +829,8 @@
        /**
         * Render the bottom row of the sign-offs table containing the buttons 
to
         * strike and submit sign-offs
+        *
+        * @param $signOffs array
         * @return string HTML
         */
        protected function signoffButtons( $signOffs ) {
@@ -815,6 +886,9 @@
                        "<div 
class='mw-codereview-associateform'>$associateText $textbox 
$associateButton</div></td></tr>";
        }
 
+       /**
+        * @return string
+        */
        protected function addActionButtons() {
                return '<div>' .
                        Xml::submitButton( wfMsg( 'code-rev-submit' ),


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to