r89664 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89663‎ | r89664 | r89665 >
Date:17:46, 7 June 2011
Author:reedy
Status:ok
Tags:
Comment:
Commenty tweaky stuffs
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeComment.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeCommentLinker.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodePropChange.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeRepository.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/CodeSignoff.php (modified) (history)
  • /trunk/extensions/CodeReview/backend/RepoStats.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -165,8 +165,8 @@
166166 * confusing (e.g. in e-mails, page titles etc.). If only one repository is
167167 * defined then this returns the same as getIdString() as there is no ambiguity.
168168 *
169 - * @param null $id
170 - * @return
 169+ * @param $id int
 170+ * @return string
171171 */
172172 public function getIdStringUnique( $id = null ) {
173173 if ( $id === null ) {
@@ -743,7 +743,7 @@
744744 return $comments;
745745 }
746746
747 - /*
 747+ /**
748748 * @return int
749749 */
750750 public function getCommentCount() {
@@ -813,8 +813,10 @@
814814 }
815815
816816 /**
817 - * "Review" being revision commenters, and people who set/removed tags and changed the status
818 - */
 817+ * "Review" being revision commenters, and people who set/removed tags and changed the status
 818+ *
 819+ * @return array
 820+ */
819821 public function getReviewContributingUsers() {
820822 return array_merge( $this->getCommentingUsers(), $this->getPropChangeUsers() );
821823 }
@@ -936,7 +938,7 @@
937939
938940 /**
939941 * Get all sign-offs for this revision
940 - * @param $from DB_SLAVE or DB_MASTER
 942+ * @param $from int DB_SLAVE or DB_MASTER
941943 * @return array of CodeSignoff objects
942944 */
943945 public function getSignoffs( $from = DB_SLAVE ) {
@@ -1018,10 +1020,9 @@
10191021 }
10201022
10211023 /**
1022 - * @param $addTags
1023 - * @param $removeTags
1024 - * @param null $user
1025 - * @return void
 1024+ * @param $addTags array
 1025+ * @param $removeTags array
 1026+ * @param $user User
10261027 */
10271028 public function changeTags( $addTags, $removeTags, $user = null ) {
10281029 // Get the current tags and see what changes
@@ -1258,9 +1259,8 @@
12591260 }
12601261
12611262 /**
1262 - * @param $status
1263 - * @param $oldStatus
1264 - * @return void
 1263+ * @param $status string
 1264+ * @param $oldStatus string
12651265 */
12661266 protected function sendStatusToUDP( $status, $oldStatus ) {
12671267 global $wgCodeReviewUDPAddress, $wgCodeReviewUDPPort, $wgCodeReviewUDPPrefix, $wgUser;
Index: trunk/extensions/CodeReview/backend/CodeRepository.php
@@ -33,7 +33,7 @@
3434 * @param $id Int Database id for the repo
3535 * @param $name String User-defined name for the repository
3636 * @param $path String Path to SVN
37 - * @param $viewVc String Base path to ViewVC URLs
 37+ * @param $viewvc String Base path to ViewVC URLs
3838 * @param $bugzilla String Base path to Bugzilla
3939 */
4040 public function __construct( $id, $name, $path, $viewvc, $bugzilla ) {
@@ -44,6 +44,10 @@
4545 $this->bugzilla = $bugzilla;
4646 }
4747
 48+ /**
 49+ * @param $name string
 50+ * @return CodeRepository|null
 51+ */
4852 public static function newFromName( $name ) {
4953 $dbw = wfGetDB( DB_MASTER );
5054 $row = $dbw->selectRow(
@@ -64,6 +68,10 @@
6569 }
6670 }
6771
 72+ /**
 73+ * @param $id int
 74+ * @return CodeRepository|null
 75+ */
6876 public static function newFromId( $id ) {
6977 $dbw = wfGetDB( DB_MASTER );
7078 $row = $dbw->selectRow(
@@ -84,6 +92,10 @@
8593 }
8694 }
8795
 96+ /**
 97+ * @param $row
 98+ * @return CodeRepository
 99+ */
88100 static function newFromRow( $row ) {
89101 return new CodeRepository(
90102 intval( $row->repo_id ),
@@ -94,6 +106,9 @@
95107 );
96108 }
97109
 110+ /**
 111+ * @return array
 112+ */
98113 static function getRepoList() {
99114 $dbr = wfGetDB( DB_SLAVE );
100115 $options = array( 'ORDER BY' => 'repo_name' );
@@ -105,28 +120,46 @@
106121 return $repos;
107122 }
108123
 124+ /**
 125+ * @return int
 126+ */
109127 public function getId() {
110128 return intval( $this->id );
111129 }
112130
 131+ /**
 132+ * @return String
 133+ */
113134 public function getName() {
114135 return $this->name;
115136 }
116137
 138+ /**
 139+ * @return String
 140+ */
117141 public function getPath() {
118142 return $this->path;
119143 }
120144
 145+ /**
 146+ * @return String
 147+ */
121148 public function getViewVcBase() {
122149 return $this->viewVc;
123150 }
124151
 152+ /**
 153+ * @return String
 154+ */
125155 public function getBugzillaBase() {
126156 return $this->bugzilla;
127157 }
128158
129159 /**
130 - * Return a bug URL or false.
 160+ * Return a bug URL or false
 161+ *
 162+ * @param $bugId int|string
 163+ * @return string|false.
131164 */
132165 public function getBugPath( $bugId ) {
133166 if ( $this->bugzilla ) {
@@ -136,6 +169,9 @@
137170 return false;
138171 }
139172
 173+ /**
 174+ * @return int
 175+ */
140176 public function getLastStoredRev() {
141177 $dbr = wfGetDB( DB_SLAVE );
142178 $row = $dbr->selectField(
@@ -147,6 +183,9 @@
148184 return intval( $row );
149185 }
150186
 187+ /**
 188+ * @return array
 189+ */
151190 public function getAuthorList() {
152191 global $wgMemc;
153192 $key = wfMemcKey( 'codereview', 'authors', $this->getId() );
@@ -173,6 +212,9 @@
174213 return $authors;
175214 }
176215
 216+ /**
 217+ * @return int
 218+ */
177219 public function getAuthorCount() {
178220 return count( $this->getAuthorList() );
179221 }
@@ -208,6 +250,8 @@
209251
210252 /**
211253 * Load a particular revision out of the DB
 254+ * @param $id int|string
 255+ * @return CodeRevision
212256 */
213257 public function getRevision( $id ) {
214258 if ( !$this->isValidRev( $id ) ) {
@@ -231,6 +275,9 @@
232276 /**
233277 * Returns the supplied revision ID as a string ready for output, including the
234278 * appropriate (localisable) prefix (e.g. "r123" instead of 123).
 279+ *
 280+ * @param $id string
 281+ * @return string
235282 */
236283 public function getRevIdString( $id ) {
237284 return wfMsg( 'code-rev-id', $id );
@@ -244,6 +291,9 @@
245292 * confusing (e.g. in e-mails, page titles etc.). If only one repository is
246293 * defined then this returns the same as getRevIdString() as there
247294 * is no ambiguity.
 295+ *
 296+ * @param $id string
 297+ * @return string
248298 */
249299 public function getRevIdStringUnique( $id ) {
250300 $id = wfMsg( 'code-rev-id', $id );
@@ -258,8 +308,8 @@
259309 }
260310
261311 /**
262 - * @param int $rev Revision ID
263 - * @param $useCache 'skipcache' to avoid caching
 312+ * @param $rev int Revision ID
 313+ * @param $useCache string 'skipcache' to avoid caching
264314 * 'cached' to *only* fetch if cached
265315 * @return string|int The diff text on success, a DIFFRESULT_* constant on failure.
266316 */
@@ -471,6 +521,9 @@
472522 /**
473523 * returns a User object if $author has a wikiuser associated,
474524 * or false
 525+ *
 526+ * @param $author string
 527+ *
475528 * @return User|bool
476529 */
477530 public function authorWikiUser( $author ) {
@@ -503,6 +556,10 @@
504557 /**
505558 * returns an author name if $name wikiuser has an author associated,
506559 * or false
 560+ *
 561+ * @param $name string
 562+ *
 563+ * @return string|false
507564 */
508565 public function wikiUserAuthor( $name ) {
509566 if ( isset( self::$authorLinks[$name] ) )
Index: trunk/extensions/CodeReview/backend/CodeComment.php
@@ -3,14 +3,32 @@
44 class CodeComment {
55 public $id, $text, $user, $userText, $timestamp, $review, $sortkey, $attrib, $removed, $added;
66
 7+ /**
 8+ * @var CodeRevision
 9+ */
 10+ public $rev;
 11+
 12+ /**
 13+ * @param $rev CodeRevision
 14+ */
715 function __construct( $rev ) {
816 $this->rev = $rev;
917 }
1018
 19+ /**
 20+ * @param $rev Revision
 21+ * @param $row
 22+ * @return CodeComment
 23+ */
1124 static function newFromRow( $rev, $row ) {
1225 return self::newFromData( $rev, get_object_vars( $row ) );
1326 }
1427
 28+ /**
 29+ * @param $rev Revision
 30+ * @param $data array
 31+ * @return CodeComment
 32+ */
1533 static function newFromData( $rev, $data ) {
1634 $comment = new CodeComment( $rev );
1735 $comment->id = intval( $data['cc_id'] );
@@ -23,6 +41,9 @@
2442 return $comment;
2543 }
2644
 45+ /**
 46+ * @return int
 47+ */
2748 function threadDepth() {
2849 $timestamps = explode( ",", $this->sortkey );
2950 return count( $timestamps );
Index: trunk/extensions/CodeReview/backend/CodePropChange.php
@@ -9,14 +9,27 @@
1010 */
1111 public $rev;
1212
 13+ /**
 14+ * @param $rev CodeRevision
 15+ */
1316 function __construct( $rev ) {
1417 $this->rev = $rev;
1518 }
1619
 20+ /**
 21+ * @param $rev CodeRevision
 22+ * @param $row
 23+ * @return CodePropChange
 24+ */
1725 static function newFromRow( $rev, $row ) {
1826 return self::newFromData( $rev, get_object_vars( $row ) );
1927 }
2028
 29+ /**
 30+ * @param $rev CodeRevision
 31+ * @param $data
 32+ * @return CodePropChange
 33+ */
2134 static function newFromData( $rev, $data ) {
2235 $change = new CodePropChange( $rev );
2336 $change->attrib = $data['cpc_attrib'];
Index: trunk/extensions/CodeReview/backend/CodeCommentLinker.php
@@ -12,12 +12,19 @@
1313 */
1414 protected $mRepo;
1515
 16+ /**
 17+ * @param $repo CodeRepository
 18+ */
1619 function __construct( $repo ) {
1720 global $wgUser;
1821 $this->skin = $wgUser->getSkin();
1922 $this->mRepo = $repo;
2023 }
2124
 25+ /**
 26+ * @param $text string
 27+ * @return string
 28+ */
2229 function link( $text ) {
2330 # Catch links like http://www.mediawiki.org/wiki/Special:Code/MediaWiki/44245#c829
2431 # Ended by space or brackets (like those pesky <br /> tags)
@@ -30,12 +37,20 @@
3138 return $text;
3239 }
3340
 41+ /**
 42+ * @param $arr array
 43+ * @return string
 44+ */
3445 function generalLink( $arr ) {
3546 $url = $arr[2] . $arr[3];
3647 // Re-add the surrounding space/punctuation
3748 return $arr[1] . $this->makeExternalLink( $url, $url );
3849 }
3950
 51+ /**
 52+ * @param $arr array
 53+ * @return string
 54+ */
4055 function messageBugLink( $arr ) {
4156 $text = $arr[0];
4257 $bugNo = intval( $arr[1] );
@@ -47,6 +62,9 @@
4863 }
4964 }
5065
 66+ /**
 67+ * @param $matches array
 68+ */
5169 function messageRevLink( $matches ) {
5270 $text = $matches[0];
5371 $rev = intval( $matches[1] );
@@ -57,29 +75,50 @@
5876 return $this->makeInternalLink( $title, $text );
5977 }
6078
 79+ /**
 80+ * @param $url string
 81+ * @param $text string
 82+ * @return string
 83+ */
6184 abstract function makeExternalLink( $url, $text );
6285
6386 abstract function makeInternalLink( $title, $text );
6487 }
6588
6689 class CodeCommentLinkerHtml extends CodeCommentLinker {
 90+
 91+ /**
 92+ * @param $url string
 93+ * @param $text string
 94+ * @return string
 95+ */
6796 function makeExternalLink( $url, $text ) {
6897 return $this->skin->makeExternalLink( $url, $text );
6998 }
7099
 100+ /**
 101+ * @param $title Title
 102+ * @param $text string
 103+ * @return string
 104+ */
71105 function makeInternalLink( $title, $text ) {
72106 return $this->skin->link( $title, $text );
73107 }
74108 }
75109
76110 class CodeCommentLinkerWiki extends CodeCommentLinker {
 111+ /**
 112+ * @param $url string
 113+ * @param $text string
 114+ * @return string
 115+ */
77116 function makeExternalLink( $url, $text ) {
78117 return "[$url $text]";
79118 }
80119
81120 /**
82 - * @param Title $title
83 - * @param $text
 121+ * @param $title Title
 122+ * @param $text string
84123 * @return string
85124 */
86125 function makeInternalLink( $title, $text ) {
Index: trunk/extensions/CodeReview/backend/RepoStats.php
@@ -1,6 +1,10 @@
22 <?php
33
44 class RepoStats {
 5+
 6+ /**
 7+ * @var CodeRepository
 8+ */
59 private $repo;
610
711 public $time;
@@ -11,6 +15,10 @@
1216 $states,
1317 $fixmes;
1418
 19+ /**
 20+ * @param CodeRepository $repo
 21+ * @return RepoStats
 22+ */
1523 public static function newFromRepo( CodeRepository $repo ) {
1624 global $wgMemc, $wgCodeReviewRepoStatsCacheTime;
1725
@@ -28,6 +36,9 @@
2937 return $stats;
3038 }
3139
 40+ /**
 41+ * @param $repo CodeRepository
 42+ */
3243 public function __construct( CodeRepository $repo ) {
3344 $this->repo = $repo;
3445 $this->time = wfTimestamp( TS_MW );
Index: trunk/extensions/CodeReview/backend/CodeSignoff.php
@@ -98,7 +98,7 @@
9999 /**
100100 * Create a CodeSignoff object from a revision and a database row in array format
101101 * @param $rev CodeRevision object the signoff belongs to
102 - * @param $row array Database row with cs_* fields from code_signoffs
 102+ * @param $data array Database row with cs_* fields from code_signoffs
103103 * @return CodeSignoff
104104 */
105105 public static function newFromData( $rev, $data ) {
Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php
@@ -9,7 +9,6 @@
1010 * @param string|CodeRepository $repo
1111 * @param string|CodeRevision $rev
1212 * @param null $replyTarget
13 - *
1413 */
1514 function __construct( $repo, $rev, $replyTarget = null ) {
1615 parent::__construct( $repo );
@@ -57,6 +56,10 @@
5857 $wgRequest->getIntArray( 'wpReferences', array() ) : array();
5958 }
6059
 60+ /**
 61+ * @param $item string
 62+ * @return int
 63+ */
6164 private function ltrimIntval( $item ) {
6265 $item = ltrim( $item, 'r' );
6366 return intval( $item );
@@ -240,6 +243,9 @@
241244 return false;
242245 }
243246
 247+ /**
 248+ * @return bool
 249+ */
244250 protected function canPostComments() {
245251 global $wgUser;
246252 return $wgUser->isAllowed( 'codereview-post-comment' ) && !$wgUser->isBlocked();
@@ -332,6 +338,10 @@
333339 return $tags;
334340 }
335341
 342+ /**
 343+ * @param $tags array
 344+ * @return string
 345+ */
336346 static function listTags( $tags ) {
337347 if ( empty( $tags ) ) {
338348 return "";
@@ -339,6 +349,9 @@
340350 return implode( ",", $tags );
341351 }
342352
 353+ /**
 354+ * @return string
 355+ */
343356 protected function statusForm() {
344357 global $wgUser;
345358 if ( $wgUser->isAllowed( 'codereview-set-status' ) ) {
@@ -366,7 +379,12 @@
367380 return $out;
368381 }
369382
370 - /** Parameters are the tags to be added/removed sent with the request */
 383+ /**
 384+ * Parameters are the tags to be added/removed sent with the request
 385+ * @param $addTags array
 386+ * @param $removeTags array
 387+ * @return string
 388+ */
371389 static function addTagForm( $addTags, $removeTags ) {
372390 return '<div><table><tr><td>' .
373391 Xml::inputLabel( wfMsg( 'code-rev-tag-add' ), 'wpTag', 'wpTag', 20,
@@ -375,12 +393,19 @@
376394 self::listTags( $removeTags ) ) . '</td></tr></table></div>';
377395 }
378396
 397+ /**
 398+ * @param $tag string
 399+ * @return string
 400+ */
379401 protected function formatTag( $tag ) {
380402 $repo = $this->mRepo->getName();
381403 $special = SpecialPage::getTitleFor( 'Code', "$repo/tag/$tag" );
382404 return $this->skin->link( $special, htmlspecialchars( $tag ) );
383405 }
384406
 407+ /**
 408+ * @return string
 409+ */
385410 protected function formatDiff() {
386411 global $wgEnableAPI, $wgCodeReviewMaxDiffSize;
387412
@@ -413,6 +438,9 @@
414439 }
415440 }
416441
 442+ /**
 443+ * @return string
 444+ */
417445 protected function formatImgDiff() {
418446 global $wgCodeReviewImgRegex;
419447 // Get image diffs
@@ -445,6 +473,12 @@
446474 return $html;
447475 }
448476
 477+ /**
 478+ * @param $path
 479+ * @param $rev
 480+ * @param $message
 481+ * @return string
 482+ */
449483 protected function formatImgCell( $path, $rev, $message ) {
450484 $viewvc = $this->mRepo->getViewVcBase();
451485 $safePath = wfUrlEncode( $path );
@@ -464,6 +498,9 @@
465499 'border' => '0' ) ) ) );
466500 }
467501
 502+ /**
 503+ * @return bool|string
 504+ */
468505 protected function stubDiffLoader() {
469506 global $wgOut;
470507 $encRepo = Xml::encodeJsVar( $this->mRepo->getName() );
@@ -480,6 +517,7 @@
481518
482519 /**
483520 * Format the sign-offs table
 521+ * @param $signOffs array
484522 * @param $showButtons bool Whether the buttons to strike and submit sign-offs should be shown
485523 * @return string HTML
486524 */
@@ -500,6 +538,9 @@
501539 return "<table border='1' class='TablePager'><tr>$header</tr>$signoffs$buttonrow</table>";
502540 }
503541
 542+ /**
 543+ * @return bool|string
 544+ */
504545 protected function formatComments() {
505546 $comments = implode( "\n",
506547 array_map( array( $this, 'formatCommentInline' ), $this->mRev->getComments() )
@@ -513,6 +554,9 @@
514555 return "<div class='mw-codereview-comments'>$comments</div>";
515556 }
516557
 558+ /**
 559+ * @return bool|string
 560+ */
517561 protected function formatPropChanges() {
518562 $changes = implode( "\n",
519563 array_map( array( $this, 'formatChangeInline' ), $this->mRev->getPropChanges() )
@@ -523,6 +567,11 @@
524568 return "<ul class='mw-codereview-changes'>$changes</ul>";
525569 }
526570
 571+ /**
 572+ * @param $references array
 573+ * @param $showButtons bool
 574+ * @return string
 575+ */
527576 protected function formatReferences( $references, $showButtons ) {
528577 $this->showButtonsFormatReference = $showButtons;
529578 $refs = implode( "\n",
@@ -583,7 +632,7 @@
584633 }
585634
586635 /**
587 - * @param $change CodePropChange
 636+ * @param $change CodePropChange
588637 * @return string
589638 */
590639 protected function formatChangeInline( $change ) {
@@ -623,6 +672,10 @@
624673 return "<li>$line</li>";
625674 }
626675
 676+ /**
 677+ * @param $row
 678+ * @return string
 679+ */
627680 protected function formatReferenceInline( $row ) {
628681 global $wgLang;
629682 $rev = intval( $row->cr_id );
@@ -644,6 +697,10 @@
645698 return $ret;
646699 }
647700
 701+ /**
 702+ * @param $commentId int
 703+ * @return Title
 704+ */
648705 protected function commentLink( $commentId ) {
649706 $repo = $this->mRepo->getName();
650707 $rev = $this->mRev->getId();
@@ -652,6 +709,9 @@
653710 return $title;
654711 }
655712
 713+ /**
 714+ * @return Title
 715+ */
656716 protected function revLink() {
657717 $repo = $this->mRepo->getName();
658718 $rev = $this->mRev->getId();
@@ -659,6 +719,11 @@
660720 return $title;
661721 }
662722
 723+ /**
 724+ * @param $text string
 725+ * @param $review int
 726+ * @return string
 727+ */
663728 protected function previewComment( $text, $review = 0 ) {
664729 $comment = $this->mRev->previewComment( $text, $review );
665730 return $this->formatComment( $comment );
@@ -716,6 +781,10 @@
717782 return "margin-left: ${margin}px";
718783 }
719784
 785+ /**
 786+ * @param $id int
 787+ * @return string
 788+ */
720789 protected function commentReplyLink( $id ) {
721790 if ( !$this->canPostComments() ) {
722791 return '';
@@ -760,6 +829,8 @@
761830 /**
762831 * Render the bottom row of the sign-offs table containing the buttons to
763832 * strike and submit sign-offs
 833+ *
 834+ * @param $signOffs array
764835 * @return string HTML
765836 */
766837 protected function signoffButtons( $signOffs ) {
@@ -815,6 +886,9 @@
816887 "<div class='mw-codereview-associateform'>$associateText $textbox $associateButton</div></td></tr>";
817888 }
818889
 890+ /**
 891+ * @return string
 892+ */
819893 protected function addActionButtons() {
820894 return '<div>' .
821895 Xml::submitButton( wfMsg( 'code-rev-submit' ),

Status & tagging log