Aude has uploaded a new change for review.

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


Change subject: Style cleanup in WikibaseClient hooks
......................................................................

Style cleanup in WikibaseClient hooks

Change-Id: Ic5dc21c13d640d177a8d280098db0dd8a4bb8039
---
M client/WikibaseClient.hooks.php
1 file changed, 85 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/61/92161/1

diff --git a/client/WikibaseClient.hooks.php b/client/WikibaseClient.hooks.php
index f8144f3..c0b77ef 100644
--- a/client/WikibaseClient.hooks.php
+++ b/client/WikibaseClient.hooks.php
@@ -1,11 +1,30 @@
 <?php
 namespace Wikibase;
 
+use Action;
+use ChangesList;
+use DatabaseUpdater;
+use FormOptions;
 use IContextSource;
+use JobQueueGroup;
+use Linker;
+use MovePageForm;
+use OutputPage;
+use Parser;
+use ParserOutput;
+use QuickTemplate;
+use RecentChange;
 use RecursiveDirectoryIterator;
 use RecursiveIteratorIterator;
+use RuntimeException;
 use SplFileInfo;
 use SiteSQLStore;
+use Sites;
+use Skin;
+use SpecialRecentChanges;
+use StripState;
+use Title;
+use User;
 use Wikibase\Client\WikibaseClient;
 use Wikibase\Client\MovePageNotice;
 use Wikibase\DataModel\SimpleSiteLink;
@@ -14,9 +33,6 @@
  * File defining the hook handlers for the Wikibase Client extension.
  *
  * @since 0.1
- *
- * @file
- * @ingroup WikibaseClient
  *
  * @licence GNU GPL v2+
  *
@@ -27,7 +43,6 @@
  * @author Jeroen De Dauw < [email protected] >
  * @author Marius Hoch < [email protected] >
  */
