Thiemo Kreuz (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/399169 )

Change subject: Fix all kinds of type safety warnings accross the code base
......................................................................

Fix all kinds of type safety warnings accross the code base

This fixes all kinds of warnings the static analysis in my PHPStorms
spits out. Most changes are to PHPDoc comments. Some are actually broken,
some outdated, some missing. Some changes make generic "array" type hints
more specific. Other changes add strict type hints to internal methods.

Change-Id: Ie053a03556c253fa2796b04d83050adfcdbb31d9
---
M AntiSpoof/batchCAAntiSpoof.php
M includes/CentralAuthHooks.php
M includes/CentralAuthPrimaryAuthenticationProvider.php
M includes/CentralAuthUser.php
M includes/CentralAuthUserArray.php
M includes/CentralAuthUtils.php
M includes/GlobalRename/GlobalRenameRequest.php
M includes/GlobalRename/GlobalRenameUserDatabaseUpdates.php
M includes/GlobalRename/GlobalRenameUserStatus.php
M includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
M includes/UsersToRename/UsersToRenameDatabaseUpdates.php
M includes/api/ApiQueryGlobalAllUsers.php
M includes/session/CentralAuthSessionProvider.php
M includes/specials/SpecialCentralAuth.php
M includes/specials/SpecialCentralAutoLogin.php
M includes/specials/SpecialCentralLogin.php
M includes/specials/SpecialGlobalRenameQueue.php
M maintenance/forceRenameUsers.php
M maintenance/populateListOfUsersToRename.php
19 files changed, 47 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CentralAuth 
refs/changes/69/399169/1

diff --git a/AntiSpoof/batchCAAntiSpoof.php b/AntiSpoof/batchCAAntiSpoof.php
index 017ccbb..d259009 100644
--- a/AntiSpoof/batchCAAntiSpoof.php
+++ b/AntiSpoof/batchCAAntiSpoof.php
@@ -1,6 +1,8 @@
 <?php
 // Go through all usernames and calculate and record spoof thingies
 
