Thiemo Mättig (WMDE) has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/252897

Change subject: Fix all PHPCS errors and warnings
......................................................................

Fix all PHPCS errors and warnings

Change-Id: Ic3d6b5dd42f79f74608805402c2637a78f3587ba
---
M ArticlePlaceholder.php
M Specials/SpecialAboutTopic.php
M includes/Hooks.php
M includes/SearchHookHandler.php
M tests/phpunit/Specials/SpecialAboutTopicTest.php
5 files changed, 49 insertions(+), 27 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ArticlePlaceholder 
refs/changes/97/252897/1

diff --git a/ArticlePlaceholder.php b/ArticlePlaceholder.php
index 3101aae..f512ab6 100644
--- a/ArticlePlaceholder.php
+++ b/ArticlePlaceholder.php
@@ -7,7 +7,6 @@
  *
  * @author Lucie-Aimée Kaffee
  *
- *
  * The license governing the extension code:
  * @license GNU General Public Licence 2.0 or later
  */
@@ -21,14 +20,16 @@
        'descriptionmsg' => 'articleplaceholder-desc',
 );
 
-$dir = dirname( __FILE__ );
-$dirbasename = basename( $dir );
-
-$wgAutoloadClasses['ArticlePlaceholder\Specials\SpecialAboutTopic'] = $dir . 
'/Specials/SpecialAboutTopic.php';
+$wgAutoloadClasses['ArticlePlaceholder\Specials\SpecialAboutTopic']
+       = __DIR__ . '/Specials/SpecialAboutTopic.php';
 $wgAutoloadClasses['ArticlePlaceholder\Hooks'] = __DIR__ . 
'/includes/Hooks.php';
-$wgAutoloadClasses['ArticlePlaceholder\SearchHookHandler'] = __DIR__ . 
'/includes/SearchHookHandler.php';
-$wgHooks['ScribuntoExternalLibraryPaths'][] = 
'\ArticlePlaceholder\Hooks::registerScribuntoExternalLibraryPaths';
-$wgHooks['SpecialSearchResultsAppend'][] = 
'\ArticlePlaceholder\SearchHookHandler::onSpecialSearchResultsAppend';
+$wgAutoloadClasses['ArticlePlaceholder\SearchHookHandler']
+       = __DIR__ . '/includes/SearchHookHandler.php';
+
+$wgHooks['ScribuntoExternalLibraryPaths'][]
+       = '\ArticlePlaceholder\Hooks::registerScribuntoExternalLibraryPaths';
+$wgHooks['SpecialSearchResultsAppend'][]
+       = '\ArticlePlaceholder\SearchHookHandler::onSpecialSearchResultsAppend';
 
 $wgMessagesDirs['ArticlePlaceholder'] = __DIR__ . '/i18n';
 $wgExtensionMessagesFiles['ArticlePlaceholderAliases'] = __DIR__ . 
'/ArticlePlaceholder.alias.php';
diff --git a/Specials/SpecialAboutTopic.php b/Specials/SpecialAboutTopic.php
index c3e5185..27ad8a9 100644
--- a/Specials/SpecialAboutTopic.php
+++ b/Specials/SpecialAboutTopic.php
@@ -116,7 +116,8 @@
                }
                if ( !$this->entityLookup->hasEntity( $entityId ) ) {
                        $this->createForm();
-                       $this->getOutput()->addWikiText( $this->msg( 
'articleplaceholder-abouttopic-no-entity-error' )->text() );
+                       $message = $this->msg( 
'articleplaceholder-abouttopic-no-entity-error' );
+                       $this->getOutput()->addWikiText( $message->text() );
                        return;
                }
 
