r94597 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94596‎ | r94597 | r94598 >
Date:00:41, 16 August 2011
Author:reedy
Status:ok
Tags:
Comment:
Explicitally define some member variables

Fix/update/add to comments

Add some braces
Modified paths:
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -40,6 +40,26 @@
4141 /// No idea, apparently used by some other classes
4242 protected $mPrefix;
4343
 44+ /**
 45+ * @var int
 46+ */
 47+ protected $limit, $offset;
 48+
 49+ /**
 50+ * @var array
 51+ */
 52+ protected $namespaces;
 53+
 54+ /**
 55+ * @var bool
 56+ */
 57+ protected $searchRedirects;
 58+
 59+ /**
 60+ * @var string
 61+ */
 62+ protected $didYouMeanHtml, $fulltext;
 63+
4464 const NAMESPACES_CURRENT = 'sense';
4565
4666 public function __construct() {
@@ -213,8 +233,9 @@
214234 $rewritten = $search->replacePrefixes($term);
215235
216236 $titleMatches = $search->searchTitle( $rewritten );
217 - if( !($titleMatches instanceof SearchResultTooMany))
 237+ if( !( $titleMatches instanceof SearchResultTooMany ) ) {
218238 $textMatches = $search->searchText( $rewritten );
 239+ }
219240
220241 // did you mean... suggestions
221242 if( $textMatches && $textMatches->hasSuggestion() ) {
@@ -223,8 +244,9 @@
224245 # mirror Go/Search behaviour of original request ..
225246 $didYouMeanParams = array( 'search' => $textMatches->getSuggestionQuery() );
226247
227 - if($this->fulltext != null)
 248+ if( $this->fulltext != null ) {
228249 $didYouMeanParams['fulltext'] = $this->fulltext;
 250+ }
229251
230252 $stParams = array_merge(
231253 $didYouMeanParams,
@@ -233,8 +255,9 @@
234256
235257 $suggestionSnippet = $textMatches->getSuggestionSnippet();
236258
237 - if( $suggestionSnippet == '' )
 259+ if( $suggestionSnippet == '' ) {
238260 $suggestionSnippet = null;
 261+ }
239262
240263 $suggestLink = Linker::linkKnown(
241264 $st,
@@ -365,6 +388,9 @@
366389 wfProfileOut( __METHOD__ );
367390 }
368391
 392+ /**
 393+ * @param $t Title
 394+ */
369395 protected function showCreateLink( $t ) {
370396 // show direct page/create link if applicable
371397 // Check DBkey !== '' in case of fragment link only.
@@ -387,7 +413,7 @@
388414 }
389415
390416 /**
391 - *
 417+ * @param $term string
392418 */
393419 protected function setupPage( $term ) {
394420 # Should advanced UI be used?
@@ -441,6 +467,8 @@
442468 * Show whole set of results
443469 *
444470 * @param $matches SearchResultSet
 471+ *
 472+ * @return string
445473 */
446474 protected function showMatches( &$matches ) {
447475 global $wgContLang;
@@ -470,6 +498,8 @@
471499 *
472500 * @param $result SearchResult
473501 * @param $terms Array: terms to highlight
 502+ *
 503+ * @return string
474504 */
475505 protected function showHit( $result, $terms ) {
476506 wfProfileIn( __METHOD__ );
@@ -650,6 +680,8 @@
651681 *
652682 * @param $matches SearchResultSet
653683 * @param $query String
 684+ *
 685+ * @return string
654686 */
655687 protected function showInterwiki( &$matches, $query ) {
656688 global $wgContLang;
@@ -691,6 +723,8 @@
692724 * @param $terms Array
693725 * @param $query String
694726 * @param $customCaptions Array: iw prefix -> caption
 727+ *
 728+ * @return string
695729 */
696730 protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) {
697731 wfProfileIn( __METHOD__ );
@@ -734,10 +768,10 @@
735769 $out = "";
736770 // display project name
737771 if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()) {
738 - if( key_exists($t->getInterwiki(),$customCaptions) )
 772+ if( key_exists($t->getInterwiki(),$customCaptions) ) {
739773 // captions from 'search-interwiki-custom'
740774 $caption = $customCaptions[$t->getInterwiki()];
741 - else{
 775+ } else {
742776 // default is to show the hostname of the other wiki which might suck
743777 // if there are many wikis on one hostname
744778 $parsed = parse_url($t->getFullURL());
@@ -763,6 +797,11 @@
764798 return $out;
765799 }
766800
 801+ /**
 802+ * @param $profile
 803+ * @param $term
 804+ * @return String
 805+ */
767806 protected function getProfileForm( $profile, $term ) {
768807 // Hidden stuff
769808 $opts = array();
@@ -782,6 +821,7 @@
783822 * Generates the power search box at [[Special:Search]]
784823 *
785824 * @param $term String: search term
 825+ * @param $opts array
786826 * @return String: HTML form
787827 */
788828 protected function powerSearchBox( $term, $opts ) {
@@ -872,6 +912,9 @@
873913 Xml::closeElement( 'fieldset' );
874914 }
875915
 916+ /**
 917+ * @return array
 918+ */
876919 protected function getSearchProfiles() {
877920 // Builds list of Search Types (profiles)
878921 $nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
@@ -920,6 +963,12 @@
921964 return $profiles;
922965 }
923966
 967+ /**
 968+ * @param $term
 969+ * @param $resultsShown
 970+ * @param $totalNum
 971+ * @return string
 972+ */
924973 protected function formHeader( $term, $resultsShown, $totalNum ) {
925974 $out = Xml::openElement('div', array( 'class' => 'mw-search-formheader' ) );
926975
@@ -990,6 +1039,10 @@
9911040 return $out;
9921041 }
9931042
 1043+ /**
 1044+ * @param $term string
 1045+ * @return string
 1046+ */
9941047 protected function shortDialog( $term ) {
9951048 $out = Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n";
9961049 // Term box
@@ -1072,6 +1125,8 @@
10731126
10741127 /**
10751128 * @since 1.18
 1129+ *
 1130+ * @return SearchEngine
10761131 */
10771132 public function getSearchEngine() {
10781133 if ( $this->searchEngine === null ) {
@@ -1085,6 +1140,9 @@
10861141 * add more params to links to not lose selection when
10871142 * user navigates search results.
10881143 * @since 1.18
 1144+ *
 1145+ * @param $key
 1146+ * @param $value
10891147 */
10901148 public function setExtraParam( $key, $value ) {
10911149 $this->extraParams[$key] = $value;
Index: trunk/phase3/languages/Language.php
@@ -3513,7 +3513,7 @@
35143514 * Format a size in bytes for output, using an appropriate
35153515 * unit (B, KB, MB or GB) according to the magnitude in question
35163516 *
3517 - * @param $size Size to format
 3517+ * @param $size int Size to format
35183518 * @return string Plain text (not HTML)
35193519 */
35203520 function formatSize( $size ) {

Status & tagging log