r86902 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86901‎ | r86902 | r86903 >
Date:21:25, 25 April 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Type hinting

Braces

Remove extra whitespace
Modified paths:
  • /trunk/phase3/includes/BacklinkCache.php (modified) (history)
  • /trunk/phase3/includes/GenderCache.php (modified) (history)
  • /trunk/phase3/includes/HTMLFileCache.php (modified) (history)
  • /trunk/phase3/includes/ProxyTools.php (modified) (history)
  • /trunk/phase3/includes/TitleArray.php (modified) (history)
  • /trunk/phase3/maintenance/importImages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/importImages.inc
@@ -54,7 +54,7 @@
5555 /**
5656 * Split a filename into filename and extension
5757 *
58 - * @param $filename Filename
 58+ * @param $filename string Filename
5959 * @return array
6060 */
6161 function splitFilename( $filename ) {
Index: trunk/phase3/includes/ProxyTools.php
@@ -15,7 +15,7 @@
1616 $apacheHeaders = function_exists( 'apache_request_headers' ) ? apache_request_headers() : null;
1717 if( is_array( $apacheHeaders ) ) {
1818 // More reliable than $_SERVER due to case and -/_ folding
19 - $set = array ();
 19+ $set = array();
2020 foreach ( $apacheHeaders as $tempName => $tempValue ) {
2121 $set[ strtoupper( $tempName ) ] = $tempValue;
2222 }
@@ -46,7 +46,7 @@
4747 function wfGetAgent() {
4848 if( function_exists( 'apache_request_headers' ) ) {
4949 // More reliable than $_SERVER due to case and -/_ folding
50 - $set = array ();
 50+ $set = array();
5151 foreach ( apache_request_headers() as $tempName => $tempValue ) {
5252 $set[ strtoupper( $tempName ) ] = $tempValue;
5353 }
@@ -134,13 +134,8 @@
135135 function wfIsTrustedProxy( $ip ) {
136136 global $wgSquidServers, $wgSquidServersNoPurge;
137137
138 - if ( in_array( $ip, $wgSquidServers ) ||
139 - in_array( $ip, $wgSquidServersNoPurge )
140 - ) {
141 - $trusted = true;
142 - } else {
143 - $trusted = false;
144 - }
 138+ $trusted = in_array( $ip, $wgSquidServers ) ||
 139+ in_array( $ip, $wgSquidServersNoPurge );
145140 wfRunHooks( 'IsTrustedProxy', array( &$ip, &$trusted ) );
146141 return $trusted;
147142 }
Index: trunk/phase3/includes/TitleArray.php
@@ -14,7 +14,7 @@
1515 * @param $res result A MySQL result including at least page_namespace and
1616 * page_title -- also can have page_id, page_len, page_is_redirect,
1717 * page_latest (if those will be used). See Title::newFromRow.
18 - * @return TitleArray
 18+ * @return TitleArrayFromResult
1919 */
2020 static function newFromResult( $res ) {
2121 $array = null;
@@ -27,6 +27,10 @@
2828 return $array;
2929 }
3030
 31+ /**
 32+ * @param $res
 33+ * @return TitleArrayFromResult
 34+ */
3135 protected static function newFromResult_internal( $res ) {
3236 $array = new TitleArrayFromResult( $res );
3337 return $array;
Index: trunk/phase3/includes/BacklinkCache.php
@@ -114,7 +114,7 @@
115115 * @param $table String
116116 * @param $startId Integer or false
117117 * @param $endId Integer or false
118 - * @return TitleArray
 118+ * @return TitleArrayFromResult
119119 */
120120 public function getLinks( $table, $startId = false, $endId = false ) {
121121 wfProfileIn( __METHOD__ );
@@ -272,7 +272,6 @@
273273 $this->partitionCache[$table][$batchSize] = false;
274274 $cacheEntry =& $this->partitionCache[$table][$batchSize];
275275
276 -
277276 // 2) try full result cache
278277
279278 if ( isset( $this->fullResultCache[$table] ) ) {
@@ -282,7 +281,6 @@
283282 return $cacheEntry['batches'];
284283 }
285284
286 -
287285 // 3) ... fallback to memcached ...
288286
289287 global $wgMemc;
@@ -317,7 +315,7 @@
318316
319317 /**
320318 * Partition a DB result with backlinks in it into batches
321 - * @param $res database result
 319+ * @param $res ResultWrapper database result
322320 * @param $batchSize integer
323321 * @return array @see
324322 */
Index: trunk/phase3/includes/HTMLFileCache.php
@@ -69,7 +69,9 @@
7070 }
7171
7272 public function isFileCached() {
73 - if( $this->mType === false ) return false;
 73+ if( $this->mType === false ) {
 74+ return false;
 75+ }
7476 return file_exists( $this->fileCacheName() );
7577 }
7678
@@ -83,20 +85,28 @@
8486 */
8587 public static function useFileCache() {
8688 global $wgUser, $wgUseFileCache, $wgShowIPinHeader, $wgRequest, $wgLang, $wgContLang;
87 - if( !$wgUseFileCache ) return false;
 89+ if( !$wgUseFileCache ) {
 90+ return false;
 91+ }
8892 // Get all query values
8993 $queryVals = $wgRequest->getValues();
9094 foreach( $queryVals as $query => $val ) {
91 - if( $query == 'title' || $query == 'curid' ) continue;
 95+ if( $query == 'title' || $query == 'curid' ) {
 96+ continue;
 97+ }
9298 // Normal page view in query form can have action=view.
9399 // Raw hits for pages also stored, like .css pages for example.
94 - else if( $query == 'action' && ($val == 'view' || $val == 'raw') ) continue;
95 - else if( $query == 'usemsgcache' && $val == 'yes' ) continue;
 100+ else if( $query == 'action' && ($val == 'view' || $val == 'raw') ) {
 101+ continue;
 102+ } else if( $query == 'usemsgcache' && $val == 'yes' ) {
 103+ continue;
 104+ }
96105 // Below are header setting params
97 - else if( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' )
 106+ else if( $query == 'maxage' || $query == 'smaxage' || $query == 'ctype' || $query == 'gen' ) {
98107 continue;
99 - else
 108+ } else {
100109 return false;
 110+ }
101111 }
102112 // Check for non-standard user language; this covers uselang,
103113 // and extensions for auto-detecting user language.
@@ -113,7 +123,9 @@
114124 public function isFileCacheGood( $timestamp = '' ) {
115125 global $wgCacheEpoch;
116126
117 - if( !$this->isFileCached() ) return false;
 127+ if( !$this->isFileCached() ) {
 128+ return false;
 129+ }
118130
119131 $cachetime = $this->fileCacheTime();
120132 $good = $timestamp <= $cachetime && $wgCacheEpoch <= $cachetime;
Index: trunk/phase3/includes/GenderCache.php
@@ -91,7 +91,9 @@
9292 * @param $caller String: the calling method
9393 */
9494 public function doQuery( $users, $caller = '' ) {
95 - if ( count( $users ) === 0 ) return false;
 95+ if ( count( $users ) === 0 ) {
 96+ return false;
 97+ }
9698
9799 foreach ( (array) $users as $index => $value ) {
98100 $users[$index] = strtr( $value, '_', ' ' );

Comments

#Comment by Happy-melon (talk | contribs)   21:57, 26 April 2011

elseif is preferred to else if; has an infintesimal performance improvement. But that's not introduced by this commit, just not fixed by it.

Status & tagging log