From bac2f3f64dfa4fb4378a244eef8d01e88b365af5 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Fri, 16 Dec 2022 11:25:32 +0100 Subject: [PATCH] auth: Replace FQNs with imports Change-Id: If77151460187f304beb7e842b0347f4ba715987e --- includes/auth/AuthenticationRequest.php | 14 ++++++++------ includes/auth/PasswordAuthenticationRequest.php | 4 +++- .../auth/PasswordDomainAuthenticationRequest.php | 4 +++- .../TemporaryPasswordAuthenticationRequest.php | 6 ++++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/includes/auth/AuthenticationRequest.php b/includes/auth/AuthenticationRequest.php index 57f527d5b81..bfb5517113d 100644 --- a/includes/auth/AuthenticationRequest.php +++ b/includes/auth/AuthenticationRequest.php @@ -23,7 +23,9 @@ namespace MediaWiki\Auth; +use MediaWiki\Language\RawMessage; use Message; +use UnexpectedValueException; /** * This is a value object for authentication requests. @@ -235,8 +237,8 @@ abstract class AuthenticationRequest { */ public function describeCredentials() { return [ - 'provider' => new \MediaWiki\Language\RawMessage( '$1', [ get_called_class() ] ), - 'account' => new \MediaWiki\Language\RawMessage( '$1', [ $this->getUniqueId() ] ), + 'provider' => new RawMessage( '$1', [ get_called_class() ] ), + 'account' => new RawMessage( '$1', [ $this->getUniqueId() ] ), ]; } @@ -289,7 +291,7 @@ abstract class AuthenticationRequest { * * @param AuthenticationRequest[] $reqs * @return string|null - * @throws \UnexpectedValueException If multiple different usernames are present. + * @throws UnexpectedValueException If multiple different usernames are present. */ public static function getUsernameFromRequests( array $reqs ) { $username = null; @@ -302,7 +304,7 @@ abstract class AuthenticationRequest { $otherClass = get_class( $req ); } elseif ( $username !== $req->username ) { $requestClass = get_class( $req ); - throw new \UnexpectedValueException( "Conflicting username fields: \"{$req->username}\" from " + throw new UnexpectedValueException( "Conflicting username fields: \"{$req->username}\" from " // @phan-suppress-next-line PhanTypeSuspiciousStringExpression $otherClass always set . "$requestClass::\$username vs. \"$username\" from $otherClass::\$username" ); } @@ -315,7 +317,7 @@ abstract class AuthenticationRequest { * Merge the output of multiple AuthenticationRequest::getFieldInfo() calls. * @param AuthenticationRequest[] $reqs * @return array - * @throws \UnexpectedValueException If fields cannot be merged + * @throws UnexpectedValueException If fields cannot be merged */ public static function mergeFieldInfo( array $reqs ) { $merged = []; @@ -366,7 +368,7 @@ abstract class AuthenticationRequest { if ( !array_key_exists( $name, $merged ) ) { $merged[$name] = $options; } elseif ( $merged[$name]['type'] !== $type ) { - throw new \UnexpectedValueException( "Field type conflict for \"$name\", " . + throw new UnexpectedValueException( "Field type conflict for \"$name\", " . "\"{$merged[$name]['type']}\" vs \"$type\"" ); } else { diff --git a/includes/auth/PasswordAuthenticationRequest.php b/includes/auth/PasswordAuthenticationRequest.php index f8c3573102e..957c9511173 100644 --- a/includes/auth/PasswordAuthenticationRequest.php +++ b/includes/auth/PasswordAuthenticationRequest.php @@ -21,6 +21,8 @@ namespace MediaWiki\Auth; +use MediaWiki\Language\RawMessage; + /** * This is a value object for authentication requests with a username and password * @stable to extend @@ -88,7 +90,7 @@ class PasswordAuthenticationRequest extends AuthenticationRequest { public function describeCredentials() { return [ 'provider' => wfMessage( 'authmanager-provider-password' ), - 'account' => new \MediaWiki\Language\RawMessage( '$1', [ $this->username ] ), + 'account' => new RawMessage( '$1', [ $this->username ] ), ]; } } diff --git a/includes/auth/PasswordDomainAuthenticationRequest.php b/includes/auth/PasswordDomainAuthenticationRequest.php index 9886efe28eb..3ee153c64a5 100644 --- a/includes/auth/PasswordDomainAuthenticationRequest.php +++ b/includes/auth/PasswordDomainAuthenticationRequest.php @@ -21,6 +21,8 @@ namespace MediaWiki\Auth; +use MediaWiki\Language\RawMessage; + /** * This is a value object for authentication requests with a username, password, and domain * @stable to extend @@ -58,7 +60,7 @@ class PasswordDomainAuthenticationRequest extends PasswordAuthenticationRequest 'help' => wfMessage( 'authmanager-domain-help' ), ]; foreach ( $this->domainList as $domain ) { - $ret['domain']['options'][$domain] = new \MediaWiki\Language\RawMessage( '$1', [ $domain ] ); + $ret['domain']['options'][$domain] = new RawMessage( '$1', [ $domain ] ); } } diff --git a/includes/auth/TemporaryPasswordAuthenticationRequest.php b/includes/auth/TemporaryPasswordAuthenticationRequest.php index a8bfd9cd6d9..dccae66fef7 100644 --- a/includes/auth/TemporaryPasswordAuthenticationRequest.php +++ b/includes/auth/TemporaryPasswordAuthenticationRequest.php @@ -21,8 +21,10 @@ namespace MediaWiki\Auth; +use MediaWiki\Language\RawMessage; use MediaWiki\MainConfigNames; use MediaWiki\MediaWikiServices; +use PasswordFactory; /** * This represents the intention to set a temporary password for the user. @@ -81,7 +83,7 @@ class TemporaryPasswordAuthenticationRequest extends AuthenticationRequest { } } - $password = \PasswordFactory::generateRandomPasswordString( $minLength ); + $password = PasswordFactory::generateRandomPasswordString( $minLength ); return new self( $password ); } @@ -102,7 +104,7 @@ class TemporaryPasswordAuthenticationRequest extends AuthenticationRequest { public function describeCredentials() { return [ 'provider' => wfMessage( 'authmanager-provider-temporarypassword' ), - 'account' => new \MediaWiki\Language\RawMessage( '$1', [ $this->username ] ), + 'account' => new RawMessage( '$1', [ $this->username ] ), ] + parent::describeCredentials(); }