@@ -268,7 +269,8 @@
         * @return string|null label
         */
        private function getLabel( ItemId $entityId ) {
-               $label = $this->termLookupFactory->newLabelDescriptionLookup( 
$this->getLanguage(), array() )->getLabel( $entityId );
+               $label = $this->termLookupFactory->newLabelDescriptionLookup( 
$this->getLanguage() )
+                       ->getLabel( $entityId );
 
                if ( $label !== null ) {
                        return $label->getText();
@@ -293,18 +295,18 @@
         * @todo set links to other projects in sidebar, too!
         */
        private function showLanguageLinks( ItemId $entityId ) {
-               $sitelinks = $this->sitelinkLookup->getSiteLinksForItem( 
$entityId );
-               $languagelinks = array();
+               $siteLinks = $this->sitelinkLookup->getSiteLinksForItem( 
$entityId );
+               $languageLinks = array();
 
-               foreach ( $sitelinks as $sl ) {
-                       $languageCode = $this->siteStore->getSite( 
($sl->getSiteId() ) )->getLanguageCode();
+               foreach ( $siteLinks as $siteLink ) {
+                       $languageCode = $this->siteStore->getSite( 
$siteLink->getSiteId() )->getLanguageCode();
 
                        if ( $languageCode !== null ) {
-                               $languagelinks[$languageCode] = $languageCode . 
':' . $sl->getPageName();
+                               $languageLinks[$languageCode] = $languageCode . 
':' . $siteLink->getPageName();
                        }
                }
 
-               $this->getOutput()->setLanguageLinks( $languagelinks );
+               $this->getOutput()->setLanguageLinks( $languageLinks );
        }
 
        /**
diff --git a/includes/Hooks.php b/includes/Hooks.php
index b24726a..612b2a0 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -6,18 +6,22 @@
  * File defining the hook handlers for the ArticlePlaceholder extension.
  *
  * @license GNU GPL v2+
- *
  * @author Lucie-Aimée Kaffee
  */
 class Hooks {
+
        /**
         * External Lua library paths for Scribunto
         *
         * @param string $engine
-        * @param array $extraLibraryPaths
+        * @param array &$extraLibraryPaths
+        *
         * @return bool
         */
-       public static function registerScribuntoExternalLibraryPaths( $engine, 
array &$extraLibraryPaths ) {
+       public static function registerScribuntoExternalLibraryPaths(
+               $engine,
+               array &$extraLibraryPaths
+       ) {
                if ( $engine !== 'lua' ) {
                        return true;
                }
diff --git a/includes/SearchHookHandler.php b/includes/SearchHookHandler.php
index 078875f..daa0a51 100644
--- a/includes/SearchHookHandler.php
+++ b/includes/SearchHookHandler.php
@@ -4,11 +4,11 @@
 
 use OutputPage;
 use SpecialSearch;
-use Wikibase\TermIndex;
-use Wikibase\TermIndexEntry;
 use Wikibase\Client\WikibaseClient;
 use Wikibase\Lib\Interactors\TermIndexSearchInteractor;
 use Wikibase\Lib\Interactors\TermSearchResult;
+use Wikibase\TermIndex;
+use Wikibase\TermIndexEntry;
 
 /**
  * Adding results from ArticlePlaceholder to search
@@ -35,11 +35,14 @@
 
        /**
         * @param string $language user language
+        *
         * @return self
         */
        private static function newFromGlobalState( $language ) {
                global $wgLanguageCode;
+
                $wikibaseClient = WikibaseClient::getDefaultInstance();
+
                return new self(
                        $wikibaseClient->getStore()->getTermIndex(),
                        $wikibaseClient->newTermSearchInteractor( $language ),
@@ -52,7 +55,11 @@
         * @param TermIndexSearchInteractor $termSearchInteractor
         * @param string $languageCode content language
         */
-       public function __construct( TermIndex $termIndex, 
TermIndexSearchInteractor $termSearchInteractor, $languageCode ) {
+       public function __construct(
+               TermIndex $termIndex,
+               TermIndexSearchInteractor $termSearchInteractor,
+               $languageCode
+       ) {
                $this->termIndex = $termIndex;
                $this->termSearchInteractor = $termSearchInteractor;
                $this->languageCode = $languageCode;
@@ -62,9 +69,14 @@
         * @param SpecialSearch $specialSearch
         * @param OutputPage $output
         * @param string|null $term
+        *
         * @return bool
         */
-       public static function onSpecialSearchResultsAppend( SpecialSearch 
$specialSearch, OutputPage $output, $term ) {
+       public static function onSpecialSearchResultsAppend(
+               SpecialSearch $specialSearch,
+               OutputPage $output,
+               $term
+       ) {
                if ( $term === null || $term === '' ) {
                        return;
                }
@@ -98,6 +110,7 @@
 
        /**
         * @param string $term
+        *
         * @return string
         */
        private function getSearchResults( $term ) {
@@ -115,6 +128,7 @@
        /**
         * @param TermSearchResult $searchResult
         * @param string $link
+        *
         * @return string
         */
        private function createResult( TermSearchResult $searchResult, $link ) {
@@ -122,13 +136,13 @@
                $label = $searchResult->getDisplayLabel()->getText();
                $description = 
$searchResult->getDisplayDescription()->getText();
 
-               $wikitextResult = '[[' . $link . wfEscapeWikiText( $entityId ) 
. '|' . wfEscapeWikiText( $label ) .']]';
-               $wikitextResult .= ': ' . wfEscapeWikiText( $description );
-               return $wikitextResult;
+               return '[[' . $link . wfEscapeWikiText( $entityId ) . '|' . 
wfEscapeWikiText( $label )
+                       .']]: ' . wfEscapeWikiText( $description );
        }
 
        /**
         * @param string $term
+        *
         * @return TermSearchResult[]
         */
        private function searchEntities( $term ) {
diff --git a/tests/phpunit/Specials/SpecialAboutTopicTest.php 
b/tests/phpunit/Specials/SpecialAboutTopicTest.php
index 8e888b3..e52d7b6 100644
--- a/tests/phpunit/Specials/SpecialAboutTopicTest.php
+++ b/tests/phpunit/Specials/SpecialAboutTopicTest.php
@@ -26,7 +26,8 @@
        }
 
        public function testExecute() {
-               $termLookupFactory = $this->getMockBuilder( 
'Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory' )
+               $termLookupFactory = $this->getMockBuilder(
+                       
'Wikibase\Lib\Store\LanguageFallbackLabelDescriptionLookupFactory' )
                        ->disableOriginalConstructor()
                        ->getMock();
 

-- 
To view, visit https://gerrit.wikimedia.org/r/252897
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3d6b5dd42f79f74608805402c2637a78f3587ba
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ArticlePlaceholder
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to