From 896f05efded0deb66c0382adb4bcfe2379c5b655 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sun, 24 Jul 2011 21:36:04 +0000 Subject: [PATCH] Trim trailing whitespace Add documentation Remove unused variables Remove an extract from ImageFunctionsTest --- includes/PatrolLog.php | 2 ++ includes/WikiCategoryPage.php | 4 ++++ includes/parser/Parser.php | 18 +++++++++++++----- includes/parser/ParserCache.php | 2 ++ includes/parser/Preprocessor_HipHop.hphp | 6 +++--- includes/specials/SpecialProtectedpages.php | 2 +- includes/upload/UploadFromUrl.php | 5 ++++- .../includes/GlobalFunctions/wfExpandUrl.php | 4 +++- tests/phpunit/includes/ImageFunctionsTest.php | 4 +++- 9 files changed, 35 insertions(+), 12 deletions(-) diff --git a/includes/PatrolLog.php b/includes/PatrolLog.php index 480337a113..9a23b1a91c 100644 --- a/includes/PatrolLog.php +++ b/includes/PatrolLog.php @@ -13,6 +13,8 @@ class PatrolLog { * * @param $rc Mixed: change identifier or RecentChange object * @param $auto Boolean: was this patrol event automatic? + * + * @return bool */ public static function record( $rc, $auto = false ) { if( !( $rc instanceof RecentChange ) ) { diff --git a/includes/WikiCategoryPage.php b/includes/WikiCategoryPage.php index 42c2a6ceb6..1bbc691d6a 100644 --- a/includes/WikiCategoryPage.php +++ b/includes/WikiCategoryPage.php @@ -6,6 +6,8 @@ class WikiCategoryPage extends WikiPage { /** * Constructor from a page id * @param $id Int article ID to load + * + * @return WikiCategoryPage */ public static function newFromID( $id ) { $t = Title::newFromID( $id ); @@ -18,6 +20,8 @@ class WikiCategoryPage extends WikiPage { * Don't return a 404 for categories in use. * In use defined as: either the actual page exists * or the category currently has members. + * + * @return bool */ public function hasViewableContent() { if ( parent::hasViewableContent() ) { diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 447ffa54ea..f19d96d443 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4190,10 +4190,10 @@ class Parser { # split up and insert constructed headlines $blocks = preg_split( '/.*?<\/H[1-6]>/i', $text ); $i = 0; - + // build an array of document sections $sections = array(); - foreach ( $blocks as $block ) { + foreach ( $blocks as $block ) { // $head is zero-based, sections aren't. if ( empty( $head[$i - 1] ) ) { $sections[$i] = $block; @@ -4212,7 +4212,7 @@ class Parser { * $showEditLinks : boolean describing whether this section has an edit link */ wfRunHooks( 'ParserSectionCreate', array( $this, $i, &$sections[$i], $showEditLink ) ); - + $i++; } @@ -4221,9 +4221,9 @@ class Parser { // Top anchor now in skin $sections[0] = $sections[0] . $toc . "\n"; } - + $full .= join( '', $sections ); - + if ( $this->mForceTocPosition ) { return str_replace( '', $toc, $full ); } else { @@ -5128,6 +5128,10 @@ class Parser { * * Transparent tag hooks are like regular XML-style tag hooks, except they * operate late in the transformation sequence, on HTML instead of wikitext. + * + * @param $text string + * + * @return string */ function replaceTransparentTags( $text ) { $matches = array(); @@ -5414,6 +5418,10 @@ class Parser { * Try to guess the section anchor name based on a wikitext fragment * presumably extracted from a heading, for example "Header" from * "== Header ==". + * + * @param $text string + * + * @return string */ public function guessSectionNameFromWikiText( $text ) { # Strip out wikitext links(they break the anchor) diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 2941541b75..9515859c97 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -15,6 +15,8 @@ class ParserCache { /** * Get an instance of this object + * + * @return ParserCache */ public static function singleton() { static $instance; diff --git a/includes/parser/Preprocessor_HipHop.hphp b/includes/parser/Preprocessor_HipHop.hphp index dc404f7c09..9048d31542 100644 --- a/includes/parser/Preprocessor_HipHop.hphp +++ b/includes/parser/Preprocessor_HipHop.hphp @@ -260,8 +260,8 @@ class Preprocessor_HipHop implements Preprocessor { if ( $found === 'angle' ) { $matches = false; // Handle - if ( $enableOnlyinclude - && substr( $text, $i, strlen( '' ) ) === '' ) + if ( $enableOnlyinclude + && substr( $text, $i, strlen( '' ) ) === '' ) { $findOnlyinclude = true; continue; @@ -362,7 +362,7 @@ class Preprocessor_HipHop implements Preprocessor { } $tagStartPos = $i; - $inner = $close = ''; + $close = ''; if ( $text[$tagEndPos-1] === '/' ) { // Short end tag $attrEnd = $tagEndPos - 1; diff --git a/includes/specials/SpecialProtectedpages.php b/includes/specials/SpecialProtectedpages.php index b1f61f09b1..19b9760aca 100644 --- a/includes/specials/SpecialProtectedpages.php +++ b/includes/specials/SpecialProtectedpages.php @@ -83,7 +83,7 @@ class SpecialProtectedpages extends SpecialPage { static $skin = null, $infinity = null; if( is_null( $skin ) ){ - $skin = $wgUser->getSkin(); + $skin = $this->getSkin(); $infinity = wfGetDB( DB_SLAVE )->getInfinity(); } diff --git a/includes/upload/UploadFromUrl.php b/includes/upload/UploadFromUrl.php index e8178cdf73..f9abffe8ff 100644 --- a/includes/upload/UploadFromUrl.php +++ b/includes/upload/UploadFromUrl.php @@ -19,10 +19,13 @@ class UploadFromUrl extends UploadBase { * user is allowed, pass on permissions checking to the parent. * * @param $user User + * + * @return bool */ public static function isAllowed( $user ) { - if ( !$user->isAllowed( 'upload_by_url' ) ) + if ( !$user->isAllowed( 'upload_by_url' ) ) { return 'upload_by_url'; + } return parent::isAllowed( $user ); } diff --git a/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php b/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php index c0875dbbeb..624ee8ce87 100644 --- a/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php +++ b/tests/phpunit/includes/GlobalFunctions/wfExpandUrl.php @@ -1,5 +1,5 @@ 4, 18 => 4 ) ) ); foreach ( $vals as $row ) { - extract( $row ); + $tests = $row['tests']; + $height = $row['height']; + $width = $row['width']; foreach ( $tests as $max => $expected ) { $y = round( $expected * $height / $width ); $result = wfFitBoxWidth( $width, $height, $max ); -- 2.20.1