Florianschmidtwelzow has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/360679 )
Change subject: Enable some phpcs rules ...................................................................... Enable some phpcs rules The following rules are now enabled and the code is fixed accordingly: * MediaWiki.Commenting.FunctionComment.MissingParamComment * MediaWiki.Commenting.FunctionComment.MissingParamName * MediaWiki.Commenting.FunctionComment.MissingParamTag * MediaWiki.Commenting.FunctionComment.MissingReturn * MediaWiki.Commenting.FunctionComment.ParamNameNoMatch * MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment Change-Id: I957412e6bfec60fa9064701cc3020c8e88fe7b17 --- M includes/GoogleLogin.body.php M includes/GoogleLogin.hooks.php M includes/GoogleUser.php M includes/alloweddomains/AllowedDomainsStore.php M includes/alloweddomains/EmailDomain.php M includes/alloweddomains/MutableAllowedDomainsStore.php M phpcs.xml 7 files changed, 47 insertions(+), 40 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GoogleLogin refs/changes/79/360679/1 diff --git a/includes/GoogleLogin.body.php b/includes/GoogleLogin.body.php index 2e918cf..d243fa0 100755 --- a/includes/GoogleLogin.body.php +++ b/includes/GoogleLogin.body.php @@ -6,19 +6,19 @@ use Google_Client; use GoogleLogin\AllowedDomains\AllowedDomainsStore; -use GoogleLogin\AllowedDomains\CachedAllowedDomainsStore; use GoogleLogin\AllowedDomains\EmailDomain; -use GoogleLogin\AllowedDomains\MutableAllowedDomainsStore; use MediaWiki\MediaWikiServices; class GoogleLogin { - /** @var $mGoogleClient Stores an instance of GoogleClient */ + /** @var Google_Client $mGoogleClient Stores an instance of GoogleClient */ private static $mGoogleClient; - /** @var $mConfig Config object created for GoogleLogin extension */ + /** @var $mConfig \Config object created for GoogleLogin extension */ private static $mConfig; /** * Returns an prepared instance of Google client to do requests with to Google API + * @param string $returnToUrl The URL to set for the redirectURI + * @param string $token The token to set for the Goolge_Client state * @return Google_Client */ public static function getClient( $returnToUrl, $token ) { diff --git a/includes/GoogleLogin.hooks.php b/includes/GoogleLogin.hooks.php index 267107b..476b72a 100644 --- a/includes/GoogleLogin.hooks.php +++ b/includes/GoogleLogin.hooks.php @@ -48,9 +48,11 @@ } /** - * Handles Updates to the UserMergeAccountFields of the UserMerge extension. + * MergeAccountFromTo hook handler * - * @param array &$updateFields + * @param \User &$oldUser The user to "merge from" + * @param \User &$newUser The user to "merge to" + * @return bool */ public static function onMergeAccountFromTo( &$oldUser, &$newUser ) { // check, if @@ -58,9 +60,9 @@ // the new user exists (e.g. is not Anonymous) !$newUser->isAnon() && // the new user doesn't has a google connection already - !$newUser->hasConnectedGoogleAccount() && + !GoogleUser::hasConnectedGoogleAccount( $newUser ) && // the old user has a google connection - $oldUser->hasConnectedGoogleAccount() + GoogleUser::hasConnectedGoogleAccount( $oldUser ) ) { // save the google id of the old account $googleIds = GoogleUser::getGoogleIdFromUser( $oldUser ); @@ -79,7 +81,8 @@ * Handle, what data needs to be deleted from the GoogleLogin tables when a user is * deleted through the UserMerge extension. * - * @param array &$tablesToDelete + * @param array &$tablesToDelete Array of table => user_id_field to delete + * @return bool */ public static function onUserMergeAccountDeleteTables( &$tablesToDelete ) { $tablesToDelete['user_google_user'] = 'user_id'; @@ -91,10 +94,10 @@ * AuthChangeFormFields hook handler. Give the "Login with Google" button a larger * weight as the LocalPasswordAuthentication Log in button. * - * @param array $requests - * @param array $fieldInfo - * @param array $formDescriptor - * @param $action + * @param array $requests AuthenticationRequests for the current auth attempt + * @param array $fieldInfo Array of field information + * @param array &$formDescriptor Array of fields in a descriptor format + * @param string $action one of the AuthManager::ACTION_* constants. */ public static function onAuthChangeFormFields( array $requests, array $fieldInfo, array &$formDescriptor, $action @@ -114,9 +117,9 @@ /** * Add GoogleLogin management events to Echo * - * @param array $notifications Echo notifications - * @param array $notificationCategories Echo categories - * @param array $icons Echo icons + * @param array &$notifications Echo notifications + * @param array &$notificationCategories Echo categories + * @param array &$icons Echo icons * @return bool */ public static function onBeforeCreateEchoEvent( @@ -147,8 +150,8 @@ /** * Bundle GoogleLogin echo notifications if they're made from the same administrator. * - * @param \EchoEvent $event - * @param String $bundleString + * @param \EchoEvent $event The triggering event + * @param String &$bundleString The message of the bundle * @return boolean */ public static function onEchoGetBundleRules( \EchoEvent $event, &$bundleString ) { diff --git a/includes/GoogleUser.php b/includes/GoogleUser.php index d829eed..1bc13b5 100644 --- a/includes/GoogleUser.php +++ b/includes/GoogleUser.php @@ -23,7 +23,7 @@ * will start a request to the Google+ API to find out the information about * the person who owns the given Google ID. * - * @param $googleId The Google ID for the new GoogleUser object + * @param int $googleId The Google ID for the new GoogleUser object * @return GoogleUser */ public static function newFromGoogleId( $googleId ) { @@ -80,7 +80,7 @@ * Returns the requested user data of the person with the Google ID represented by this * GoogleUser object or null, if the data is not available. * - * @param $data The data to retrieve + * @param string $data The data to retrieve * @return null */ public function getData( $data ) { @@ -115,8 +115,8 @@ /** * Check, if the Google ID is already connected to another wiki account or not. * - * @param $id - * @param int $flags + * @param int $googleId The Google ID to check for + * @param int $flags A bit mask of flags, see User::READ_* * @return bool */ public static function isGoogleIdFree( $googleId, $flags = User::READ_LATEST ) { @@ -129,7 +129,7 @@ * * @param User $user The user to get the Google Id for * @param integer $flags User::READ_* constant bitfield - * @return bool False, if no Google ID connected with this User ID, true otherwise + * @return null|array An array of user IDs, null if an error occurred or no IDs was found */ public static function getGoogleIdFromUser( User $user, $flags = User::READ_LATEST ) { $db = ( $flags & User::READ_LATEST ) diff --git a/includes/alloweddomains/AllowedDomainsStore.php b/includes/alloweddomains/AllowedDomainsStore.php index d582d09..e385943 100644 --- a/includes/alloweddomains/AllowedDomainsStore.php +++ b/includes/alloweddomains/AllowedDomainsStore.php @@ -15,7 +15,8 @@ /** * Checks, if the given EmailDomain is allowed to be used for login or not. * - * @param EmailDomain $domain + * @param EmailDomain $domain The e-mail-address as an EmailDomain object to check if it is + * contained in the store. * @return boolean */ function contains( EmailDomain $domain ); diff --git a/includes/alloweddomains/EmailDomain.php b/includes/alloweddomains/EmailDomain.php index cd9c4fb..cf72db2 100644 --- a/includes/alloweddomains/EmailDomain.php +++ b/includes/alloweddomains/EmailDomain.php @@ -16,7 +16,7 @@ /** * EmailDomain constructor. * - * @param $mail String The whole e-mail address, which is represented by this object + * @param String $mail The whole e-mail address, which is represented by this object * @param bool $strict If the domain should be parsed strictly or not (e.g. * t...@test.example.com will be converted to example.com if this is false) */ @@ -66,10 +66,13 @@ // remove "/path/file.html", "/:80", etc. $domain = parse_url( $domain, PHP_URL_HOST ); // separate domain level - $lvl = explode( '.', $domain ); // 0 => www, 1 => example, 2 => co, 3 => uk + // 0 => www, 1 => example, 2 => co, 3 => uk + $lvl = explode( '.', $domain ); // set levels - krsort( $lvl ); // 3 => uk, 2 => co, 1 => example, 0 => www - $lvl = array_values( $lvl ); // 0 => uk, 1 => co, 2 => example, 3 => www + // 3 => uk, 2 => co, 1 => example, 0 => www + krsort( $lvl ); + // 0 => uk, 1 => co, 2 => example, 3 => www + $lvl = array_values( $lvl ); $_1st = $lvl[0]; $_2nd = isset( $lvl[1] ) ? $lvl[1] . '.' . $_1st : false; $_3rd = isset( $lvl[2] ) ? $lvl[2] . '.' . $_2nd : false; @@ -81,7 +84,8 @@ } require "$dir/cache/tld.txt"; $tlds = array_flip( $tlds ); - if ( // fourth level is TLD + // fourth level is TLD + if ( $_4th && !isset( $tlds[ '!' . $_4th ] ) && ( @@ -90,7 +94,8 @@ ) ) { $domain = isset( $lvl[4] ) ? $lvl[4] . '.' . $_4th : false; - } elseif ( // third level is TLD + // third level is TLD + } elseif ( $_3rd && !isset( $tlds[ '!' . $_3rd ] ) && ( @@ -99,7 +104,8 @@ ) ) { $domain = $_4th; - } elseif ( // second level is TLD + // second level is TLD + } elseif ( !isset( $tlds[ '!' . $_2nd ] ) && ( isset( $tlds[ $_2nd ] ) || @@ -107,7 +113,8 @@ ) ) { $domain = $_3rd; - } else { // first level is TLD + // first level is TLD + } else { $domain = $_2nd; } return $domain; diff --git a/includes/alloweddomains/MutableAllowedDomainsStore.php b/includes/alloweddomains/MutableAllowedDomainsStore.php index 1c5116f..10c8c01 100644 --- a/includes/alloweddomains/MutableAllowedDomainsStore.php +++ b/includes/alloweddomains/MutableAllowedDomainsStore.php @@ -13,7 +13,8 @@ /** * Adds the host of the given EmailDomain to the store. * - * @param EmailDomain $domain + * @param EmailDomain $domain The e-mail-address as an EmailDomain object to add as allowed + * to the store * @return integer The ID of the newly added entry (0 if IDs are not used, -1 on failure) */ function add( EmailDomain $domain ); @@ -23,7 +24,8 @@ * Will return true, when the domain is not present anymore (either not present before or * successfully deleted), false otheriwse. * - * @param EmailDomain $domain + * @param EmailDomain $domain The e-mail-address as an EmailDomain object to remove from the + * store. * @return boolean */ function remove( EmailDomain $domain ); diff --git a/phpcs.xml b/phpcs.xml index 1c8d485..6436b06 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,14 +1,8 @@ <?xml version="1.0"?> <ruleset> <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki"> - <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamComment" /> - <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamName" /> - <exclude name="MediaWiki.Commenting.FunctionComment.MissingParamTag" /> - <exclude name="MediaWiki.Commenting.FunctionComment.MissingReturn" /> - <exclude name="MediaWiki.Commenting.FunctionComment.ParamNameNoMatch" /> <exclude name="MediaWiki.FunctionComment.Missing.Protected" /> <exclude name="MediaWiki.FunctionComment.Missing.Public" /> - <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" /> </rule> <file>.</file> <arg name="extensions" value="php,php5,inc" /> -- To view, visit https://gerrit.wikimedia.org/r/360679 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I957412e6bfec60fa9064701cc3020c8e88fe7b17 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GoogleLogin Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits