Merge "Linker.php: Make long lines shorter to pass phpcs"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 26 Sep 2015 17:21:52 +0000 (17:21 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 26 Sep 2015 17:21:52 +0000 (17:21 +0000)
13 files changed:
includes/api/ApiBase.php
includes/debug/logger/monolog/BufferHandler.php
includes/debug/logger/monolog/KafkaHandler.php
includes/utils/AvroValidator.php
maintenance/populateContentModel.php
phpcs.xml
tests/phpunit/includes/WikiMapTest.php
tests/phpunit/includes/content/CssContentTest.php
tests/phpunit/includes/content/JavaScriptContentTest.php
tests/phpunit/includes/debug/logger/monolog/KafkaHandlerTest.php
tests/phpunit/includes/filerepo/FileBackendDBRepoWrapperTest.php
tests/phpunit/includes/filerepo/MigrateFileRepoLayoutTest.php
tests/phpunit/includes/media/WebPTest.php

index d53797b..7743384 100644 (file)
@@ -206,7 +206,8 @@ abstract class ApiBase extends ContextSource {
                                // Fix up the ugly "even numbered elements are description, odd
                                // numbered elemts are the link" format (see doc for self::getExamples)
                                $tmp = array();
-                               for ( $i = 0; $i < count( $examples ); $i += 2 ) {
+                               $examplesCount = count( $examples );
+                               for ( $i = 0; $i < $examplesCount; $i += 2 ) {
                                        $tmp[$examples[$i + 1]] = $examples[$i];
                                }
                                $examples = $tmp;
index 3ebd0b1..ea286b3 100644 (file)
@@ -37,7 +37,7 @@ class BufferHandler extends BaseBufferHandler {
         * {@inheritDoc}
         */
        public function handle( array $record ) {
-               if (!$this->initialized) {
+               if ( !$this->initialized ) {
                        DeferredUpdates::addCallableUpdate( array( $this, 'close' ) );
                        $this->initialized = true;
                }
index 59d7764..1583cd1 100644 (file)
@@ -133,7 +133,7 @@ class KafkaHandler extends AbstractProcessingHandler {
                                }
                        }
                        if ( $messages ) {
-                               $this->addMessages($channel, $messages);
+                               $this->addMessages( $channel, $messages );
                        }
                }
 
index 89341ea..b9d30d7 100644 (file)
@@ -36,25 +36,25 @@ class AvroValidator {
         *  returned.
         */
        public static function getErrors( AvroSchema $schema, $datum ) {
-               switch ( $schema->type) {
+               switch ( $schema->type ) {
                case AvroSchema::NULL_TYPE:
-                       if ( !is_null($datum) ) {
+                       if ( !is_null( $datum ) ) {
                                return self::wrongType( 'null', $datum );
                        }
                        return array();
                case AvroSchema::BOOLEAN_TYPE:
-                       if ( !is_bool($datum) ) {
+                       if ( !is_bool( $datum ) ) {
                                return self::wrongType( 'boolean', $datum );
                        }
                        return array();
                case AvroSchema::STRING_TYPE:
                case AvroSchema::BYTES_TYPE:
-                       if ( !is_string($datum) ) {
+                       if ( !is_string( $datum ) ) {
                                return self::wrongType( 'string', $datum );
                        }
                        return array();
                case AvroSchema::INT_TYPE:
-                       if ( !is_int($datum) ) {
+                       if ( !is_int( $datum ) ) {
                                return self::wrongType( 'integer', $datum );
                        }
                        if ( AvroSchema::INT_MIN_VALUE > $datum
@@ -68,7 +68,7 @@ class AvroValidator {
                        }
                        return array();
                case AvroSchema::LONG_TYPE:
-                       if ( !is_int($datum) ) {
+                       if ( !is_int( $datum ) ) {
                                return self::wrongType( 'integer', $datum );
                        }
                        if ( AvroSchema::LONG_MIN_VALUE > $datum
@@ -83,16 +83,16 @@ class AvroValidator {
                        return array();
                case AvroSchema::FLOAT_TYPE:
                case AvroSchema::DOUBLE_TYPE:
-                       if ( !is_float($datum) && !is_int($datum) ) {
+                       if ( !is_float( $datum ) && !is_int( $datum ) ) {
                                return self::wrongType( 'float or integer', $datum );
                        }
                        return array();
                case AvroSchema::ARRAY_SCHEMA:
-                       if (!is_array($datum)) {
+                       if ( !is_array( $datum ) ) {
                                return self::wrongType( 'array', $datum );
                        }
                        $errors = array();
-                       foreach ($datum as $d) {
+                       foreach ( $datum as $d ) {
                                $result = self::getErrors( $schema->items(), $d );
                                if ( $result ) {
                                        $errors[] = $result;
@@ -100,12 +100,12 @@ class AvroValidator {
                        }
                        return $errors;
                case AvroSchema::MAP_SCHEMA:
-                       if (!is_array($datum)) {
+                       if ( !is_array( $datum ) ) {
                                return self::wrongType( 'array', $datum );
                        }
                        $errors = array();
-                       foreach ($datum as $k => $v) {
-                               if ( !is_string($k) ) {
+                       foreach ( $datum as $k => $v ) {
+                               if ( !is_string( $k ) ) {
                                        $errors[] = self::wrongType( 'string key', $k );
                                }
                                $result = self::getErrors( $schema->values(), $v );
@@ -116,7 +116,7 @@ class AvroValidator {
                        return $errors;
                case AvroSchema::UNION_SCHEMA:
                        $errors = array();
-                       foreach ($schema->schemas() as $schema) {
+                       foreach ( $schema->schemas() as $schema ) {
                                $result = self::getErrors( $schema, $datum );
                                if ( !$result ) {
                                        return array();
index 3f5d6b6..7bca0ec 100644 (file)
@@ -178,7 +178,7 @@ class PopulateContentModel extends Maintenance {
                                        if ( $dbFormat === $defaultFormat ) {
                                                $toSave[$defaultModel][] = $row->{$key};
                                        } else { // non-default format, just update now
-                                               $this->output( "Updating model to match format for $table $id of $title... ");
+                                               $this->output( "Updating model to match format for $table $id of $title... " );
                                                $dbw->update(
                                                        $table,
                                                        array( $model_column => $defaultModel ),
index 03b2af2..8a28177 100644 (file)
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -5,14 +5,9 @@
                <exclude name="Generic.Files.LineLength"/>
                <exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
                <exclude name="MediaWiki.NamingConventions.PrefixedGlobalFunctions.wfPrefix"/>
-               <exclude name="MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceBeforeCloseParenthesis"/>
-               <exclude name="MediaWiki.WhiteSpace.SpaceyParenthesis.SingleSpaceAfterOpenParenthesis"/>
                <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
-               <exclude name="Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed"/>
                <exclude name="MediaWiki.WhiteSpace.SpaceAfterControlStructure.Incorrect"/>
                <exclude name="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
-               <exclude name="Squiz.WhiteSpace.ScopeClosingBrace.Indent"/>
-               <exclude name="Squiz.WhiteSpace.SemicolonSpacing.Incorrect"/>
        </rule>
        <file>.</file>
        <arg name="encoding" value="utf8"/>
index 9233416..f7ae08e 100644 (file)
@@ -62,7 +62,7 @@ class WikiMapTest extends MediaWikiLangTestCase {
        public function provideMakeForeignLink() {
                return array(
                        'unknown' => array( false, 'xyzzy', 'Foo' ),
-                       'enwiki' => array( '<a class="external" rel="nofollow" href="http://en.example.org/w/Foo">Foo</a>', 'enwiki', 'Foo' ),
+                       'enwiki' => array( '<a class="external" rel="nofollow" href="http://en.example.org/w/Foo">Foo</a>', 'enwiki', 'Foo' ),
                        'ruwiki' => array( '<a class="external" rel="nofollow" href="//ru.example.org/wiki/%D0%A4%D1%83">вар</a>', 'ruwiki', 'Фу', 'вар' ),
                );
        }
@@ -77,7 +77,7 @@ class WikiMapTest extends MediaWikiLangTestCase {
        public function provideForeignUserLink() {
                return array(
                        'unknown' => array( false, 'xyzzy', 'Foo' ),
-                       'enwiki' => array( '<a class="external" rel="nofollow" href="http://en.example.org/w/User:Foo">User:Foo</a>', 'enwiki', 'Foo' ),
+                       'enwiki' => array( '<a class="external" rel="nofollow" href="http://en.example.org/w/User:Foo">User:Foo</a>', 'enwiki', 'Foo' ),
                        'ruwiki' => array( '<a class="external" rel="nofollow" href="//ru.example.org/wiki/User:%D0%A4%D1%83">вар</a>', 'ruwiki', 'Фу', 'вар' ),
                );
        }
@@ -92,7 +92,7 @@ class WikiMapTest extends MediaWikiLangTestCase {
        public function provideGetForeignURL() {
                return array(
                        'unknown' => array( false, 'xyzzy', 'Foo' ),
-                       'enwiki' => array( 'http://en.example.org/w/Foo', 'enwiki', 'Foo' ),
+                       'enwiki' => array( 'http://en.example.org/w/Foo', 'enwiki', 'Foo' ),
                        'ruwiki with fragement' => array( '//ru.example.org/wiki/%D0%A4%D1%83#%D0%B2%D0%B0%D1%80', 'ruwiki', 'Фу', 'вар' ),
                );
        }
index c4d87c2..59bfb03 100644 (file)
@@ -111,7 +111,7 @@ class CssContentTest extends JavaScriptContentTest {
                );
        }
 
-               public static function dataEquals() {
+       public static function dataEquals() {
                return array(
                        array( new CssContent( 'hallo' ), null, false ),
                        array( new CssContent( 'hallo' ), new CssContent( 'hallo' ), true ),
index 0ee2712..898fa53 100644 (file)
@@ -253,7 +253,7 @@ class JavaScriptContentTest extends TextContentTest {
         * @covers JavaScriptContent::updateRedirect
         * @dataProvider provideUpdateRedirect
         */
-       public function testUpdateRedirect( $oldText, $expectedText) {
+       public function testUpdateRedirect( $oldText, $expectedText ) {
                $this->setMwGlobals( array(
                        'wgServer' => '//example.org',
                        'wgScriptPath' => '/w/index.php',
index ef6f847..9866ce1 100644 (file)
@@ -52,10 +52,10 @@ class KafkaHandlerTest extends MediaWikiTestCase {
                $produce = $this->getMockBuilder( 'Kafka\Produce' )
                        ->disableOriginalConstructor()
                        ->getMock();
-               $produce->expects($this->any())
-                       ->method('getAvailablePartitions')
-                       ->will($this->returnValue( array( 'A' ) ) );
-               $produce->expects($this->once())
+               $produce->expects( $this->any() )
+                       ->method( 'getAvailablePartitions' )
+                       ->will( $this->returnValue( array( 'A' ) ) );
+               $produce->expects( $this->once() )
                        ->method( 'setMessages' )
                        ->with( $expect, $this->anything(), $this->anything() );
 
index 681e368..ea3f862 100644 (file)
@@ -99,7 +99,7 @@ class FileBackendDBRepoWrapperTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( '96246614d75ba1703bdfd5d7660bb57407aaf5d9' ) );
 
                $backendMock->expects( $this->once() )
-                       ->method( 'getFileContentsMulti')
+                       ->method( 'getFileContentsMulti' )
                        ->will( $this->returnValue( array( $sha1Path => 'foo' ) ) );
 
                $result = $wrapperMock->getFileContentsMulti( array( 'srcs' => array( $filenamePath ) ) );
index 551d3a7..679382b 100644 (file)
@@ -64,12 +64,12 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase {
 
        protected function deleteFilesRecursively( $directory ) {
                foreach ( glob( $directory . '/*' ) as $file ) {
-               if ( is_dir( $file ) ) {
-                       $this->deleteFilesRecursively( $file );
-               } else {
-                       unlink( $file );
-               }
-               }
+                       if ( is_dir( $file ) ) {
+                               $this->deleteFilesRecursively( $file );
+                       } else {
+                               unlink( $file );
+                       }
+               }
 
                rmdir( $directory );
        }
@@ -103,7 +103,7 @@ class MigrateFileRepoLayoutTest extends MediaWikiTestCase {
                        . '/'
                        . substr( $sha1, 2, 1 )
                        . '/'
-                       . $sha1 ;
+                       . $sha1;
 
                $this->assertEquals( file_get_contents( $expectedOriginalFilepath ), $this->text, 'New sha1 file should be exist and have the right contents' );
 
index d36710a..285f280 100644 (file)
@@ -24,7 +24,7 @@ class WebPHandlerTest extends MediaWikiTestCase {
                        array( "\x52\x49\x46\x46\x90\x68\x01\x00\x57\x45\x42\x50\x56\x50\x38\x4C\x83\x68\x01\x00\x2F\x8F\x01\x4B\x10\x8D\x38\x6C\xDB\x46\x92\xE0\xE0\x82\x7B\x6C",
                                array( 'compression' => 'lossless', 'width' => 400, 'height' => 301 ) ),
                        array( "\x52\x49\x46\x46\x64\x5B\x00\x00\x57\x45\x42\x50\x56\x50\x38\x58\x0A\x00\x00\x00\x10\x00\x00\x00\x8F\x01\x00\x2C\x01\x00\x41\x4C\x50\x48\xE5\x0E",
-                               array( 'compression' => 'unknown', 'animated' => false, 'transparency' => true, 'width' => 400, 'height' => 301) ),
+                               array( 'compression' => 'unknown', 'animated' => false, 'transparency' => true, 'width' => 400, 'height' => 301 ) ),
                        array( "\x52\x49\x46\x46\xA8\x72\x00\x00\x57\x45\x42\x50\x56\x50\x38\x4C\x9B\x72\x00\x00\x2F\x81\x81\x62\x10\x8D\x40\x8C\x24\x39\x6E\x73\x73\x38\x01\x96",
                                array( 'compression' => 'lossless', 'width' => 386, 'height' => 395 ) ),
                        array( "\x52\x49\x46\x46\xE0\x42\x00\x00\x57\x45\x42\x50\x56\x50\x38\x58\x0A\x00\x00\x00\x10\x00\x00\x00\x81\x01\x00\x8A\x01\x00\x41\x4C\x50\x48\x56\x10",
@@ -50,9 +50,9 @@ class WebPHandlerTest extends MediaWikiTestCase {
                        array( "\x52\x49\x46\x46\x7A\x19\x03\x00\x57\x45\x42\x50\x56\x50\x38\x20\x6E\x19\x03\x00\xB2\xF8\x09\x9D\x01\x2A\x00\x05\xD0\x02\x3E\xAD\x46\x99\x4A\xA5",
                                array( 'compression' => 'lossy', 'width' => 1280, 'height' => 720 ) ),
                        array( "\x52\x49\x46\x46\x44\xB3\x02\x00\x57\x45\x42\x50\x56\x50\x38\x20\x38\xB3\x02\x00\x52\x57\x06\x9D\x01\x2A\x00\x04\x04\x03\x3E\xA5\x44\x96\x49\x26",
-                               array( 'compression' => 'lossy', 'width' => 1024, 'height' => 772) ),
+                               array( 'compression' => 'lossy', 'width' => 1024, 'height' => 772 ) ),
                        array( "\x52\x49\x46\x46\x02\x43\x01\x00\x57\x45\x42\x50\x56\x50\x38\x20\xF6\x42\x01\x00\x12\xC0\x05\x9D\x01\x2A\x00\x04\xF0\x02\x3E\x79\x34\x93\x47\xA4",
-                               array( 'compression' => 'lossy', 'width' => 1024, 'height' => 752) ),
+                               array( 'compression' => 'lossy', 'width' => 1024, 'height' => 752 ) ),
 
                        // Animated file from https://groups.google.com/a/chromium.org/d/topic/blink-dev/Y8tRC4mdQz8/discussion
                        array( "\x52\x49\x46\x46\xD0\x0B\x02\x00\x57\x45\x42\x50\x56\x50\x38\x58\x0A\x00\x00\x00\x12\x00\x00\x00\x3F\x01\x00\x3F\x01\x00\x41\x4E",