-
 final class ClientHooks {
 
        /**
@@ -36,11 +51,11 @@
         *
         * @since 0.1
         *
-        * @param \DatabaseUpdater $updater
+        * @param DatabaseUpdater $updater
         *
         * @return bool
         */
-       public static function onSchemaUpdate( \DatabaseUpdater $updater ) {
+       public static function onSchemaUpdate( DatabaseUpdater $updater ) {
                wfProfileIn( __METHOD__ );
 
                $type = $updater->getDB()->getType();
@@ -149,7 +164,8 @@
 
                $store = WikibaseClient::getDefaultInstance()->getStore();
                $stores = array_flip( $GLOBALS['wgWBClientStores'] );
-               $reportMessage( "Rebuilding all data in the " . 
$stores[get_class( $store )] . " store on the client..." );
+               $reportMessage( "Rebuilding all data in the " . 
$stores[get_class( $store )]
+                       . " store on the client..." );
                $store->rebuild();
                $changes = ChangesTable::singleton();
                $changes = $changes->select(
@@ -171,13 +187,14 @@
         *
         * @since 0.3
         *
-        * @param \MovePageForm $movePage
-        * @param \Title &$oldTitle
-        * @param \Title &$newTitle
+        * @param MovePageForm $movePage
+        * @param Title &$oldTitle
+        * @param Title &$newTitle
         *
         * @return bool
         */
-       public static function onSpecialMovepageAfterMove( \MovePageForm 
$movePage, \Title &$oldTitle, \Title &$newTitle ) {
+       public static function onSpecialMovepageAfterMove( MovePageForm 
$movePage, Title &$oldTitle,
+               Title &$newTitle ) {
                $siteLinkLookup = 
WikibaseClient::getDefaultInstance()->getStore()->getSiteLinkTable();
                $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
 
@@ -201,11 +218,11 @@
         *
         * @since 0.4
         *
-        * @param $engine
+        * @param string $engine
         * @param array $extraLibraries
         * @return bool
         */
-       public static function onScribuntoExternalLibraries ( $engine, array 
&$extraLibraries ) {
+       public static function onScribuntoExternalLibraries( $engine, array 
&$extraLibraries ) {
                if ( Settings::get( 'allowDataTransclusion' ) === true ) {
                        $extraLibraries['mw.wikibase'] = 
'Scribunto_LuaWikibaseLibrary';
                }
@@ -222,14 +239,15 @@
         * @param &$conds[]
         * @param &$tables[]
         * @param &$join_conds[]
-        * @param \FormOptions $opts
+        * @param FormOptions $opts
         * @param &$query_options[]
         * @param &$fields[]
         *
         * @return bool
         */
-       public static function onSpecialRecentChangesQuery( array &$conds, 
array &$tables, array &$join_conds,
-               \FormOptions $opts, array &$query_options, array &$fields ) {
+       public static function onSpecialRecentChangesQuery( array &$conds, 
array &$tables,
+               array &$join_conds, FormOptions $opts, array &$query_options, 
array &$fields
+       ) {
                wfProfileIn( __METHOD__ );
 
                $rcFilterOpts = new RecentChangesFilterOptions( $opts );
@@ -248,14 +266,15 @@
         *
         * @since 0.2
         *
-        * @param \ChangesList $changesList
+        * @param ChangesList $changesList
         * @param string $s
-        * @param \RecentChange $rc
+        * @param RecentChange $rc
+        * @param string[] &$classes
         *
         * @return bool
         */
-       public static function onOldChangesListRecentChangesLine( \ChangesList 
&$changesList, &$s,
-               \RecentChange $rc, &$classes = array() ) {
+       public static function onOldChangesListRecentChangesLine( ChangesList 
&$changesList, &$s,
+               RecentChange $rc, &$classes = array() ) {
 
                wfProfileIn( __METHOD__ );
 
@@ -302,7 +321,9 @@
         *
         * @return bool
         */
-       public static function onSpecialWatchlistQuery( array &$conds, array 
&$tables, array &$join_conds, array &$fields, array $values = array() ) {
+       public static function onSpecialWatchlistQuery( array &$conds, array 
&$tables,
+               array &$join_conds, array &$fields, array $values = array()
+       ) {
                global $wgRequest, $wgUser;
 
                wfProfileIn( __METHOD__ );
@@ -317,7 +338,7 @@
 
                        $newConds = array();
                        foreach( $conds as $k => $v ) {
-                               if ( $v ===  'rc_this_oldid=page_latest OR 
rc_type=3' ) {
+                               if ( $v === 'rc_this_oldid=page_latest OR 
rc_type=3' ) {
                                        $where = array(
                                                'rc_this_oldid=page_latest',
                                                'rc_type' => array( 3, 5 )
@@ -342,13 +363,13 @@
         *
         * @since 0.1
         *
-        * @param \Parser $parser
+        * @param Parser $parser
         * @param string $text
-        * @param \StripState $stripState
+        * @param StripState $stripState
         *
         * @return bool
         */
-       public static function onParserAfterParse( \Parser &$parser, &$text, 
\StripState $stripState ) {
+       public static function onParserAfterParse( Parser &$parser, &$text, 
StripState $stripState ) {
                wfProfileIn( __METHOD__ );
 
                // @todo split up the multiple responsibilities here and in 
lang link handler
@@ -367,7 +388,7 @@
                        Settings::get( 'namespaces' ),
                        Settings::get( 'excludeNamespaces' ),
                        
WikibaseClient::getDefaultInstance()->getStore()->getSiteLinkTable(),
-                       \Sites::singleton(),
+                       Sites::singleton(),
                        
WikibaseClient::getDefaultInstance()->getLangLinkSiteGroup() );
 
                $useRepoLinks = $langLinkHandler->useRepoLinks( 
$parser->getTitle(), $parser->getOutput() );
@@ -409,7 +430,7 @@
         *
         * @return boolean
         */
-       public static function onBaseTemplateToolbox( &$sk, &$toolbox ) {
+       public static function onBaseTemplateToolbox( SkinTemplate &$sk, 
&$toolbox ) {
                $prefixedId = $sk->getSkin()->getOutput()->getProperty( 
'wikibase_item' );
 
                if ( $prefixedId !== null ) {
@@ -432,14 +453,14 @@
        /**
         * Add the connected item prefixed id as a JS config variable, for 
gadgets etc.
         *
-        * @param \OutputPage &$out
-        * @param \Skin &$skin
+        * @param OutputPage &$out
+        * @param Skin &$skin
         *
         * @since 0.4
         *
         * @return bool
         */
-       public static function onBeforePageDisplayAddJsConfig( \OutputPage 
&$out, \Skin &$skin ) {
+       public static function onBeforePageDisplayAddJsConfig( OutputPage 
&$out, Skin &$skin ) {
                $prefixedId = $out->getProperty( 'wikibase_item' );
 
                if ( $prefixedId !== null ) {
@@ -453,14 +474,14 @@
         * Adds css for the edit links sidebar link or JS to create a new item
         * or to link with an existing one.
         *
-        * @param \OutputPage &$out
-        * @param \Skin &$skin
+        * @param OutputPage &$out
+        * @param Skin &$skin
         *
         * @since 0.1
         *
         * @return bool
         */
-       public static function onBeforePageDisplay( \OutputPage &$out, \Skin 
&$skin ) {
+       public static function onBeforePageDisplay( OutputPage &$out, Skin 
&$skin ) {
                wfProfileIn( __METHOD__ );
 
                $title = $out->getTitle();
@@ -473,15 +494,17 @@
 
                if ( $namespaceChecker->isWikibaseEnabled( 
$title->getNamespace() ) ) {
                        $out->addModules( 'wikibase.client.init' );
+                       $actionName = Action::getActionName( 
$skin->getContext() );
 
-                       if ( !$out->getLanguageLinks() && 
\Action::getActionName( $skin->getContext() ) === 'view' && $title->exists() ) {
+                       if ( !$out->getLanguageLinks() && $actionName === 
'view' && $title->exists() ) {
                                // Module with the sole purpose to hide #p-lang
                                // Needed as we can't do that in the regular 
CSS nor in JavaScript
                                // (as that only runs after the element 
initially appeared).
                                $out->addModules( 'wikibase.client.nolanglinks' 
);
 
                                if ( Settings::get( 'enableSiteLinkWidget' ) 
=== true && $user->isLoggedIn() === true ) {
-                                       // Add the JavaScript which lazy-loads 
the link item widget (needed as jquery.wikibase.linkitem has pretty heavy 
dependencies)
+                                       // Add the JavaScript which lazy-loads 
the link item widget
+                                       // (needed as jquery.wikibase.linkitem 
has pretty heavy dependencies)
                                        $out->addModules( 
'wikibase.client.linkitem.init' );
                                }
                        }
@@ -496,18 +519,18 @@
         *
         * @since 0.4
         *
-        * @param \OutputPage &$out
-        * @param \ParserOutput $pout
+        * @param OutputPage &$out
+        * @param ParserOutput $pout
         *
         * @return bool
         */
-       public static function onOutputPageParserOutput( \OutputPage &$out, 
\ParserOutput $pout ) {
+       public static function onOutputPageParserOutput( OutputPage &$out, 
ParserOutput $pout ) {
                $langLinkHandler = new LangLinkHandler(
                        Settings::get( 'siteGlobalID' ),
                        Settings::get( 'namespaces' ),
                        Settings::get( 'excludeNamespaces' ),
                        
WikibaseClient::getDefaultInstance()->getStore()->getSiteLinkTable(),
-                       \Sites::singleton(),
+                       Sites::singleton(),
                        
WikibaseClient::getDefaultInstance()->getLangLinkSiteGroup() );
 
                $noExternalLangLinks = 
$langLinkHandler->getNoExternalLangLinks( $pout );
@@ -540,12 +563,12 @@
         *
         * @since 0.1
         *
-        * @param \Skin $skin
-        * @param \QuickTemplate $template
+        * @param Skin $skin
+        * @param QuickTemplate $template
         *
         * @return bool
         */
-       public static function onSkinTemplateOutputPageBeforeExec( \Skin 
&$skin, \QuickTemplate &$template ) {
+       public static function onSkinTemplateOutputPageBeforeExec( Skin &$skin, 
QuickTemplate &$template ) {
                wfProfileIn( __METHOD__ );
 
                $namespaceChecker = new NamespaceChecker(
@@ -572,7 +595,7 @@
                        $site->getGroup()
                );
 
-               $action = \Action::getActionName( $skin->getContext() );
+               $action = Action::getActionName( $skin->getContext() );
                $title = $skin->getContext()->getTitle();
 
                $isAnon = ! $skin->getContext()->getUser()->isLoggedIn();
@@ -592,12 +615,12 @@
        /**
         * Adds a toggle for showing/hiding Wikidata entries in recent changes
         *
-        * @param \SpecialRecentChanges $special
+        * @param SpecialRecentChanges $special
         * @param array &$filters
         *
         * @return bool
         */
-       public static function onSpecialRecentChangesFilters( 
\SpecialRecentChanges $special, array &$filters ) {
+       public static function onSpecialRecentChangesFilters( 
SpecialRecentChanges $special, array &$filters ) {
                $context = $special->getContext();
 
                if ( $context->getRequest()->getBool( 'enhanced', 
$context->getUser()->getOption( 'usenewrc' ) ) === false ) {
@@ -614,12 +637,12 @@
        /**
         * Adds a preference for showing or hiding Wikidata entries in recent 
changes
         *
-        * @param \User $user
+        * @param User $user
         * @param &$prefs[]
         *
         * @return bool
         */
-       public static function onGetPreferences( \User $user, array &$prefs ) {
+       public static function onGetPreferences( User $user, array &$prefs ) {
                $prefs['rcshowwikidata'] = array(
                        'type' => 'toggle',
                        'label-message' => 'wikibase-rc-show-wikidata-pref',
@@ -638,11 +661,11 @@
        /**
         * Register the parser functions.
         *
-        * @param $parser \Parser
+        * @param $parser Parser
         *
         * @return bool
         */
-       public static function onParserFirstCallInit( &$parser ) {
+       public static function onParserFirstCallInit( Parser &$parser ) {
                $parser->setFunctionHook( 'noexternallanglinks', 
'\Wikibase\NoLangLinkHandler::handle', SFH_NO_HASH );
 
                if ( Settings::get( 'allowDataTransclusion' ) === true ) {
@@ -685,7 +708,8 @@
        public static function onSpecialWatchlistFilters( $special, &$filters ) 
{
                $user = $special->getContext()->getUser();
 
-               if ( $special->getContext()->getRequest()->getBool( 'enhanced', 
$user->getOption( 'usenewrc' ) ) === false ) {
+               if ( $special->getContext()->getRequest()->getBool( 'enhanced',
+                       $user->getOption( 'usenewrc' ) ) === false ) {
                        // Allow toggling wikibase changes in case the enhanced 
watchlist is disabled
                        $filters['hideWikibase'] = array(
                                'msg' => 'wikibase-rc-hide-wikidata',
@@ -703,7 +727,7 @@
         *
         * @return bool
         */
-       public static function onInfoAction( $context, array &$pageInfo ) {
+       public static function onInfoAction( IContextSource $context, array 
&$pageInfo ) {
                // Check if wikibase namespace is enabled
                $title = $context->getTitle();
                $namespaceChecker = new NamespaceChecker(
@@ -723,7 +747,12 @@
                                $repoLinker = 
WikibaseClient::getDefaultInstance()->newRepoLinker();
                                $idFormatter = 
WikibaseClient::getDefaultInstance()->getEntityIdFormatter();
                                $idString = $idFormatter->format( $entityId );
-                               $itemLink = \Linker::makeExternalLink( 
$repoLinker->repoItemUrl( $entityId ), $idString, true, 'plainlink' );
+                               $itemLink = Linker::makeExternalLink(
+                                       $repoLinker->repoItemUrl( $entityId ),
+                                       $idString,
+                                       true,
+                                       'plainlink'
+                               );
 
                                // Adding the Repo link to array &$pageInfo
                                $pageInfo['header-basic'][] = array(
@@ -754,7 +783,8 @@
         *
         * @return bool
         */
-       public static function onTitleMoveComplete( $oldTitle, $newTitle, 
$user, $pageId, $redirectId ) {
+       public static function onTitleMoveComplete( Title $oldTitle, Title 
$newTitle, User $user,
+               $pageId, $redirectId ) {
                wfProfileIn( __METHOD__ );
 
                if ( Settings::get( 'propagateChangesToRepo' ) !== true ) {
@@ -764,7 +794,7 @@
 
                $repoDB = Settings::get( 'repoDatabase' );
                $siteLinkLookup = 
WikibaseClient::getDefaultInstance()->getStore()->getSiteLinkTable();
-               $jobQueueGroup = \JobQueueGroup::singleton( $repoDB );
+               $jobQueueGroup = JobQueueGroup::singleton( $repoDB );
 
                if ( !$jobQueueGroup ) {
                        wfLogWarning( "Failed to acquire a JobQueueGroup for 
$repoDB" );
@@ -791,7 +821,7 @@
 
                        // To be able to find out about this in the 
SpecialMovepageAfterMove hook
                        $newTitle->wikibasePushedMoveToRepo = true;
-               } catch( \RuntimeException $e ) {
+               } catch( RuntimeException $e ) {
                        // This is not a reason to let an exception bubble up, 
we just
                        // show a message to the user that the Wikibase item 
needs to be
                        // manually updated.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic5dc21c13d640d177a8d280098db0dd8a4bb8039
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <[email protected]>

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

Reply via email to