jenkins-bot has submitted this change and it was merged. Change subject: Enable PHPCS' Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace ......................................................................
Enable PHPCS' Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace Not much left for this sniff. Change-Id: Icb7464e1c3b7cd237c54c5f01356b983172379ef --- M client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php M lib/includes/LanguageNameLookup.php M lib/includes/serializers/AliasSerializer.php M lib/includes/serializers/ByPropertyListSerializer.php M lib/includes/serializers/ClaimSerializer.php M lib/includes/serializers/SiteLinkSerializer.php M lib/includes/serializers/SnakSerializer.php M lib/includes/store/EntityContentDataCodec.php M phpcs.xml M repo/Wikibase.hooks.php M repo/includes/BabelUserLanguageLookup.php M repo/includes/EntityParserOutputGenerator.php M repo/includes/SummaryFormatter.php M repo/includes/actions/HistoryEntityAction.php M repo/includes/api/EditEntity.php M repo/includes/api/LinkTitles.php M repo/includes/api/ParseValue.php M repo/includes/specials/SpecialItemDisambiguation.php M repo/includes/specials/SpecialModifyEntity.php M repo/includes/specials/SpecialSetSiteLink.php M repo/tests/phpunit/includes/SummaryFormatterTest.php M repo/tests/phpunit/includes/api/CreateClaimTest.php M repo/tests/phpunit/includes/api/RemoveQualifiersTest.php M repo/tests/phpunit/includes/api/RemoveReferencesTest.php M repo/tests/phpunit/includes/api/SetReferenceTest.php 25 files changed, 47 insertions(+), 80 deletions(-) Approvals: Jonas Kress (WMDE): Looks good to me, approved jenkins-bot: Verified diff --git a/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php b/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php index 75bddd4..394d2a3 100644 --- a/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php +++ b/client/includes/DataAccess/Scribunto/Scribunto_LuaWikibaseLibrary.php @@ -253,14 +253,13 @@ */ public function getEntity( $prefixedEntityId ) { $this->checkType( 'getEntity', 1, $prefixedEntityId, 'string' ); + try { $entityArr = $this->getEntityAccessor()->getEntity( $prefixedEntityId ); return array( $entityArr ); - } - catch ( EntityIdParsingException $e ) { + } catch ( EntityIdParsingException $ex ) { throw new ScribuntoException( 'wikibase-error-invalid-entity-id' ); - } - catch ( \Exception $e ) { + } catch ( Exception $ex ) { throw new ScribuntoException( 'wikibase-error-serialize-error' ); } } @@ -407,4 +406,5 @@ public function getUserLang() { return array( $this->getLuaBindings()->getUserLang() ); } + } diff --git a/lib/includes/LanguageNameLookup.php b/lib/includes/LanguageNameLookup.php index 26341fc..f758f8e 100644 --- a/lib/includes/LanguageNameLookup.php +++ b/lib/includes/LanguageNameLookup.php @@ -33,8 +33,7 @@ if ( isset( $inLanguage ) ) { $inLanguage = str_replace( '_', '-', $inLanguage ); $languageName = Language::fetchLanguageName( $languageCode, $inLanguage ); - } - else { + } else { $languageName = Language::fetchLanguageName( $languageCode ); } diff --git a/lib/includes/serializers/AliasSerializer.php b/lib/includes/serializers/AliasSerializer.php index 8fef354..e4969ae 100644 --- a/lib/includes/serializers/AliasSerializer.php +++ b/lib/includes/serializers/AliasSerializer.php @@ -50,8 +50,7 @@ } $value[$languageCode] = $arr; } - } - else { + } else { foreach ( $aliases as $languageCode => $alarr ) { foreach ( $alarr as $alias ) { if ( $alias === '' ) { diff --git a/lib/includes/serializers/ByPropertyListSerializer.php b/lib/includes/serializers/ByPropertyListSerializer.php index 2ae0aab..1b585d3 100644 --- a/lib/includes/serializers/ByPropertyListSerializer.php +++ b/lib/includes/serializers/ByPropertyListSerializer.php @@ -80,8 +80,7 @@ if ( $this->options->shouldIndexTags() ) { $serializedObjects['id'] = $propertyId->getSerialization(); $serialization[] = $serializedObjects; - } - else { + } else { $key = $propertyId->getSerialization(); if ( $this->getOptions()->shouldUseUpperCaseIdsAsKeys() ) { diff --git a/lib/includes/serializers/ClaimSerializer.php b/lib/includes/serializers/ClaimSerializer.php index 91a1ea7..269445a 100644 --- a/lib/includes/serializers/ClaimSerializer.php +++ b/lib/includes/serializers/ClaimSerializer.php @@ -141,8 +141,7 @@ if ( $serialization['references'] === array() ) { unset( $serialization['references'] ); - } - else { + } else { $this->setIndexedTagName( $serialization['references'], 'reference' ); } } diff --git a/lib/includes/serializers/SiteLinkSerializer.php b/lib/includes/serializers/SiteLinkSerializer.php index 9ec63af..450d1a9 100644 --- a/lib/includes/serializers/SiteLinkSerializer.php +++ b/lib/includes/serializers/SiteLinkSerializer.php @@ -107,8 +107,7 @@ if ( !$this->options->shouldIndexTags() ) { $serialization[$siteLink->getSiteId()] = $response; - } - else { + } else { $serialization[] = $response; } } diff --git a/lib/includes/serializers/SnakSerializer.php b/lib/includes/serializers/SnakSerializer.php index a753dd0..b9d4baa 100644 --- a/lib/includes/serializers/SnakSerializer.php +++ b/lib/includes/serializers/SnakSerializer.php @@ -145,8 +145,7 @@ $constructorArguments[0], $constructorArguments[1] ); - } - else { + } else { return new $snakClass( $constructorArguments[0] ); } } diff --git a/lib/includes/store/EntityContentDataCodec.php b/lib/includes/store/EntityContentDataCodec.php index 38599b1..a180c99 100644 --- a/lib/includes/store/EntityContentDataCodec.php +++ b/lib/includes/store/EntityContentDataCodec.php @@ -6,6 +6,7 @@ use Deserializers\Exceptions\DeserializationException; use InvalidArgumentException; use MWContentSerializationException; +use MWExceptionHandler; use Serializers\Exceptions\SerializationException; use Serializers\Serializer; use Wikibase\DataModel\Entity\Entity; @@ -139,9 +140,8 @@ try { $data = $this->entitySerializer->serialize( $entity ); return $this->encodeEntityContentData( $data, $format ); - } - catch ( SerializationException $ex ) { - \MWExceptionHandler::logException( $ex ); + } catch ( SerializationException $ex ) { + MWExceptionHandler::logException( $ex ); throw new MWContentSerializationException( $ex->getMessage(), 0, $ex ); } } @@ -227,8 +227,7 @@ try { $entity = $this->entityDeserializer->deserialize( $data ); return $entity; - } - catch ( DeserializationException $ex ) { + } catch ( DeserializationException $ex ) { throw new MWContentSerializationException( $ex->getMessage(), 0, $ex ); } } @@ -266,8 +265,7 @@ // TODO: Use proper Deserializer $redirect = new EntityRedirect( $entityId, $targetId ); return $redirect; - } - catch ( InvalidArgumentException $ex ) { + } catch ( InvalidArgumentException $ex ) { throw new MWContentSerializationException( $ex->getMessage(), 0, $ex ); } } @@ -290,16 +288,14 @@ // Handle the old-style representation of IDs as a two element array. $stubbedId = $data[$key]; return LegacyIdInterpreter::newIdFromTypeAndNumber( $stubbedId[0], $stubbedId[1] ); - } - catch ( InvalidArgumentException $ex ) { + } catch ( InvalidArgumentException $ex ) { throw new MWContentSerializationException( $ex->getMessage(), 0, $ex ); } } try { return $this->entityIdParser->parse( $data[$key] ); - } - catch ( EntityIdParsingException $ex ) { + } catch ( EntityIdParsingException $ex ) { throw new MWContentSerializationException( $ex->getMessage(), 0, $ex ); } } diff --git a/phpcs.xml b/phpcs.xml index 4d86acb..41f6fb2 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -60,9 +60,6 @@ <exclude-pattern>DataAccess*Scribunto*Scribunto_LuaWikibase*Library*\.php</exclude-pattern> </rule> <rule ref="Squiz.ControlStructures.ControlSignature" /> - <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"> - <severity>0</severity> - </rule> <!-- FIXME: This indicates an error in the Wikibase codebase that should be fixed. --> <rule ref="Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword"> <severity>0</severity> diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 6660b92..84d398a 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -130,8 +130,7 @@ 'wb_changes_dispatch', __DIR__ . '/sql/changes_dispatch' . $extension ); - } - else { + } else { wfWarn( "Database type '$type' is not supported by the Wikibase repository." ); } diff --git a/repo/includes/BabelUserLanguageLookup.php b/repo/includes/BabelUserLanguageLookup.php index 5103946..bc9dc02 100644 --- a/repo/includes/BabelUserLanguageLookup.php +++ b/repo/includes/BabelUserLanguageLookup.php @@ -38,8 +38,7 @@ // If the extension is installed, grab the languages from the user's Babel box if ( class_exists( 'Babel' ) && !$user->isAnon() ) { $this->babelLanguages[$key] = \Babel::getUserLanguages( $user ); - } - else { + } else { $this->babelLanguages[$key] = array(); } } diff --git a/repo/includes/EntityParserOutputGenerator.php b/repo/includes/EntityParserOutputGenerator.php index b2712f1..03140e3 100644 --- a/repo/includes/EntityParserOutputGenerator.php +++ b/repo/includes/EntityParserOutputGenerator.php @@ -151,8 +151,7 @@ if ( $entity instanceof StatementListProvider ) { $snaks = $entity->getStatements()->getAllSnaks(); - } - else { + } else { $snaks = array(); } diff --git a/repo/includes/SummaryFormatter.php b/repo/includes/SummaryFormatter.php index 18fb5a3..057da10 100644 --- a/repo/includes/SummaryFormatter.php +++ b/repo/includes/SummaryFormatter.php @@ -231,8 +231,7 @@ private function formatIfEntityId( $value ) { try { return $this->idFormatter->formatEntityId( $this->idParser->parse( $value ) ); - } - catch ( EntityIdParsingException $ex ) { + } catch ( EntityIdParsingException $ex ) { return $value; } } diff --git a/repo/includes/actions/HistoryEntityAction.php b/repo/includes/actions/HistoryEntityAction.php index a9efba7..d167c49 100644 --- a/repo/includes/actions/HistoryEntityAction.php +++ b/repo/includes/actions/HistoryEntityAction.php @@ -92,8 +92,7 @@ // OutputPage::setPageTitle: return $this->msg( 'wikibase-history-title-with-label' ) ->rawParams( $idSerialization, htmlspecialchars( $labelText ) )->text(); - } - else { + } else { return $this->msg( 'wikibase-history-title-without-label' ) ->rawParams( $idSerialization )->text(); } diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php index 1274a8d..bb22bdd 100644 --- a/repo/includes/api/EditEntity.php +++ b/repo/includes/api/EditEntity.php @@ -301,8 +301,7 @@ if ( $newLabel === "" ) { $labelChangeOps[] = $this->termChangeOpFactory->newRemoveLabelOp( $language ); - } - else { + } else { $labelChangeOps[] = $this->termChangeOpFactory->newSetLabelOp( $language, $newLabel ); } } @@ -331,8 +330,7 @@ if ( $newDescription === "" ) { $descriptionChangeOps[] = $this->termChangeOpFactory->newRemoveDescriptionOp( $language ); - } - else { + } else { $descriptionChangeOps[] = $this->termChangeOpFactory->newSetDescriptionOp( $language, $newDescription ); } } @@ -396,7 +394,7 @@ $aliasesChangeOps[] = $this->termChangeOpFactory->newRemoveAliasesOp( $language, $alias ); } elseif ( array_key_exists( 'add', $arg ) ) { $aliasesChangeOps[] = $this->termChangeOpFactory->newAddAliasesOp( $language, $alias ); - } else { + } else { $aliasesToSet[] = $alias[0]; } } diff --git a/repo/includes/api/LinkTitles.php b/repo/includes/api/LinkTitles.php index e037149..333803d 100644 --- a/repo/includes/api/LinkTitles.php +++ b/repo/includes/api/LinkTitles.php @@ -142,8 +142,7 @@ $flags |= EDIT_NEW; $summary->setAction( 'create' ); - } - elseif ( $fromId === null && $toId !== null ) { + } elseif ( $fromId === null && $toId !== null ) { // reuse to-site's item /** @var Item $item */ $itemRev = $lookup->getEntityRevision( $toId, EntityRevisionLookup::LATEST_FROM_MASTER ); @@ -152,8 +151,7 @@ $item->addSiteLink( $fromLink ); $return[] = $fromLink; $summary->setAction( 'connect' ); - } - elseif ( $fromId !== null && $toId === null ) { + } elseif ( $fromId !== null && $toId === null ) { // reuse from-site's item /** @var Item $item */ $itemRev = $lookup->getEntityRevision( $fromId, EntityRevisionLookup::LATEST_FROM_MASTER ); @@ -162,13 +160,10 @@ $item->addSiteLink( $toLink ); $return[] = $toLink; $summary->setAction( 'connect' ); - } - // we can be sure that $fromId and $toId are not null here - elseif ( $fromId->equals( $toId ) ) { + } elseif ( $fromId->equals( $toId ) ) { // no-op $this->errorReporter->dieError( 'Common item detected, sitelinks are both on the same item', 'common-item' ); - } - else { + } else { // dissimilar items $this->errorReporter->dieError( 'No common item detected, unable to link titles', 'no-common-item' ); } @@ -188,7 +183,7 @@ private function getSiteAndNormalizedPageName( SiteList $sites, $site, $pageTitle ) { $siteObj = $sites->getSite( $site ); $page = $siteObj->normalizePageName( $pageTitle ); - if( $page === false ) { + if ( $page === false ) { $this->errorReporter->dieMessage( 'no-external-page', $site, $pageTitle ); } return array( $siteObj, $page ); @@ -204,8 +199,7 @@ if ( $item === null ) { // to not have an Item isn't really bad at this point return Status::newGood( true ); - } - else { + } else { // Do the actual save, or if it don't exist yet create it. return $this->attemptSaveEntity( $item, $summary, diff --git a/repo/includes/api/ParseValue.php b/repo/includes/api/ParseValue.php index 1947919..7925f01 100644 --- a/repo/includes/api/ParseValue.php +++ b/repo/includes/api/ParseValue.php @@ -124,8 +124,7 @@ try { $parseResult = $parser->parse( $value ); - } - catch ( ParseException $parseError ) { + } catch ( ParseException $parseError ) { $this->addParseErrorToResult( $result, $parseError ); return $result; } @@ -133,8 +132,7 @@ if ( $parseResult instanceof DataValue ) { $result['value'] = $parseResult->getArrayValue(); $result['type'] = $parseResult->getType(); - } - else { + } else { $result['value'] = $parseResult; } diff --git a/repo/includes/specials/SpecialItemDisambiguation.php b/repo/includes/specials/SpecialItemDisambiguation.php index 89e7fef..f07fe14 100644 --- a/repo/includes/specials/SpecialItemDisambiguation.php +++ b/repo/includes/specials/SpecialItemDisambiguation.php @@ -116,8 +116,7 @@ if ( $request->getCheck( 'label' ) ) { $label = $request->getText( 'label' ); - } - else { + } else { $label = isset( $parts[1] ) ? str_replace( '_', ' ', $parts[1] ) : ''; } diff --git a/repo/includes/specials/SpecialModifyEntity.php b/repo/includes/specials/SpecialModifyEntity.php index de10a9a..b78e2ae 100644 --- a/repo/includes/specials/SpecialModifyEntity.php +++ b/repo/includes/specials/SpecialModifyEntity.php @@ -100,8 +100,7 @@ $errors = $status->getErrorsArray(); $this->showErrorHTML( $this->msg( $errors[0][0], array_slice( $errors[0], 1 ) )->parse() ); $this->setForm( $entity ); - } - else { + } else { $entityUrl = $this->getEntityTitle( $entity->getId() )->getFullUrl(); $this->getOutput()->redirect( $entityUrl ); } diff --git a/repo/includes/specials/SpecialSetSiteLink.php b/repo/includes/specials/SpecialSetSiteLink.php index b1bbc26..f09591b 100644 --- a/repo/includes/specials/SpecialSetSiteLink.php +++ b/repo/includes/specials/SpecialSetSiteLink.php @@ -256,8 +256,7 @@ . Html::input( 'id', $this->entityRevision->getEntity()->getId()->getSerialization(), 'hidden' ) . Html::input( 'remove', 'remove', 'hidden' ) . $pageinput; - } - else { + } else { $intro = $this->msg( 'wikibase-setsitelink-intro' )->text(); if ( !empty( $this->badgeItems ) ) { diff --git a/repo/tests/phpunit/includes/SummaryFormatterTest.php b/repo/tests/phpunit/includes/SummaryFormatterTest.php index a3f8e08..8a1ed38 100644 --- a/repo/tests/phpunit/includes/SummaryFormatterTest.php +++ b/repo/tests/phpunit/includes/SummaryFormatterTest.php @@ -330,12 +330,14 @@ public function testOnFormat( $model, $root, $pre, $auto, $post, $title, $local, $expected ) { $itemTitle = $this->getMock( $title ); $itemTitle->expects( $this->once() )->method( 'getContentModel' )->will( $this->returnValue( $model ) ); + $comment = null; - RepoHooks::onFormat( array($model, $root), $comment, $pre, $auto, $post, $itemTitle, $local ); + + RepoHooks::onFormat( array( $model, $root ), $comment, $pre, $auto, $post, $itemTitle, $local ); + if ( is_null( $expected ) ) { $this->assertEquals( $expected, $comment, "Didn't find the expected null" ); - } - else { + } else { $this->assertRegExp( $expected, $comment, "Didn't find the expected final comment" ); } } diff --git a/repo/tests/phpunit/includes/api/CreateClaimTest.php b/repo/tests/phpunit/includes/api/CreateClaimTest.php index 3089da0..5e0a6ce 100644 --- a/repo/tests/phpunit/includes/api/CreateClaimTest.php +++ b/repo/tests/phpunit/includes/api/CreateClaimTest.php @@ -226,11 +226,10 @@ try { $this->doApiRequestWithToken( $params ); $this->fail( 'Invalid request should raise an exception' ); - } - catch ( UsageException $e ) { + } catch ( UsageException $ex ) { $this->assertEquals( $errorCode, - $e->getCodeString(), 'Invalid request raised correct error: ' . $e->getMessage() + $ex->getCodeString(), 'Invalid request raised correct error: ' . $ex->getMessage() ); } diff --git a/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php b/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php index d5dab55..01a6db0 100644 --- a/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php +++ b/repo/tests/phpunit/includes/api/RemoveQualifiersTest.php @@ -95,8 +95,7 @@ array( '~=[,,_,,]:3' ), 'no-such-qualifier' ); - } - else { + } else { $hashes = array_map( function( Snak $qualifier ) { return $qualifier->getHash(); diff --git a/repo/tests/phpunit/includes/api/RemoveReferencesTest.php b/repo/tests/phpunit/includes/api/RemoveReferencesTest.php index 441da6e..0863f04 100644 --- a/repo/tests/phpunit/includes/api/RemoveReferencesTest.php +++ b/repo/tests/phpunit/includes/api/RemoveReferencesTest.php @@ -102,8 +102,7 @@ array( '~=[,,_,,]:3' ), 'no-such-reference' ); - } - else { + } else { $this->makeValidRequest( $statement->getGuid(), $hashes diff --git a/repo/tests/phpunit/includes/api/SetReferenceTest.php b/repo/tests/phpunit/includes/api/SetReferenceTest.php index 79029da..676c074 100644 --- a/repo/tests/phpunit/includes/api/SetReferenceTest.php +++ b/repo/tests/phpunit/includes/api/SetReferenceTest.php @@ -229,9 +229,8 @@ try { $this->doApiRequestWithToken( $params ); $this->assertFalse( true, 'Invalid request should raise an exception' ); - } - catch ( UsageException $e ) { - $this->assertEquals( $expectedErrorCode, $e->getCodeString(), 'Invalid request raised correct error' ); + } catch ( UsageException $ex ) { + $this->assertEquals( $expectedErrorCode, $ex->getCodeString(), 'Invalid request raised correct error' ); } } -- To view, visit https://gerrit.wikimedia.org/r/224951 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Icb7464e1c3b7cd237c54c5f01356b983172379ef Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Bene <benestar.wikime...@gmail.com> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits