Merge "UserFactory: Simplify and type hint newAnonymous"
This commit is contained in:
commit
48a3b2e7f8
1 changed files with 3 additions and 5 deletions
|
|
@ -109,14 +109,12 @@ class UserFactory implements IDBAccessObject, UserRigorOptions {
|
||||||
* @param string|null $ip IP address
|
* @param string|null $ip IP address
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
public function newAnonymous( $ip = null ): User {
|
public function newAnonymous( ?string $ip = null ): User {
|
||||||
if ( $ip ) {
|
if ( $ip ) {
|
||||||
$validIp = $this->userNameUtils->isIP( $ip );
|
if ( !$this->userNameUtils->isIP( $ip ) ) {
|
||||||
if ( $validIp ) {
|
|
||||||
$user = $this->newFromName( $ip, self::RIGOR_NONE );
|
|
||||||
} else {
|
|
||||||
throw new InvalidArgumentException( 'Invalid IP address' );
|
throw new InvalidArgumentException( 'Invalid IP address' );
|
||||||
}
|
}
|
||||||
|
$user = $this->newFromName( $ip, self::RIGOR_NONE );
|
||||||
} else {
|
} else {
|
||||||
$user = new User();
|
$user = new User();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue