From 63dc5abc9aaf5fdaf21f01395e6948b1edffc485 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Mon, 25 Aug 2014 19:16:36 +0200 Subject: [PATCH] Fixed spacing - Added space after reserved words: function, foreach, if - Combined 'else if' into elseif - Added braces to one-line statements - Added spaces after comma, before parentheses Change-Id: Ie5bbf680d6fbe0f0872dab2700c16b1394906a72 --- includes/Revision.php | 4 ++-- includes/Setup.php | 6 +++--- includes/Title.php | 2 +- includes/WatchedItem.php | 2 +- includes/htmlform/HTMLAutoCompleteSelectField.php | 2 +- includes/htmlform/HTMLForm.php | 2 +- includes/objectcache/MemcachedBagOStuff.php | 2 +- includes/search/SearchHighlighter.php | 6 +++--- includes/skins/SkinFactory.php | 2 +- includes/specials/SpecialImport.php | 2 +- tests/parser/parserTest.inc | 2 +- tests/phpunit/MediaWikiTestCase.php | 10 +++++----- .../phpunit/includes/deferred/DeferredUpdatesTest.php | 4 ++-- tests/phpunit/includes/parser/NewParserTest.php | 2 +- tests/phpunit/includes/parser/TidyTest.php | 2 +- .../resourceloader/ResourceLoaderModuleTest.php | 2 +- tests/phpunit/includes/skins/SkinFactoryTest.php | 4 +++- tests/testHelpers.inc | 11 +++++++---- 18 files changed, 36 insertions(+), 31 deletions(-) diff --git a/includes/Revision.php b/includes/Revision.php index cad9f2ce59..28a825d051 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -1658,7 +1658,7 @@ class Revision implements IDBAccessObject { * instead of just plain userrights * @return bool */ - public static function userCanBitfield( $bitfield, $field, User $user = null , + public static function userCanBitfield( $bitfield, $field, User $user = null, Title $title = null ) { if ( $bitfield & $field ) { // aspect is deleted @@ -1680,7 +1680,7 @@ class Revision implements IDBAccessObject { } else { $text = $title->getPrefixedText(); wfDebug( "Checking for $permissionlist on $text due to $field match on $bitfield\n" ); - foreach( $permissions as $perm ) { + foreach ( $permissions as $perm ) { if ( $title->userCan( $perm, $user ) ) { return true; } diff --git a/includes/Setup.php b/includes/Setup.php index acceb59d04..6dbaac6bd9 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -265,16 +265,16 @@ if ( $wgSkipSkin ) { // Register skins // Use a closure to avoid leaking into global state -call_user_func( function() use ( $wgValidSkinNames ) { +call_user_func( function () use ( $wgValidSkinNames ) { $factory = SkinFactory::getDefaultInstance(); foreach ( $wgValidSkinNames as $name => $skin ) { - $factory->register( $name, $skin, function() use ( $name, $skin ) { + $factory->register( $name, $skin, function () use ( $name, $skin ) { $class = "Skin$skin"; return new $class( $name ); } ); } // Register a hidden "fallback" skin - $factory->register( 'fallback', 'Fallback', function() { + $factory->register( 'fallback', 'Fallback', function () { return new SkinFallback; } ); } ); diff --git a/includes/Title.php b/includes/Title.php index bcf9cbd851..7fdeb05511 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2265,7 +2265,7 @@ class Title { } elseif ( $action == 'delete' ) { $tempErrors = $this->checkPageRestrictions( 'edit', $user, array(), $doExpensiveQueries, true ); - if( !$tempErrors ) { + if ( !$tempErrors ) { $tempErrors = $this->checkCascadingSourcesRestrictions( 'edit', $user, $tempErrors, $doExpensiveQueries, true ); } diff --git a/includes/WatchedItem.php b/includes/WatchedItem.php index 488932cb08..ab136b8954 100644 --- a/includes/WatchedItem.php +++ b/includes/WatchedItem.php @@ -309,7 +309,7 @@ class WatchedItem { } $dbw = wfGetDB( DB_MASTER ); - foreach( array_chunk( $rows, 100 ) as $toInsert ) { + foreach ( array_chunk( $rows, 100 ) as $toInsert ) { // Use INSERT IGNORE to avoid overwriting the notification timestamp // if there's already an entry for this page $dbw->insert( 'watchlist', $toInsert, __METHOD__, 'IGNORE' ); diff --git a/includes/htmlform/HTMLAutoCompleteSelectField.php b/includes/htmlform/HTMLAutoCompleteSelectField.php index 4ea5e992fd..49053628de 100644 --- a/includes/htmlform/HTMLAutoCompleteSelectField.php +++ b/includes/htmlform/HTMLAutoCompleteSelectField.php @@ -106,7 +106,7 @@ class HTMLAutoCompleteSelectField extends HTMLTextField { if ( $this->getOptions() ) { $attribs['data-hide-if'] = FormatJson::encode( - array( '!==', $this->mName . '-select', 'other' ) + array( '!==', $this->mName . '-select', 'other' ) ); } diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 50f70379c0..fc2222ad8c 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -937,7 +937,7 @@ class HTMLForm extends ContextSource { } if ( $useMediaWikiUIEverywhere ) { - if ( isset( $attrs['class' ] ) ) { + if ( isset( $attrs['class'] ) ) { $attrs['class'] .= ' mw-ui-button'; } else { $attrs['class'] = 'mw-ui-button'; diff --git a/includes/objectcache/MemcachedBagOStuff.php b/includes/objectcache/MemcachedBagOStuff.php index 54a464de00..53edcddec9 100644 --- a/includes/objectcache/MemcachedBagOStuff.php +++ b/includes/objectcache/MemcachedBagOStuff.php @@ -154,7 +154,7 @@ class MemcachedBagOStuff extends BagOStuff { if ( $expiry > 2592000 && $expiry < 1000000000 ) { $expiry = 2592000; } - return (int) $expiry; + return (int)$expiry; } /** diff --git a/includes/search/SearchHighlighter.php b/includes/search/SearchHighlighter.php index 0bd6ca83d5..109c466f6d 100644 --- a/includes/search/SearchHighlighter.php +++ b/includes/search/SearchHighlighter.php @@ -564,11 +564,11 @@ class SearchHighlighter { * @param int $contextchars average number of characters per line * @return string */ - public function highlightNone( $text, $contextlines, $contextchars) { + public function highlightNone( $text, $contextlines, $contextchars ) { $match = array(); $text = ltrim( $text ) . "\n"; // make sure the preg_match may find the last line - $text = str_replace( "\n\n", "\n", $text); // remove empty lines - preg_match( "/^(.*\n){0,$contextlines}/", $text , $match); + $text = str_replace( "\n\n", "\n", $text ); // remove empty lines + preg_match( "/^(.*\n){0,$contextlines}/", $text, $match ); $text = htmlspecialchars( substr( trim( $match[0] ), 0, $contextlines * $contextchars ) ); // trim and limit to max number of chars return str_replace( "\n", '
', $text ); } diff --git a/includes/skins/SkinFactory.php b/includes/skins/SkinFactory.php index 64480884b7..fb40857740 100644 --- a/includes/skins/SkinFactory.php +++ b/includes/skins/SkinFactory.php @@ -70,7 +70,7 @@ class SkinFactory { * to be, but doing so would change the case of i18n message keys). * @param string $displayName For backwards-compatibility with old skin loading system. This is * the text used as skin's human-readable name when the 'skinname-' message is not - * available. It should be the same as the skin name provided in $wgExtensionCredits. + * available. It should be the same as the skin name provided in $wgExtensionCredits. * @param callable $callback Callback that takes the skin name as an argument * @throws InvalidArgumentException If an invalid callback is provided */ diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index 1b45315fc4..eab4784cef 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -327,7 +327,7 @@ class SpecialImport extends SpecialPage { foreach ( $importSources as $key => $value ) { if ( is_int( $key ) ) { $key = $value; - } else if ( $value !== $key ) { + } elseif ( $value !== $key ) { $needSubprojectField = true; } diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index a342fec56e..25ffb02836 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -625,7 +625,7 @@ class ParserTest { return $this->showSkipped(); } $out = MWTidy::tidy( $out ); - $out = preg_replace( '/\s+$/', '', $out); + $out = preg_replace( '/\s+$/', '', $out ); } if ( isset( $opts['showtitle'] ) ) { diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 873d979163..1166817506 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -1120,13 +1120,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * @param string $message * @param bool $isHtml */ - public static function assertTag($matcher, $actual, $message = '', $isHtml = true) { + public static function assertTag( $matcher, $actual, $message = '', $isHtml = true ) { //trigger_error(__METHOD__ . ' is deprecated', E_USER_DEPRECATED); - $dom = PHPUnit_Util_XML::load($actual, $isHtml); - $tags = PHPUnit_Util_XML::findNodes($dom, $matcher, $isHtml); - $matched = count($tags) > 0 && $tags[0] instanceof DOMNode; + $dom = PHPUnit_Util_XML::load( $actual, $isHtml ); + $tags = PHPUnit_Util_XML::findNodes( $dom, $matcher, $isHtml ); + $matched = count( $tags ) > 0 && $tags[0] instanceof DOMNode; - self::assertTrue($matched, $message); + self::assertTrue( $matched, $message ); } } diff --git a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php index b3d57e796a..5348c85435 100644 --- a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php +++ b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php @@ -3,7 +3,7 @@ class DeferredUpdatesTest extends MediaWikiTestCase { public function testDoUpdates() { - $updates = array ( + $updates = array( '1' => 'deferred update 1', '2' => 'deferred update 2', '3' => 'deferred update 3', @@ -18,7 +18,7 @@ class DeferredUpdatesTest extends MediaWikiTestCase { function () use ( $updates ) { echo $updates['2']; DeferredUpdates::addCallableUpdate( - function() use ( $updates ) { + function () use ( $updates ) { echo $updates['2-1']; } ); diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 4e8c11f193..dda15ec7d4 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -754,7 +754,7 @@ class NewParserTest extends MediaWikiTestCase { $this->markTestSkipped( "SKIPPED: tidy extension is not installed.\n" ); } else { $out = MWTidy::tidy( $out ); - $out = preg_replace( '/\s+$/', '', $out); + $out = preg_replace( '/\s+$/', '', $out ); } } diff --git a/tests/phpunit/includes/parser/TidyTest.php b/tests/phpunit/includes/parser/TidyTest.php index 7b2a1da72a..c869258d0e 100644 --- a/tests/phpunit/includes/parser/TidyTest.php +++ b/tests/phpunit/includes/parser/TidyTest.php @@ -58,7 +58,7 @@ MathML; array( 'foo', 'foo', ' should survive tidy' ), array( "\nfoo", 'foo', ' should survive tidy' ), array( "\nfoo", 'foo', ' should survive tidy' ), - array( $testMathML , $testMathML, ' should survive tidy' ), + array( $testMathML, $testMathML, ' should survive tidy' ), ); } } diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php index 6ca4793390..b0edaaf7b7 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php @@ -10,7 +10,7 @@ class ResourceLoaderModuleTest extends ResourceLoaderTestCase { SkinFactory::getDefaultInstance()->register( 'fakeskin', 'FakeSkin', - function(){ + function () { } ); } diff --git a/tests/phpunit/includes/skins/SkinFactoryTest.php b/tests/phpunit/includes/skins/SkinFactoryTest.php index 36c56a9bb2..d3663c84ad 100644 --- a/tests/phpunit/includes/skins/SkinFactoryTest.php +++ b/tests/phpunit/includes/skins/SkinFactoryTest.php @@ -56,7 +56,9 @@ class SkinFactoryTest extends MediaWikiTestCase { public function testGetSkinNames() { $factory = new SkinFactory(); // A fake callback we can use that will never be called - $callback = function() {}; + $callback = function () { + // NOP + }; $factory->register( 'skin1', 'Skin1', $callback ); $factory->register( 'skin2', 'Skin2', $callback ); $names = $factory->getSkinNames(); diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc index 2f5fa9ea3f..890952eb63 100644 --- a/tests/testHelpers.inc +++ b/tests/testHelpers.inc @@ -423,7 +423,7 @@ class TestFileIterator implements Iterator { $input = $this->checkSection( array( 'wikitext', 'input' ), false ); $result = $this->checkSection( array( 'html/php', 'html/*', 'html', 'result' ), false ); // some tests have "with tidy" and "without tidy" variants - $tidy = $this->checkSection( array( 'html/php+tidy', 'html+tidy'), false ); + $tidy = $this->checkSection( array( 'html/php+tidy', 'html+tidy' ), false ); if ( $tidy != false ) { if ( $this->nextSubTest == 0 ) { if ( $result != false ) { @@ -475,9 +475,11 @@ class TestFileIterator implements Iterator { function readNextTest() { # Run additional subtests of previous test - while ( $this->nextSubTest > 0 ) - if ( $this->setupCurrentTest() ) + while ( $this->nextSubTest > 0 ) { + if ( $this->setupCurrentTest() ) { return true; + } + } $this->clearSection(); # Reset hooks for the delayed test object @@ -554,8 +556,9 @@ class TestFileIterator implements Iterator { if ( $this->section == 'end' ) { $this->checkSection( 'test' ); do { - if ( $this->setupCurrentTest() ) + if ( $this->setupCurrentTest() ) { return true; + } } while ( $this->nextSubTest > 0 ); # go on to next test (since this was disabled) $this->clearSection(); -- 2.20.1