From 54c56da85a33ce18582b7b6023f9e93181334a34 Mon Sep 17 00:00:00 2001 From: Paladox Date: Thu, 4 May 2017 19:35:41 +0000 Subject: [PATCH] Fix php code style Preparation change for updating mediawiki code sniffer to 0.8.0 Change-Id: Ib0b3fe4afea9096ffa3a1347b4f7e07d3398b0b2 --- includes/EditPage.php | 1 - includes/GlobalFunctions.php | 1 - includes/content/FileContentHandler.php | 2 +- .../jobqueue/jobs/RecentChangesUpdateJob.php | 1 - includes/libs/IEUrlExtension.php | 12 ++--- includes/libs/mime/IEContentAnalyzer.php | 44 +++++++++---------- includes/libs/mime/MimeAnalyzer.php | 5 +-- .../rdbms/loadmonitor/LoadMonitorNull.php | 3 -- includes/libs/stats/SamplingStatsdClient.php | 2 +- includes/libs/xmp/XMP.php | 3 -- includes/parser/ParserDiffTest.php | 3 +- includes/search/SearchEngine.php | 4 +- includes/services/ServiceContainer.php | 2 +- .../specialpage/ChangesListSpecialPage.php | 1 - includes/specials/SpecialRecentchanges.php | 2 +- includes/user/User.php | 1 - includes/utils/AutoloadGenerator.php | 1 - includes/utils/BatchRowIterator.php | 4 +- .../search/SimpleSearchResultSetWidget.php | 2 +- maintenance/updateCredits.php | 2 +- .../changes/ChangesListFilterTest.php | 1 - .../includes/db/DatabaseMysqlBaseTest.php | 1 - .../includes/deferred/DeferredUpdatesTest.php | 3 +- .../includes/libs/DnsSrvDiscovererTest.php | 1 - .../ResourceLoaderWikiModuleTest.php | 1 - .../includes/search/SearchIndexFieldTest.php | 1 - .../specials/SpecialWatchlistTest.php | 1 - 27 files changed, 42 insertions(+), 63 deletions(-) diff --git a/includes/EditPage.php b/includes/EditPage.php index 6424ca6705..0d3c74ff4d 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -3170,7 +3170,6 @@ class EditPage { ); $wgOut->addHTML( "{$label} {$input}" ); } - } /** diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c7f132a09b..d21cc1d749 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1436,7 +1436,6 @@ function wfMsgReplaceArgs( $message, $args ) { function wfHostname() { static $host; if ( is_null( $host ) ) { - # Hostname overriding global $wgOverrideHostname; if ( $wgOverrideHostname !== false ) { diff --git a/includes/content/FileContentHandler.php b/includes/content/FileContentHandler.php index 843d54056a..3028dfdac8 100644 --- a/includes/content/FileContentHandler.php +++ b/includes/content/FileContentHandler.php @@ -6,7 +6,7 @@ * but instead manually called by WikitextHandler. * This should be fixed in the future. */ -class FileContentHandler extends WikitextContentHandler { +class FileContentHandler extends WikitextContentHandler { public function getFieldsForSearchIndex( SearchEngine $engine ) { $fields['file_media_type'] = diff --git a/includes/jobqueue/jobs/RecentChangesUpdateJob.php b/includes/jobqueue/jobs/RecentChangesUpdateJob.php index c1236198be..eb367aff23 100644 --- a/includes/jobqueue/jobs/RecentChangesUpdateJob.php +++ b/includes/jobqueue/jobs/RecentChangesUpdateJob.php @@ -231,7 +231,6 @@ class RecentChangesUpdateJob extends Job { ], __METHOD__ ); - }, __METHOD__ ); diff --git a/includes/libs/IEUrlExtension.php b/includes/libs/IEUrlExtension.php index 4a6e3fb168..e55bebc93a 100644 --- a/includes/libs/IEUrlExtension.php +++ b/includes/libs/IEUrlExtension.php @@ -63,8 +63,8 @@ class IEUrlExtension { // Check QUERY_STRING or REQUEST_URI if ( isset( $vars['SERVER_SOFTWARE'] ) && isset( $vars['REQUEST_URI'] ) - && self::haveUndecodedRequestUri( $vars['SERVER_SOFTWARE'] ) ) - { + && self::haveUndecodedRequestUri( $vars['SERVER_SOFTWARE'] ) + ) { $urlPart = $vars['REQUEST_URI']; } elseif ( isset( $vars['QUERY_STRING'] ) ) { $urlPart = $vars['QUERY_STRING']; @@ -79,8 +79,8 @@ class IEUrlExtension { // Some servers have PATH_INFO but not REQUEST_URI, so we check both // to be on the safe side. if ( isset( $vars['PATH_INFO'] ) - && self::isUrlExtensionBad( $vars['PATH_INFO'], $extWhitelist ) ) - { + && self::isUrlExtensionBad( $vars['PATH_INFO'], $extWhitelist ) + ) { return true; } @@ -223,8 +223,8 @@ class IEUrlExtension { // If the extension is NOT exe, dll or cgi, return it $extension = substr( $url, $pos, $nextPos - $pos ); if ( strcasecmp( $extension, 'exe' ) && strcasecmp( $extension, 'dll' ) && - strcasecmp( $extension, 'cgi' ) ) - { + strcasecmp( $extension, 'cgi' ) + ) { return $extension; } // Else continue looking diff --git a/includes/libs/mime/IEContentAnalyzer.php b/includes/libs/mime/IEContentAnalyzer.php index 0d1e527ba6..badcb2bced 100644 --- a/includes/libs/mime/IEContentAnalyzer.php +++ b/includes/libs/mime/IEContentAnalyzer.php @@ -399,8 +399,8 @@ class IEContentAnalyzer { $proposedFormat = $this->getDataFormat( $version, $proposed ); if ( $proposedFormat == 'unknown' && $proposed != 'multipart/mixed' - && $proposed != 'multipart/x-mixed-replace' ) - { + && $proposed != 'multipart/x-mixed-replace' + ) { return $proposed; } if ( strval( $chunk ) === '' ) { @@ -426,15 +426,15 @@ class IEContentAnalyzer { return 'image/gif'; } if ( ( $proposed == 'image/pjpeg' || $proposed == 'image/jpeg' ) - && $binaryType == 'image/pjpeg' ) - { + && $binaryType == 'image/pjpeg' + ) { return $proposed; } // PNG check added in IE 7 if ( $version >= 'ie07' && ( $proposed == 'image/x-png' || $proposed == 'image/png' ) - && $binaryType == 'image/x-png' ) - { + && $binaryType == 'image/x-png' + ) { return $proposed; } @@ -450,8 +450,8 @@ class IEContentAnalyzer { } if ( isset( $sampleFound['rdf-tag'] ) && isset( $sampleFound['rdf-url'] ) - && isset( $sampleFound['rdf-purl'] ) ) - { + && isset( $sampleFound['rdf-purl'] ) + ) { return 'application/rss+xml'; } if ( isset( $sampleFound['atom'] ) ) { @@ -497,8 +497,8 @@ class IEContentAnalyzer { // Freaky heuristics to determine if the data is text or binary // The heuristic is of course broken for non-ASCII text if ( $counters['ctrl'] != 0 && ( $counters['ff'] + $counters['low'] ) - < ( $counters['ctrl'] + $counters['high'] ) * 16 ) - { + < ( $counters['ctrl'] + $counters['high'] ) * 16 + ) { $kindOfBinary = true; $type = $binaryType ? $binaryType : $textType; if ( $type === false ) { @@ -599,13 +599,13 @@ class IEContentAnalyzer { if ( $chunk2 == 'BM' && substr( $chunk, 6, 2 ) == "\000\000" - && substr( $chunk, 8, 2 ) == "\000\000" ) - { + && substr( $chunk, 8, 2 ) == "\000\000" + ) { return 'image/bmp'; // another non-standard MIME } if ( $chunk4 == 'RIFF' - && substr( $chunk, 8, 4 ) == 'WAVE' ) - { + && substr( $chunk, 8, 4 ) == 'WAVE' + ) { return 'audio/wav'; } // These were integer literals in IE @@ -613,8 +613,8 @@ class IEContentAnalyzer { if ( $chunk4 == ".sd\000" || $chunk4 == ".snd" || $chunk4 == "\000ds." - || $chunk4 == "dns." ) - { + || $chunk4 == "dns." + ) { return 'audio/basic'; } if ( $chunk3 == "MM\000" ) { @@ -648,8 +648,8 @@ class IEContentAnalyzer { return 'video/mpeg'; } if ( $chunk4 == "\001\000\000\000" - && substr( $chunk, 40, 4 ) == ' EMF' ) - { + && substr( $chunk, 40, 4 ) == ' EMF' + ) { return 'image/x-emf'; } if ( $chunk4 == "\xd7\xcd\xc6\x9a" ) { @@ -789,8 +789,8 @@ class IEContentAnalyzer { if ( !strncasecmp( $remainder, $rdfUrl, strlen( $rdfUrl ) ) ) { $found['rdf-url'] = true; if ( isset( $found['rdf-tag'] ) - && isset( $found['rdf-purl'] ) ) // [sic] - { + && isset( $found['rdf-purl'] ) // [sic] + ) { break; } continue; @@ -798,8 +798,8 @@ class IEContentAnalyzer { if ( !strncasecmp( $remainder, $rdfPurl, strlen( $rdfPurl ) ) ) { if ( isset( $found['rdf-tag'] ) - && isset( $found['rdf-url'] ) ) // [sic] - { + && isset( $found['rdf-url'] ) // [sic] + ) { break; } continue; diff --git a/includes/libs/mime/MimeAnalyzer.php b/includes/libs/mime/MimeAnalyzer.php index 6ea3c215bc..d03bc485fa 100644 --- a/includes/libs/mime/MimeAnalyzer.php +++ b/includes/libs/mime/MimeAnalyzer.php @@ -735,8 +735,8 @@ EOT; ( strpos( $head, "<\x00?\x00 " ) !== false ) || ( strpos( $head, "<\x00?\x00\n" ) !== false ) || ( strpos( $head, "<\x00?\x00\t" ) !== false ) || - ( strpos( $head, "<\x00?\x00=" ) !== false ) ) { - + ( strpos( $head, "<\x00?\x00=" ) !== false ) + ) { $this->logger->info( __METHOD__ . ": recognized $file as application/x-php\n" ); return 'application/x-php'; } @@ -1035,7 +1035,6 @@ EOT; // Special code for ogg - detect if it's video (theora), // else label it as sound. if ( $mime == 'application/ogg' && file_exists( $path ) ) { - // Read a chunk of the file $f = fopen( $path, "rt" ); if ( !$f ) { diff --git a/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php b/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php index 613dac5278..8bbf9e5de3 100644 --- a/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php +++ b/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php @@ -28,14 +28,12 @@ class LoadMonitorNull implements ILoadMonitor { public function __construct( ILoadBalancer $lb, BagOStuff $sCache, BagOStuff $cCache, array $options = [] ) { - } public function setLogger( LoggerInterface $logger ) { } public function scaleLoads( array &$loads, $domain ) { - } public function getLagTimes( array $serverIndexes, $domain ) { @@ -43,6 +41,5 @@ class LoadMonitorNull implements ILoadMonitor { } public function clearCaches() { - } } diff --git a/includes/libs/stats/SamplingStatsdClient.php b/includes/libs/stats/SamplingStatsdClient.php index dd1976c06e..a8af7142c4 100644 --- a/includes/libs/stats/SamplingStatsdClient.php +++ b/includes/libs/stats/SamplingStatsdClient.php @@ -69,7 +69,7 @@ class SamplingStatsdClient extends StatsdClient { return $data; } - /* + /** * Send the metrics over UDP * Sample the metrics according to their sample rate and send the remaining ones. * diff --git a/includes/libs/xmp/XMP.php b/includes/libs/xmp/XMP.php index f1df7f19dd..9d886bf9a0 100644 --- a/includes/libs/xmp/XMP.php +++ b/includes/libs/xmp/XMP.php @@ -272,7 +272,6 @@ class XMPReader implements LoggerAwareInterface { if ( isset( $data['xmp-exif']['GPSAltitudeRef'] ) && isset( $data['xmp-exif']['GPSAltitude'] ) ) { - // Must convert to a real before multiplying by -1 // XMPValidate guarantees there will always be a '/' in this value. list( $nom, $denom ) = explode( '/', $data['xmp-exif']['GPSAltitude'] ); @@ -1004,7 +1003,6 @@ class XMPReader implements LoggerAwareInterface { */ private function startElementModeInitial( $ns, $tag, $attribs ) { if ( $ns !== self::NS_RDF ) { - if ( isset( $this->items[$ns][$tag] ) ) { if ( isset( $this->items[$ns][$tag]['structPart'] ) ) { // If this element is supposed to appear only as @@ -1066,7 +1064,6 @@ class XMPReader implements LoggerAwareInterface { */ private function startElementModeStruct( $ns, $tag, $attribs ) { if ( $ns !== self::NS_RDF ) { - if ( isset( $this->items[$ns][$tag] ) ) { if ( isset( $this->items[$ns][$this->ancestorStruct]['children'] ) && !isset( $this->items[$ns][$this->ancestorStruct]['children'][$tag] ) diff --git a/includes/parser/ParserDiffTest.php b/includes/parser/ParserDiffTest.php index d0b66f8061..353825a8fb 100644 --- a/includes/parser/ParserDiffTest.php +++ b/includes/parser/ParserDiffTest.php @@ -24,8 +24,7 @@ /** * @ingroup Parser */ -class ParserDiffTest -{ +class ParserDiffTest { public $parsers; public $conf; public $shortOutput = false; diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index 6bb4e5aeba..4473bb2927 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -455,8 +455,8 @@ abstract class SearchEngine { $title = Title::newFromText( $search . 'Dummy' ); if ( $title && $title->getText() == 'Dummy' && $title->getNamespace() != NS_MAIN - && !$title->isExternal() ) - { + && !$title->isExternal() + ) { $ns = [ $title->getNamespace() ]; $search = ''; } else { diff --git a/includes/services/ServiceContainer.php b/includes/services/ServiceContainer.php index bad0ef9ce6..633cfc92db 100644 --- a/includes/services/ServiceContainer.php +++ b/includes/services/ServiceContainer.php @@ -303,7 +303,7 @@ class ServiceContainer implements DestructibleService { $instance = $this->peekService( $name ); - if ( $destroy && $instance instanceof DestructibleService ) { + if ( $destroy && $instance instanceof DestructibleService ) { $instance->destroy(); } diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 268f0b099d..7e70df2028 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -1022,7 +1022,6 @@ abstract class ChangesListSpecialPage extends SpecialPage { } return false; - } /** diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index f9164a189f..c10dbddf39 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -167,7 +167,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { $jsData = $this->getStructuredFilterJsData(); $messages = []; - foreach ( $jsData['messageKeys'] as $key ){ + foreach ( $jsData['messageKeys'] as $key ) { $messages[$key] = $this->msg( $key )->plain(); } diff --git a/includes/user/User.php b/includes/user/User.php index bb1e751dde..5dd4be1b4d 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -522,7 +522,6 @@ class User implements IDBAccessObject { } return $data; - }, [ 'pcTTL' => $cache::TTL_PROC_LONG, 'version' => self::VERSION ] ); diff --git a/includes/utils/AutoloadGenerator.php b/includes/utils/AutoloadGenerator.php index 1dac0b152a..54a86775f8 100644 --- a/includes/utils/AutoloadGenerator.php +++ b/includes/utils/AutoloadGenerator.php @@ -212,7 +212,6 @@ global \${$this->variableName}; ]; EOD; - } /** diff --git a/includes/utils/BatchRowIterator.php b/includes/utils/BatchRowIterator.php index e107fb15ba..cab6a3d6f8 100644 --- a/includes/utils/BatchRowIterator.php +++ b/includes/utils/BatchRowIterator.php @@ -87,9 +87,9 @@ class BatchRowIterator implements RecursiveIterator { /** * @param IDatabase $db The database to read from - * @param string|array $table The name or names of the table to read from + * @param string|array $table The name or names of the table to read from * @param string|array $primaryKey The name or names of the primary key columns - * @param integer $batchSize The number of rows to fetch per iteration + * @param integer $batchSize The number of rows to fetch per iteration * @throws InvalidArgumentException */ public function __construct( IDatabase $db, $table, $primaryKey, $batchSize ) { diff --git a/includes/widget/search/SimpleSearchResultSetWidget.php b/includes/widget/search/SimpleSearchResultSetWidget.php index 04e1e2100f..4df2eb5471 100644 --- a/includes/widget/search/SimpleSearchResultSetWidget.php +++ b/includes/widget/search/SimpleSearchResultSetWidget.php @@ -14,7 +14,7 @@ use Html; * interwiki prefix. Includes a per-wiki header indicating where * the results are from. */ -class SimpleSearchResultSetWidget implements SearchResultSetWidget{ +class SimpleSearchResultSetWidget implements SearchResultSetWidget { /** @var SpecialSearch */ protected $specialSearch; /** @var SearchResultWidget */ diff --git a/maintenance/updateCredits.php b/maintenance/updateCredits.php index eb717e8c66..287a40c558 100644 --- a/maintenance/updateCredits.php +++ b/maintenance/updateCredits.php @@ -59,7 +59,7 @@ unset( $lines ); $lines = explode( "\n", shell_exec( 'git log --format="%aN"' ) ); foreach ( $lines as $line ) { - if ( empty( $line ) ) { + if ( empty( $line ) ) { continue; } if ( substr( $line, 0, 5 ) === '[BOT]' ) { diff --git a/tests/phpunit/includes/changes/ChangesListFilterTest.php b/tests/phpunit/includes/changes/ChangesListFilterTest.php index 5546de8739..0015453de9 100644 --- a/tests/phpunit/includes/changes/ChangesListFilterTest.php +++ b/tests/phpunit/includes/changes/ChangesListFilterTest.php @@ -23,7 +23,6 @@ class ChangesListFilterTest extends MediaWikiTestCase { 'filters' => [], ] ); - } // @codingStandardsIgnoreStart diff --git a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php index 97e9b2626f..f61569af8a 100644 --- a/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php +++ b/tests/phpunit/includes/db/DatabaseMysqlBaseTest.php @@ -91,7 +91,6 @@ class FakeDatabaseMysqlBase extends DatabaseMysqlBase { } protected function mysqlRealEscapeString( $s ) { - } function insertId() { diff --git a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php index d7ad1d1ed6..2c199bc12a 100644 --- a/tests/phpunit/includes/deferred/DeferredUpdatesTest.php +++ b/tests/phpunit/includes/deferred/DeferredUpdatesTest.php @@ -13,8 +13,7 @@ class DeferredUpdatesTest extends MediaWikiTestCase { $post = DeferredUpdates::POSTSEND; $all = DeferredUpdates::ALL; - $update = $this->getMockBuilder( 'DeferrableUpdate' ) - ->getMock(); + $update = $this->getMock( DeferrableUpdate::class ); $update->expects( $this->never() ) ->method( 'doUpdate' ); diff --git a/tests/phpunit/includes/libs/DnsSrvDiscovererTest.php b/tests/phpunit/includes/libs/DnsSrvDiscovererTest.php index 9d12b10c24..cfc2d91b0d 100644 --- a/tests/phpunit/includes/libs/DnsSrvDiscovererTest.php +++ b/tests/phpunit/includes/libs/DnsSrvDiscovererTest.php @@ -10,7 +10,6 @@ class DnsSrvDiscovererTest extends PHPUnit_Framework_TestCase { $record = $discoverer->pickServer( $params ); $this->assertEquals( $expected, $record ); - } public static function provideRecords() { diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php index 4cf4071172..78eec6a6f7 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderWikiModuleTest.php @@ -323,7 +323,6 @@ class ResourceLoaderWikiModuleTest extends ResourceLoaderTestCase { $expected, $module->getContent( $titleText ) ); - } /** diff --git a/tests/phpunit/includes/search/SearchIndexFieldTest.php b/tests/phpunit/includes/search/SearchIndexFieldTest.php index 6b12229657..bb7508c1c8 100644 --- a/tests/phpunit/includes/search/SearchIndexFieldTest.php +++ b/tests/phpunit/includes/search/SearchIndexFieldTest.php @@ -51,7 +51,6 @@ class SearchIndexFieldTest extends MediaWikiTestCase { } ); $this->assertEquals( "test", $field1->merge( $field2 ) ); - } } diff --git a/tests/phpunit/includes/specials/SpecialWatchlistTest.php b/tests/phpunit/includes/specials/SpecialWatchlistTest.php index 7f9f25f16e..b0490ec663 100644 --- a/tests/phpunit/includes/specials/SpecialWatchlistTest.php +++ b/tests/phpunit/includes/specials/SpecialWatchlistTest.php @@ -43,7 +43,6 @@ class SpecialWatchlistTest extends SpecialPageTestBase { 'watchlistreloadautomatically' => 0, ] ); - } /** -- 2.20.1