r91155 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91154‎ | r91155 | r91156 >
Date:02:59, 30 June 2011
Author:reedy
Status:ok
Tags:
Comment:
More return documentation and trimming trailing whitespace
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/WebRequest.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialNewpages.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -50,7 +50,7 @@
5151 function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
5252 return Fallback::mb_strpos( $haystack, $needle, $offset, $encoding );
5353 }
54 -
 54+
5555 }
5656
5757 if( !function_exists( 'mb_strrpos' ) ) {
@@ -316,8 +316,8 @@
317317 * "days=7&limit=100". Options in the first array override options in the second.
318318 * Options set to "" will not be output.
319319 *
320 - * @param $array1 Array( String|Array )
321 - * @param $array2 Array( String|Array )
 320+ * @param $array1 Array ( String|Array )
 321+ * @param $array2 Array ( String|Array )
322322 * @param $prefix String
323323 * @return String
324324 */
@@ -511,7 +511,7 @@
512512 /* Provide an empty host for eg. file:/// urls (see bug 28627) */
513513 if ( !isset( $bits['host'] ) ) {
514514 $bits['host'] = '';
515 -
 515+
516516 /* parse_url loses the third / for file:///c:/ urls (but not on variants) */
517517 if ( substr( $bits['path'], 0, 1 ) !== '/' ) {
518518 $bits['path'] = '/' . $bits['path'];
@@ -623,10 +623,10 @@
624624 }
625625 # Check for raw action using $_GET not $wgRequest, since the latter might not be initialised yet
626626 if ( ( isset( $_GET['action'] ) && $_GET['action'] == 'raw' )
627 - || (
628 - isset( $_SERVER['SCRIPT_NAME'] )
629 - && substr( $_SERVER['SCRIPT_NAME'], -8 ) == 'load.php'
630 - ) )
 627+ || (
 628+ isset( $_SERVER['SCRIPT_NAME'] )
 629+ && substr( $_SERVER['SCRIPT_NAME'], -8 ) == 'load.php'
 630+ ) )
631631 {
632632 $cache = true;
633633 } else {
@@ -637,7 +637,7 @@
638638
639639 /**
640640 * Get microsecond timestamps for debug logs
641 - *
 641+ *
642642 * @return string
643643 */
644644 function wfDebugTimer() {
@@ -1277,7 +1277,7 @@
12781278 * Fetch server name for use in error reporting etc.
12791279 * Use real server name if available, so we know which machine
12801280 * in a server farm generated the current page.
1281 - *
 1281+ *
12821282 * @return string
12831283 */
12841284 function wfHostname() {
@@ -2538,7 +2538,7 @@
25392539 function in_string( $needle, $str, $insensitive = false ) {
25402540 $func = 'strpos';
25412541 if( $insensitive ) $func = 'stripos';
2542 -
 2542+
25432543 return $func( $str, $needle ) !== false;
25442544 }
25452545
@@ -2996,11 +2996,11 @@
29972997 global $IP;
29982998 require_once( "$IP/includes/cache/MemcachedSessions.php" );
29992999 }
3000 - session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read',
 3000+ session_set_save_handler( 'memsess_open', 'memsess_close', 'memsess_read',
30013001 'memsess_write', 'memsess_destroy', 'memsess_gc' );
30023002
3003 - // It's necessary to register a shutdown function to call session_write_close(),
3004 - // because by the time the request shutdown function for the session module is
 3003+ // It's necessary to register a shutdown function to call session_write_close(),
 3004+ // because by the time the request shutdown function for the session module is
30053005 // called, $wgMemc has already been destroyed. Shutdown functions registered
30063006 // this way are called before object destruction.
30073007 register_shutdown_function( 'memsess_write_close' );
@@ -3327,7 +3327,7 @@
33283328 * master position. Use this when updating very large numbers of rows, as
33293329 * in maintenance scripts, to avoid causing too much lag. Of course, this is
33303330 * a no-op if there are no slaves.
3331 - *
 3331+ *
33323332 * @param $maxLag Integer (deprecated)
33333333 * @param $wiki mixed Wiki identifier accepted by wfGetLB
33343334 * @return null
@@ -3477,7 +3477,7 @@
34783478 $codeBCP = array();
34793479 foreach ( $codeSegment as $segNo => $seg ) {
34803480 if ( count( $codeSegment ) > 0 ) {
3481 - // when previous segment is x, it is a private segment and should be lc
 3481+ // when previous segment is x, it is a private segment and should be lc
34823482 if( $segNo > 0 && strtolower( $codeSegment[($segNo - 1)] ) == 'x') {
34833483 $codeBCP[$segNo] = strtolower( $seg );
34843484 // ISO 3166 country code
@@ -3551,9 +3551,9 @@
35523552 }
35533553
35543554 /**
3555 - * Unserialize a string to a PHP value without throwing E_NOTICE. Simply a
 3555+ * Unserialize a string to a PHP value without throwing E_NOTICE. Simply a
35563556 * wrapper around unserialize()
3557 - *
 3557+ *
35583558 * @param $data string The serialized string
35593559 * @return mixed
35603560 */
Index: trunk/phase3/includes/WebRequest.php
@@ -127,6 +127,8 @@
128128 /**
129129 * Work out an appropriate URL prefix containing scheme and host, based on
130130 * information detected from $_SERVER
 131+ *
 132+ * @return string
131133 */
132134 public static function detectServer() {
133135 if ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on') {
@@ -196,7 +198,7 @@
197199 * passed on as the value of this URL parameter
198200 * @return array of URL variables to interpolate; empty if no match
199201 */
200 - private static function extractTitle( $path, $bases, $key=false ) {
 202+ private static function extractTitle( $path, $bases, $key = false ) {
201203 foreach( (array)$bases as $keyValue => $base ) {
202204 // Find the part after $wgArticlePath
203205 $base = str_replace( '$1', '', $base );
@@ -464,6 +466,8 @@
465467 * Extracts the given named values into an array.
466468 * If no arguments are given, returns all input values.
467469 * No transformation is performed on the values.
 470+ *
 471+ * @return array
468472 */
469473 public function getValues() {
470474 $names = func_get_args();
@@ -606,6 +610,12 @@
607611 return htmlspecialchars( $this->appendQuery( $query ) );
608612 }
609613
 614+ /**
 615+ * @param $key
 616+ * @param $value
 617+ * @param $onlyquery bool
 618+ * @return String
 619+ */
610620 public function appendQueryValue( $key, $value, $onlyquery = false ) {
611621 return $this->appendQueryArray( array( $key => $value ), $onlyquery );
612622 }
@@ -714,7 +724,7 @@
715725 /**
716726 * Return a WebRequestUpload object corresponding to the key
717727 *
718 - * @param @key string
 728+ * @param $key string
719729 * @return WebRequestUpload
720730 */
721731 public function getUpload( $key ) {
@@ -749,7 +759,6 @@
750760 $this->headers[ strtoupper( $tempName ) ] = $tempValue;
751761 }
752762 } else {
753 - $headers = $_SERVER;
754763 foreach ( $_SERVER as $name => $value ) {
755764 if ( substr( $name, 0, 5 ) === 'HTTP_' ) {
756765 $name = str_replace( '_', '-', substr( $name, 5 ) );
@@ -774,6 +783,8 @@
775784 /**
776785 * Get a request header, or false if it isn't set
777786 * @param $name String: case-insensitive header name
 787+ *
 788+ * @return string|false
778789 */
779790 public function getHeader( $name ) {
780791 $this->initHeaders();
@@ -813,6 +824,9 @@
814825 * PATH_INFO or QUERY_STRING. If the request can't be allowed, show an error
815826 * message or redirect to a safer URL. Returns true if the URL is OK, and
816827 * false if an error message has been shown and the request should be aborted.
 828+ *
 829+ * @param $extWhitelist array
 830+ * @return bool
817831 */
818832 public function checkUrlExtension( $extWhitelist = array() ) {
819833 global $wgScriptExtension;
@@ -837,6 +851,9 @@
838852 /**
839853 * Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in
840854 * IE 6. Returns true if it was successful, false otherwise.
 855+ *
 856+ * @param $url string
 857+ * @return bool
841858 */
842859 protected function doSecurityRedirect( $url ) {
843860 header( 'Location: ' . $url );
Index: trunk/phase3/includes/specials/SpecialNewpages.php
@@ -440,7 +440,7 @@
441441 $revision = Revision::newFromId( $row->rev_id );
442442 if( $revision ) {
443443 return '<p>' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) .
444 - htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
 444+ htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
445445 "</p>\n<hr />\n<div>" .
446446 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
447447 }
@@ -453,14 +453,22 @@
454454 */
455455 class NewPagesPager extends ReverseChronologicalPager {
456456 // Stored opts
457 - protected $opts, $mForm;
 457+ protected $opts;
458458
 459+ /**
 460+ * @var HtmlForm
 461+ */
 462+ protected $mForm;
 463+
459464 function __construct( $form, FormOptions $opts ) {
460465 parent::__construct();
461466 $this->mForm = $form;
462467 $this->opts = $opts;
463468 }
464469
 470+ /**
 471+ * @return Title
 472+ */
465473 function getTitle() {
466474 static $title = null;
467475 if ( $title === null ) {
@@ -469,6 +477,9 @@
470478 return $title;
471479 }
472480
 481+ /**
 482+ * @return User
 483+ */
473484 function getUser() {
474485 static $user = null;
475486 if ( $user === null ) {
@@ -514,7 +525,7 @@
515526 if ( $this->opts->getValue( 'hideredirs' ) ) {
516527 $conds['page_is_redirect'] = 0;
517528 }
518 -
 529+
519530 // Allow changes to the New Pages query
520531 $tables = array( 'recentchanges', 'page' );
521532 $fields = array(

Status & tagging log