+use Wikimedia\Rdbms\IDatabase;
+
 $IP = getenv( 'MW_INSTALL_PATH' );
 if ( $IP === false ) {
        $IP = __DIR__ . '/../../..';
diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php
index a24917e..54c9ae1 100644
--- a/includes/CentralAuthHooks.php
+++ b/includes/CentralAuthHooks.php
@@ -1,6 +1,8 @@
 <?php
 
+use MediaWiki\Session\SessionInfo;
 use Wikimedia\Rdbms\IMaintainableDatabase;
+use Wikimedia\Rdbms\ResultWrapper;
 
 class CentralAuthHooks {
 
@@ -1431,10 +1433,7 @@
         * Hook function to prevent logged-in sessions when a user is being
         * renamed.
         * @param string &$reason Failure reason to log
-        * @param MediaWiki\\Session\\SessionInfo $info
-        * @param WebRequest $request
-        * @param array|false $metadata
-        * @param array|false $data
+        * @param SessionInfo $info
         * @return bool
         */
        public static function onSessionCheckInfo( &$reason, $info ) {
diff --git a/includes/CentralAuthPrimaryAuthenticationProvider.php 
b/includes/CentralAuthPrimaryAuthenticationProvider.php
index 9d96793..de943f0 100644
--- a/includes/CentralAuthPrimaryAuthenticationProvider.php
+++ b/includes/CentralAuthPrimaryAuthenticationProvider.php
@@ -102,6 +102,7 @@
        }
 
        public function beginPrimaryAuthentication( array $reqs ) {
+               /** @var PasswordAuthenticationRequest $req */
                $req = AuthenticationRequest::getRequestByClass(
                        $reqs, PasswordAuthenticationRequest::class
                );
diff --git a/includes/CentralAuthUser.php b/includes/CentralAuthUser.php
index c363eb6..90c33c1 100644
--- a/includes/CentralAuthUser.php
+++ b/includes/CentralAuthUser.php
@@ -11,6 +11,9 @@
 */
 
 use MediaWiki\Logger\LoggerFactory;
+use Wikimedia\Rdbms\Database;
+use Wikimedia\Rdbms\IDatabase;
+use Wikimedia\Rdbms\ResultWrapper;
 
 class CentralAuthUser extends AuthPluginUser implements IDBAccessObject {
        /** Cache of loaded CentralAuthUsers */
@@ -2644,6 +2647,7 @@
        static function getCookieDomain() {
                global $wgCentralAuthCookieDomain;
 
+               /** @var CentralAuthSessionProvider $provider */
                $provider = MediaWiki\Session\SessionManager::singleton()
                        ->getProvider( 'CentralAuthSessionProvider' );
                if ( $provider ) {
diff --git a/includes/CentralAuthUserArray.php 
b/includes/CentralAuthUserArray.php
index 4b180f2..887fda7 100644
--- a/includes/CentralAuthUserArray.php
+++ b/includes/CentralAuthUserArray.php
@@ -1,12 +1,14 @@
 <?php
 
+use Wikimedia\Rdbms\ResultWrapper;
+
 class CentralAuthUserArray {
 
        /**
         * @param ResultWrapper $res
         * @return CentralAuthUserArrayFromResult
         */
-       static function newFromResult( $res ) {
+       static function newFromResult( ResultWrapper $res ) {
                return new CentralAuthUserArrayFromResult( $res );
        }
 }
@@ -17,7 +19,7 @@
        /**
         * @param ResultWrapper $res
         */
-       public function __construct( $res ) {
+       public function __construct( ResultWrapper $res ) {
                parent::__construct( $res );
 
                if ( $res->numRows() == 0 ) {
diff --git a/includes/CentralAuthUtils.php b/includes/CentralAuthUtils.php
index b4d8100..d896893 100644
--- a/includes/CentralAuthUtils.php
+++ b/includes/CentralAuthUtils.php
@@ -1,6 +1,7 @@
 <?php
 
 use MediaWiki\Auth\AuthManager;
+use MediaWiki\Session\Session;
 use MediaWiki\Session\SessionManager;
 use MediaWiki\MediaWikiServices;
 
@@ -156,7 +157,7 @@
 
        /**
         * Get the central session data
-        * @param MediaWiki\\Session\\Session|null $session
+        * @param Session|null $session
         * @return array
         */
        public static function getCentralSession( $session = null ) {
@@ -191,7 +192,7 @@
         * Set data in the central session
         * @param array $data
         * @param bool|string $reset Reset the session ID. If a string, this is 
the new ID.
-        * @param MediaWiki\\Session\\Session|null $session
+        * @param Session|null $session
         * @return string|null Session ID
         */
        public static function setCentralSession( array $data, $reset = false, 
$session = null ) {
@@ -232,7 +233,7 @@
 
        /**
         * Delete the central session data
-        * @param MediaWiki\\Session\\Session|null $session
+        * @param Session|null $session
         */
        public static function deleteCentralSession( $session = null ) {
                if ( !$session ) {
diff --git a/includes/GlobalRename/GlobalRenameRequest.php 
b/includes/GlobalRename/GlobalRenameRequest.php
index 416db73..eb9ffdc 100644
--- a/includes/GlobalRename/GlobalRenameRequest.php
+++ b/includes/GlobalRename/GlobalRenameRequest.php
@@ -19,6 +19,8 @@
  * @file
  */
 
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * Data access object for global rename requests.
  *
diff --git a/includes/GlobalRename/GlobalRenameUserDatabaseUpdates.php 
b/includes/GlobalRename/GlobalRenameUserDatabaseUpdates.php
index e00576b..d3e83cc 100644
--- a/includes/GlobalRename/GlobalRenameUserDatabaseUpdates.php
+++ b/includes/GlobalRename/GlobalRenameUserDatabaseUpdates.php
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * Update the rows in the CentralAuth tables during a rename
  *
diff --git a/includes/GlobalRename/GlobalRenameUserStatus.php 
b/includes/GlobalRename/GlobalRenameUserStatus.php
index effc2a0..f03e70e 100644
--- a/includes/GlobalRename/GlobalRenameUserStatus.php
+++ b/includes/GlobalRename/GlobalRenameUserStatus.php
@@ -8,6 +8,7 @@
  * @author Marius Hoch < h...@online.de >
  */
 
+use Wikimedia\Rdbms\DBQueryError;
 use Wikimedia\Rdbms\IDatabase;
 
 class GlobalRenameUserStatus implements IDBAccessObject {
diff --git a/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php 
b/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
index 41427fb..888258c 100644
--- a/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
+++ b/includes/GlobalRename/GlobalUserMergeDatabaseUpdates.php
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\Rdbms\IDatabase;
+
 /**
  * Update the rows in the CentralAuth tables during a user merge
  *
diff --git a/includes/UsersToRename/UsersToRenameDatabaseUpdates.php 
b/includes/UsersToRename/UsersToRenameDatabaseUpdates.php
index 844132c..7e8b5a2 100644
--- a/includes/UsersToRename/UsersToRenameDatabaseUpdates.php
+++ b/includes/UsersToRename/UsersToRenameDatabaseUpdates.php
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\Rdbms\IDatabase;
+
 class UsersToRenameDatabaseUpdates {
 
        /**
diff --git a/includes/api/ApiQueryGlobalAllUsers.php 
b/includes/api/ApiQueryGlobalAllUsers.php
index 38c4e3d..4e90a26 100644
--- a/includes/api/ApiQueryGlobalAllUsers.php
+++ b/includes/api/ApiQueryGlobalAllUsers.php
@@ -1,4 +1,8 @@
 <?php
+
+use Wikimedia\Rdbms\IDatabase;
+use Wikimedia\Rdbms\ResultWrapper;
+
 /**
  * Api module for CentralAuth extension to list all global users.
  * Partly based on ApiQueryAllUsers.
@@ -180,12 +184,12 @@
        /**
         * Get the global groups for the given global user result set.
         *
-        * @param array $result Result of a globaluser table select
+        * @param ResultWrapper $result Result of a globaluser table select
         * @param string $dir Sorting directory
         *
         * @return array
         */
-       protected function getGlobalGroups( $result, $dir ) {
+       protected function getGlobalGroups( ResultWrapper $result, $dir ) {
                $this->resetQueryParams();
 
                // Get all global groups now. We do this by using a WHERE
diff --git a/includes/session/CentralAuthSessionProvider.php 
b/includes/session/CentralAuthSessionProvider.php
index 39614c0..dfbd15a 100644
--- a/includes/session/CentralAuthSessionProvider.php
+++ b/includes/session/CentralAuthSessionProvider.php
@@ -22,7 +22,7 @@
 
        /**
         * @param array $params In addition to the parameters for
-        * \\MediaWiki\\Session\\CookieSessionProvider, the following are
+        * CookieSessionProvider, the following are
         * recognized:
         *  - enable: Whether to set CentralAuth-specific features. Defaults to
         *    $wgCentralAuthCookies.
diff --git a/includes/specials/SpecialCentralAuth.php 
b/includes/specials/SpecialCentralAuth.php
index 48b6150..e055cbd 100644
--- a/includes/specials/SpecialCentralAuth.php
+++ b/includes/specials/SpecialCentralAuth.php
@@ -653,6 +653,7 @@
                // "temporary" indication applies to both groups, or just the 
last one
                $listTemporary = [];
                $list = [];
+               /** @var UserGroupMembership $ugm */
                foreach ( $row['groupMemberships'] as $group => $ugm ) {
                        if ( $ugm->getExpiry() ) {
                                $listTemporary[] = $this->msg( 
'centralauth-admin-group-temporary',
diff --git a/includes/specials/SpecialCentralAutoLogin.php 
b/includes/specials/SpecialCentralAutoLogin.php
index 6b93784..ba49a57 100644
--- a/includes/specials/SpecialCentralAutoLogin.php
+++ b/includes/specials/SpecialCentralAutoLogin.php
@@ -1,5 +1,6 @@
 <?php
 
+use MediaWiki\Session\Session;
 use Wikimedia\ScopedCallback;
 
 /**
@@ -10,7 +11,7 @@
 class SpecialCentralAutoLogin extends UnlistedSpecialPage {
        private $loginWiki;
 
-       /** @var MediaWiki\\Session\\Session|null */
+       /** @var Session|null */
        protected $session = null;
 
        public function __construct() {
diff --git a/includes/specials/SpecialCentralLogin.php 
b/includes/specials/SpecialCentralLogin.php
index c2aedda..b25b110 100644
--- a/includes/specials/SpecialCentralLogin.php
+++ b/includes/specials/SpecialCentralLogin.php
@@ -1,11 +1,12 @@
 <?php
 
 use MediaWiki\MediaWikiServices;
+use MediaWiki\Session\Session;
 use Wikimedia\ScopedCallback;
 
 class SpecialCentralLogin extends UnlistedSpecialPage {
 
-       /** @var MediaWiki\\Session\\Session */
+       /** @var Session */
        protected $session = null;
 
        public function __construct() {
diff --git a/includes/specials/SpecialGlobalRenameQueue.php 
b/includes/specials/SpecialGlobalRenameQueue.php
index bf05d5a..78b8ad7 100644
--- a/includes/specials/SpecialGlobalRenameQueue.php
+++ b/includes/specials/SpecialGlobalRenameQueue.php
@@ -689,17 +689,17 @@
 class RenameQueueTablePager extends TablePager {
 
        /**
-        * @var SpecialPage $mOwner
+        * @var SpecialPage
         */
        protected $mOwner;
 
        /**
-        * @var string $mPage
+        * @var string
         */
        protected $mPage;
 
        /**
-        * @var mFieldNames array
+        * @var string[]|null
         */
        protected $mFieldNames;
 
@@ -892,7 +892,7 @@
        }
 
        /**
-        * @return array
+        * @return string[]
         */
        public function getFieldNames() {
                if ( $this->mFieldNames === null ) {
diff --git a/maintenance/forceRenameUsers.php b/maintenance/forceRenameUsers.php
index c9c9805..c4bd143 100644
--- a/maintenance/forceRenameUsers.php
+++ b/maintenance/forceRenameUsers.php
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\Rdbms\IDatabase;
+
 $IP = getenv( 'MW_INSTALL_PATH' );
 if ( $IP === false ) {
        $IP = __DIR__ . '/../../..';
diff --git a/maintenance/populateListOfUsersToRename.php 
b/maintenance/populateListOfUsersToRename.php
index adf78ba..96244c0 100644
--- a/maintenance/populateListOfUsersToRename.php
+++ b/maintenance/populateListOfUsersToRename.php
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\Rdbms\ResultWrapper;
+
 $IP = getenv( 'MW_INSTALL_PATH' );
 if ( $IP === false ) {
        $IP = __DIR__ . '/../../..';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie053a03556c253fa2796b04d83050adfcdbb31d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CentralAuth
Gerrit-Branch: master
Gerrit-Owner: Thiemo Kreuz (WMDE) <thiemo.kr...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to