Passed
Push — master ( af240f...6f38a9 )
by Daimona
26:03 queued 09:04
created
includes/Task/Subtask/SimpleUpdates.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 
20 20
 		if ( !$pages ) {
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
 	 * @param PageRiconferma[] $pages
37 37
 	 * @see OpenUpdates::addToVotazioni()
38 38
 	 */
39
-	protected function updateVotazioni( array $pages ) : void {
39
+	protected function updateVotazioni ( array $pages ) : void {
40 40
 		$this->getLogger()->info(
41 41
 			'Updating votazioni: ' . implode( ', ', $pages )
42 42
 		);
43 43
 		$votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) );
44 44
 
45
-		$users = [];
45
+		$users = [ ];
46 46
 		foreach ( $pages as $page ) {
47
-			$users[] = $this->getUser( $page->getUserName() );
47
+			$users[ ] = $this->getUser( $page->getUserName() );
48 48
 		}
49 49
 		$usersReg = RegexUtils::regexFromArray( '!', ...$users );
50 50
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param PageRiconferma[] $pages
66 66
 	 * @see OpenUpdates::addToNews()
67 67
 	 */
68
-	protected function updateNews( array $pages ) : void {
68
+	protected function updateNews ( array $pages ) : void {
69 69
 		$simpleAmount = $voteAmount = 0;
70 70
 		foreach ( $pages as $page ) {
71 71
 			if ( $page->isVote() ) {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
86 86
 		$voteMatches = $newsPage->getMatch( $voteReg );
87 87
 
88
-		$newSimp = ( (int)$simpleMatches[2] - $simpleAmount ) ?: '';
89
-		$newVote = ( (int)$voteMatches[2] - $voteAmount ) ?: '';
88
+		$newSimp = ( (int)$simpleMatches[ 2 ] - $simpleAmount ) ?: '';
89
+		$newVote = ( (int)$voteMatches[ 2 ] - $voteAmount ) ?: '';
90 90
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() );
91 91
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
92 92
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @param bool[] $outcomes
106 106
 	 */
107
-	protected function updateAdminList( array $outcomes ) : void {
107
+	protected function updateAdminList ( array $outcomes ) : void {
108 108
 		$this->getLogger()->info( 'Updating admin list' );
109 109
 		$adminsPage = $this->getPage( $this->getOpt( 'admins-list-title' ) );
110 110
 		$newContent = $adminsPage->getContent();
111 111
 
112
-		$riconfNames = $removeNames = [];
112
+		$riconfNames = $removeNames = [ ];
113 113
 		foreach ( $outcomes as $username => $confirmed ) {
114 114
 			$user = $this->getUser( $username );
115 115
 			$userReg = $user->getRegex( '!' );
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 					'${1}{{subst:#timel:Ymd}}|' . $nextDate . '$2',
125 125
 					$newContent
126 126
 				);
127
-				$riconfNames[] = $username;
127
+				$riconfNames[ ] = $username;
128 128
 			} else {
129 129
 				$newContent = preg_replace( $reg, '', $newContent );
130
-				$removeNames[] = $username;
130
+				$removeNames[ ] = $username;
131 131
 			}
132 132
 		}
133 133
 
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
 	/**
148 148
 	 * @param bool[] $outcomes
149 149
 	 */
150
-	protected function updateCUList( array $outcomes ) : void {
150
+	protected function updateCUList ( array $outcomes ) : void {
151 151
 		$this->getLogger()->info( 'Updating CU list.' );
152 152
 		$cuList = $this->getPage( $this->getOpt( 'cu-list-title' ) );
153 153
 		$newContent = $cuList->getContent();
154 154
 
155
-		$riconfNames = $removeNames = [];
155
+		$riconfNames = $removeNames = [ ];
156 156
 		foreach ( $outcomes as $user => $confirmed ) {
157 157
 			$userReg = $this->getUser( $user )->getRegex( '!' );
158 158
 			$reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
159 159
 			if ( $confirmed ) {
160 160
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent );
161
-				$riconfNames[] = $user;
161
+				$riconfNames[ ] = $user;
162 162
 			} else {
163 163
 				$newContent = preg_replace( $reg, '', $newContent );
164
-				$removeNames[] = $user;
164
+				$removeNames[ ] = $user;
165 165
 			}
166 166
 		}
167 167
 
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	 * @param PageRiconferma[] $pages
186 186
 	 * @return bool[]
187 187
 	 */
188
-	private function getGroupOutcomes( string $group, array $pages ) : array {
189
-		$ret = [];
188
+	private function getGroupOutcomes ( string $group, array $pages ) : array {
189
+		$ret = [ ];
190 190
 		foreach ( $pages as $page ) {
191 191
 			$user = $this->getUser( $page->getUserName() );
192 192
 			if ( $user->inGroup( $group ) ) {
Please login to merge, or discard this patch.
includes/Request/RequestBase.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Request;
4 4
 
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/** @var string */
40 40
 	protected $method = self::METHOD_GET;
41 41
 	/** @var string[] */
42
-	protected $newCookies = [];
42
+	protected $newCookies = [ ];
43 43
 
44 44
 	/**
45 45
 	 * @private Use RequestFactory
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @phan-param array<int|string|bool> $params
49 49
 	 * @param string $domain
50 50
 	 */
51
-	public function __construct( array $params, string $domain ) {
51
+	public function __construct ( array $params, string $domain ) {
52 52
 		$this->params = [ 'format' => 'json' ] + $params;
53 53
 		$this->url = $domain;
54 54
 	}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return self For chaining
60 60
 	 */
61
-	public function setPost() : self {
61
+	public function setPost () : self {
62 62
 		$this->method = self::METHOD_POST;
63 63
 		return $this;
64 64
 	}
@@ -67,12 +67,12 @@  discard block
 block discarded – undo
67 67
 	 * Execute a query request
68 68
 	 * @return Generator
69 69
 	 */
70
-	public function executeAsQuery() : Generator {
71
-		if ( ( $this->params['action'] ?? false ) !== 'query' ) {
70
+	public function executeAsQuery () : Generator {
71
+		if ( ( $this->params[ 'action' ] ?? false ) !== 'query' ) {
72 72
 			throw new BadMethodCallException( 'Not an ApiQuery!' );
73 73
 		}
74 74
 		// TODO Is this always correct?
75
-		$key = $this->params['list'] ?? 'pages';
75
+		$key = $this->params[ 'list' ] ?? 'pages';
76 76
 		$curParams = $this->params;
77 77
 		$lim = $this->parseLimit();
78 78
 		do {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * Execute a request that doesn't need any continuation.
102 102
 	 * @return stdClass
103 103
 	 */
104
-	public function executeSingle() : stdClass {
104
+	public function executeSingle () : stdClass {
105 105
 		$curParams = $this->params;
106 106
 		$res = $this->makeRequestInternal( $curParams );
107 107
 		$this->handleErrorAndWarnings( $res );
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	/**
112 112
 	 * @return int
113 113
 	 */
114
-	private function parseLimit() : int {
114
+	private function parseLimit () : int {
115 115
 		foreach ( $this->params as $name => $val ) {
116 116
 			if ( substr( $name, -strlen( 'limit' ) ) === 'limit' ) {
117 117
 				return $val === 'max' ? -1 : (int)$val;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $resKey
129 129
 	 * @return int|null
130 130
 	 */
131
-	private function countQueryResults( stdClass $res, string $resKey ) : ?int {
131
+	private function countQueryResults ( stdClass $res, string $resKey ) : ?int {
132 132
 		if ( !isset( $res->query->$resKey ) ) {
133 133
 			return null;
134 134
 		}
@@ -156,9 +156,9 @@  discard block
 block discarded – undo
156 156
 	 * @phan-param array<int|string|bool> $params
157 157
 	 * @return stdClass
158 158
 	 */
159
-	private function makeRequestInternal( array $params ) : stdClass {
159
+	private function makeRequestInternal ( array $params ) : stdClass {
160 160
 		if ( $this->method === self::METHOD_POST ) {
161
-			$params['maxlag'] = self::MAXLAG;
161
+			$params[ 'maxlag' ] = self::MAXLAG;
162 162
 		}
163 163
 		$query = http_build_query( $params );
164 164
 
@@ -174,17 +174,17 @@  discard block
 block discarded – undo
174 174
 	 * @param string $params
175 175
 	 * @return string
176 176
 	 */
177
-	abstract protected function reallyMakeRequest( string $params ) : string;
177
+	abstract protected function reallyMakeRequest ( string $params ) : string;
178 178
 
179 179
 	/**
180 180
 	 * After a request, set cookies for the next ones
181 181
 	 *
182 182
 	 * @param string[] $cookies
183 183
 	 */
184
-	protected function setCookies( array $cookies ) : void {
184
+	protected function setCookies ( array $cookies ) : void {
185 185
 		foreach ( $cookies as $cookie ) {
186 186
 			$bits = explode( ';', $cookie );
187
-			[ $name, $value ] = explode( '=', $bits[0] );
187
+			[ $name, $value ] = explode( '=', $bits[ 0 ] );
188 188
 			self::$cookiesToSet[ $name ] = $value;
189 189
 		}
190 190
 	}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @param stdClass $res
196 196
 	 * @return APIRequestException
197 197
 	 */
198
-	private function getException( stdClass $res ) : APIRequestException {
198
+	private function getException ( stdClass $res ) : APIRequestException {
199 199
 		switch ( $res->error->code ) {
200 200
 			case 'missingtitle':
201 201
 				$ex = new MissingPageException;
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 * @param stdClass $res
222 222
 	 * @throws APIRequestException
223 223
 	 */
224
-	protected function handleErrorAndWarnings( stdClass $res ) : void {
224
+	protected function handleErrorAndWarnings ( stdClass $res ) : void {
225 225
 		if ( isset( $res->error ) ) {
226 226
 			throw $this->getException( $res );
227 227
 		}
@@ -237,14 +237,14 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @return string[]
239 239
 	 */
240
-	protected function getHeaders() : array {
240
+	protected function getHeaders () : array {
241 241
 		$ret = self::HEADERS;
242 242
 		if ( self::$cookiesToSet ) {
243
-			$cookies = [];
243
+			$cookies = [ ];
244 244
 			foreach ( self::$cookiesToSet as $cname => $cval ) {
245
-				$cookies[] = trim( "$cname=$cval" );
245
+				$cookies[ ] = trim( "$cname=$cval" );
246 246
 			}
247
-			$ret[] = 'Cookie: ' . implode( '; ', $cookies );
247
+			$ret[ ] = 'Cookie: ' . implode( '; ', $cookies );
248 248
 		}
249 249
 		return $ret;
250 250
 	}
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 * @param string[] $headers
256 256
 	 * @return string
257 257
 	 */
258
-	protected function buildHeadersString( array $headers ) : string {
258
+	protected function buildHeadersString ( array $headers ) : string {
259 259
 		$ret = '';
260 260
 		foreach ( $headers as $header ) {
261 261
 			$ret .= "$header\r\n";
Please login to merge, or discard this patch.
includes/Request/RequestFactory.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Request;
4 4
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * @param string $domain
11 11
 	 */
12
-	public function __construct( string $domain ) {
12
+	public function __construct ( string $domain ) {
13 13
 		$this->domain = $domain;
14 14
 	}
15 15
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @phan-param array<int|string|bool> $params
19 19
 	 * @return RequestBase
20 20
 	 */
21
-	public function newFromParams( array $params ) : RequestBase {
21
+	public function newFromParams ( array $params ) : RequestBase {
22 22
 		if ( extension_loaded( 'curl' ) ) {
23 23
 			$ret = new CurlRequest( $params, $this->domain );
24 24
 		} else {
Please login to merge, or discard this patch.
includes/CLI.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	/**
66 66
 	 * @return bool
67 67
 	 */
68
-	public static function isCLI() : bool {
68
+	public static function isCLI () : bool {
69 69
 		return PHP_SAPI === 'cli';
70 70
 	}
71 71
 
72 72
 	/**
73 73
 	 * Populate options and check for required ones
74 74
 	 */
75
-	public function __construct() {
75
+	public function __construct () {
76 76
 		$opts = getopt( self::SHORT_OPTS, self::LONG_OPTS );
77 77
 		$this->checkRequiredOpts( $opts );
78 78
 		$this->checkConflictingOpts( $opts );
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	/**
84 84
 	 * @param string[] $opts
85 85
 	 */
86
-	private function checkRequiredOpts( array $opts ) : void {
86
+	private function checkRequiredOpts ( array $opts ) : void {
87 87
 		$missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) );
88 88
 		if ( $missingOpts ) {
89 89
 			$this->fatal( 'Required options missing: ' . implode( ', ', $missingOpts ) );
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * @param string[] $opts
107 107
 	 */
108
-	private function checkConflictingOpts( array $opts ) : void {
108
+	private function checkConflictingOpts ( array $opts ) : void {
109 109
 		$this->checkNotBothSet( $opts, 'password', 'use-password-file' );
110 110
 		if ( array_key_exists( 'use-password-file', $opts ) && !file_exists( self::PASSWORD_FILE ) ) {
111 111
 			$this->fatal( 'Please create the password file (' . self::PASSWORD_FILE . ')' );
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param string $first
127 127
 	 * @param string $second
128 128
 	 */
129
-	private function checkNotBothSet( array $opts, string $first, string $second ) : void {
129
+	private function checkNotBothSet ( array $opts, string $first, string $second ) : void {
130 130
 		if ( array_key_exists( $first, $opts ) && array_key_exists( $second, $opts ) ) {
131 131
 			$this->fatal( "Can only use one of '$first' and '$second'" );
132 132
 		}
@@ -135,23 +135,23 @@  discard block
 block discarded – undo
135 135
 	/**
136 136
 	 * @param string[] &$opts
137 137
 	 */
138
-	private function canonicalize( array &$opts ) : void {
138
+	private function canonicalize ( array &$opts ) : void {
139 139
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
140 140
 			$pw = trim( file_get_contents( self::PASSWORD_FILE ) );
141
-			$opts['password'] = $pw;
142
-			unset( $opts['use-password-file'] );
141
+			$opts[ 'password' ] = $pw;
142
+			unset( $opts[ 'use-password-file' ] );
143 143
 		}
144 144
 		if ( array_key_exists( 'use-private-password-file', $opts ) ) {
145 145
 			$pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) );
146
-			$opts['private-password'] = $pw;
147
-			unset( $opts['use-private-password-file'] );
146
+			$opts[ 'private-password' ] = $pw;
147
+			unset( $opts[ 'use-private-password-file' ] );
148 148
 		}
149 149
 	}
150 150
 
151 151
 	/**
152 152
 	 * @param string $msg
153 153
 	 */
154
-	private function fatal( string $msg ) : void {
154
+	private function fatal ( string $msg ) : void {
155 155
 		exit( $msg . "\n" );
156 156
 	}
157 157
 
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
 	 * @param mixed|null $default
161 161
 	 * @return mixed
162 162
 	 */
163
-	public function getOpt( string $opt, $default = null ) {
164
-		return $this->opts[$opt] ?? $default;
163
+	public function getOpt ( string $opt, $default = null ) {
164
+		return $this->opts[ $opt ] ?? $default;
165 165
 	}
166 166
 
167 167
 	/**
168 168
 	 * @return string[] Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ]
169 169
 	 */
170
-	public function getTaskOpt() : array {
170
+	public function getTaskOpt () : array {
171 171
 		return array_intersect_key(
172 172
 			$this->opts,
173 173
 			[ 'task' => true, 'subtask' => true ]
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 	/**
178 178
 	 * @return string|null
179 179
 	 */
180
-	public function getURL() : ?string {
180
+	public function getURL () : ?string {
181 181
 		return $this->getOpt( 'force-url' );
182 182
 	}
183 183
 }
Please login to merge, or discard this patch.
includes/Config.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	/** @var self */
12 12
 	private static $instance;
13 13
 	/** @var string[] */
14
-	private $opts = [];
14
+	private $opts = [ ];
15 15
 
16 16
 	/**
17 17
 	 * Use self::init() and self::getInstance()
18 18
 	 */
19
-	private function __construct() {
19
+	private function __construct () {
20 20
 	}
21 21
 
22 22
 	/**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param string[] $confValues
26 26
 	 * @throws ConfigException
27 27
 	 */
28
-	public static function init( array $confValues ) : void {
28
+	public static function init ( array $confValues ) : void {
29 29
 		if ( self::$instance ) {
30 30
 			throw new ConfigException( 'Config was already initialized' );
31 31
 		}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param string $key
45 45
 	 * @param mixed $value
46 46
 	 */
47
-	protected function set( string $key, $value ) : void {
47
+	protected function set ( string $key, $value ) : void {
48 48
 		$this->opts[ $key ] = $value;
49 49
 	}
50 50
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @return self
55 55
 	 * @throws ConfigException
56 56
 	 */
57
-	public static function getInstance() : self {
57
+	public static function getInstance () : self {
58 58
 		if ( !self::$instance ) {
59 59
 			throw new ConfigException( 'Config not yet initialized' );
60 60
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return mixed
69 69
 	 * @throws ConfigException
70 70
 	 */
71
-	public function get( string $opt ) {
71
+	public function get ( string $opt ) {
72 72
 		if ( !isset( $this->opts[ $opt ] ) ) {
73 73
 			throw new ConfigException( "Config option '$opt' not set." );
74 74
 		}
Please login to merge, or discard this patch.
includes/Task/UpdateList.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task;
4 4
 
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
 	/**
23 23
 	 * @inheritDoc
24 24
 	 */
25
-	protected function getSubtasksMap(): array {
25
+	protected function getSubtasksMap (): array {
26 26
 		// Everything is done here.
27
-		return [];
27
+		return [ ];
28 28
 	}
29 29
 
30 30
 	/**
31 31
 	 * @inheritDoc
32 32
 	 */
33
-	public function runInternal() : int {
33
+	public function runInternal () : int {
34 34
 		$this->actualList = $this->getActualAdmins();
35 35
 		$pageBotList = $this->getBotList();
36 36
 		$this->botList = $pageBotList->getDecodedContent();
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @return string[][]
59 59
 	 * @phan-return array<string,string[]>
60 60
 	 */
61
-	protected function getActualAdmins() : array {
61
+	protected function getActualAdmins () : array {
62 62
 		$params = [
63 63
 			'action' => 'query',
64 64
 			'list' => 'allusers',
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @return string[][]
77 77
 	 * @phan-return array<string,string[]>
78 78
 	 */
79
-	protected function extractAdmins( Generator $data ) : array {
80
-		$ret = [];
79
+	protected function extractAdmins ( Generator $data ) : array {
80
+		$ret = [ ];
81 81
 		$blacklist = $this->getOpt( 'exclude-admins' );
82 82
 		foreach ( $data as $u ) {
83 83
 			if ( in_array( $u->name, $blacklist, true ) ) {
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @return string[][]
96 96
 	 */
97
-	protected function getMissingGroups() : array {
98
-		$missing = [];
97
+	protected function getMissingGroups () : array {
98
+		$missing = [ ];
99 99
 		foreach ( $this->actualList as $adm => $groups ) {
100
-			$curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) );
100
+			$curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) );
101 101
 
102 102
 			foreach ( $curMissing as $group ) {
103 103
 				try {
104 104
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
105 105
 				} catch ( TaskException $e ) {
106
-					$this->errors[] = $e->getMessage();
106
+					$this->errors[ ] = $e->getMessage();
107 107
 				}
108 108
 			}
109 109
 		}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @return string
119 119
 	 * @throws TaskException
120 120
 	 */
121
-	protected function getFlagDate( string $admin, string $group ) : string {
121
+	protected function getFlagDate ( string $admin, string $group ) : string {
122 122
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
123 123
 
124 124
 		$wiki = $this->getWiki();
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param string $group
154 154
 	 * @return string|null
155 155
 	 */
156
-	private function extractTimestamp( Generator $data, string $group ) : ?string {
156
+	private function extractTimestamp ( Generator $data, string $group ) : ?string {
157 157
 		$ts = null;
158 158
 		foreach ( $data as $entry ) {
159 159
 			if (
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string[][]
174 174
 	 */
175
-	protected function getExtraGroups() : array {
176
-		$extra = [];
175
+	protected function getExtraGroups () : array {
176
+		$extra = [ ];
177 177
 		foreach ( $this->botList as $name => $groups ) {
178 178
 			$groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) );
179 179
 			if ( !isset( $this->actualList[ $name ] ) ) {
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param string[] $names
190 190
 	 * @return Generator
191 191
 	 */
192
-	private function getRenameEntries( array $names ) : Generator {
192
+	private function getRenameEntries ( array $names ) : Generator {
193 193
 		$titles = array_map( static function ( string $x ) : string {
194 194
 			return "Utente:$x";
195 195
 		}, $names );
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
 	 * @param string[] $names
214 214
 	 * @return string[] [ old_name => new_name ]
215 215
 	 */
216
-	protected function getRenamedUsers( array $names ) : array {
216
+	protected function getRenamedUsers ( array $names ) : array {
217 217
 		if ( !$names ) {
218
-			return [];
218
+			return [ ];
219 219
 		}
220 220
 		$this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) );
221 221
 
222 222
 		$data = $this->getRenameEntries( $names );
223
-		$ret = [];
223
+		$ret = [ ];
224 224
 		foreach ( $data as $entry ) {
225 225
 			// 1 month is arbitrary
226 226
 			if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) {
@@ -239,18 +239,18 @@  discard block
 block discarded – undo
239 239
 	 * @phan-param array<string,array<string,string|string[]>> $newContent
240 240
 	 * @param string[][] $removed
241 241
 	 */
242
-	private function handleRenames( array &$newContent, array $removed ) : void {
242
+	private function handleRenames ( array &$newContent, array $removed ) : void {
243 243
 		$renameMap = $this->getRenamedUsers( array_keys( $removed ) );
244 244
 		foreach ( $removed as $oldName => $info ) {
245 245
 			if (
246 246
 				array_key_exists( $oldName, $renameMap ) &&
247
-				array_key_exists( $renameMap[$oldName], $newContent )
247
+				array_key_exists( $renameMap[ $oldName ], $newContent )
248 248
 			) {
249 249
 				// This user was renamed! Add this name as alias, if they're still listed
250 250
 				$newName = $renameMap[ $oldName ];
251 251
 				$this->getLogger()->info( "Found rename $oldName -> $newName" );
252
-				$aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) );
253
-				$newContent[ $newName ]['aliases'] = $aliases;
252
+				$aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) );
253
+				$newContent[ $newName ][ 'aliases' ] = $aliases;
254 254
 				// Transfer overrides to the new name.
255 255
 				$overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] );
256 256
 				$newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides );
@@ -265,12 +265,12 @@  discard block
 block discarded – undo
265 265
 	 * @param string[][] $extra
266 266
 	 * @return string[][] Removed users
267 267
 	 */
268
-	private function handleExtraAndMissing(
268
+	private function handleExtraAndMissing (
269 269
 		array &$newContent,
270 270
 		array $missing,
271 271
 		array $extra
272 272
 	) : array {
273
-		$removed = [];
273
+		$removed = [ ];
274 274
 		foreach ( $newContent as $user => $groups ) {
275 275
 			if ( isset( $missing[ $user ] ) ) {
276 276
 				$newContent[ $user ] = array_merge( $groups, $missing[ $user ] );
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 				if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) {
281 281
 					$newContent[ $user ] = $newGroups;
282 282
 				} else {
283
-					$removed[$user] = $newContent[$user];
283
+					$removed[ $user ] = $newContent[ $user ];
284 284
 					unset( $newContent[ $user ] );
285 285
 				}
286 286
 			}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @param string[][] $extra
298 298
 	 * @return array[]
299 299
 	 */
300
-	protected function getNewContent( array $missing, array $extra ) : array {
300
+	protected function getNewContent ( array $missing, array $extra ) : array {
301 301
 		$newContent = $this->botList;
302 302
 
303 303
 		$removed = $this->handleExtraAndMissing( $newContent, $missing, $extra );
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @param array[] &$newContent
318 318
 	 */
319
-	protected function removeOverrides( array &$newContent ) : void {
320
-		$removed = [];
319
+	protected function removeOverrides ( array &$newContent ) : void {
320
+		$removed = [ ];
321 321
 		foreach ( $newContent as $user => $groups ) {
322 322
 			if ( PageBotList::isOverrideExpired( $groups ) ) {
323 323
 				unset( $newContent[ $user ][ 'override' ] );
324
-				$removed[] = $user;
324
+				$removed[ ] = $user;
325 325
 			}
326 326
 		}
327 327
 
Please login to merge, or discard this patch.
includes/Message/Message.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Message;
4 4
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @param string $value
25 25
 	 */
26
-	public function __construct( string $value ) {
26
+	public function __construct ( string $value ) {
27 27
 		$this->value = $value;
28 28
 	}
29 29
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @phan-param array<string,int|string> $args
33 33
 	 * @return self
34 34
 	 */
35
-	public function params( array $args ) : self {
35
+	public function params ( array $args ) : self {
36 36
 		$this->value = strtr( $this->value, $args );
37 37
 		return $this;
38 38
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * @return string
42 42
 	 */
43
-	public function text() : string {
43
+	public function text () : string {
44 44
 		$this->parsePlurals();
45 45
 		return $this->value;
46 46
 	}
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	/**
49 49
 	 * Replace {{$plur|<amount>|sing|plur}}
50 50
 	 */
51
-	protected function parsePlurals() : void {
51
+	protected function parsePlurals () : void {
52 52
 		$reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!';
53 53
 
54 54
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 			 * @return string
62 62
 			 */
63 63
 			static function ( array $matches ) : string {
64
-				return (int)$matches['amount'] > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
64
+				return (int)$matches[ 'amount' ] > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
65 65
 			},
66 66
 			$this->value
67 67
 		);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $timeString Full format, e.g. "15 aprile 2019 18:27"
74 74
 	 * @return int
75 75
 	 */
76
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
76
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
77 77
 		$englishTime = str_ireplace(
78 78
 			array_values( self::MONTHS ),
79 79
 			array_keys( self::MONTHS ),
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 * @param string $emptyText
93 93
 	 * @return string
94 94
 	 */
95
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
95
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
96 96
 		if ( count( $data ) > 1 ) {
97 97
 			$last = array_pop( $data );
98 98
 			$ret = implode( ', ', $data ) . " e $last";
99 99
 		} elseif ( $data ) {
100
-			$ret = (string)$data[0];
100
+			$ret = (string)$data[ 0 ];
101 101
 		} else {
102 102
 			$ret = $emptyText;
103 103
 		}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		return $ret;
106 106
 	}
107 107
 
108
-	public function __toString() {
108
+	public function __toString () {
109 109
 		return $this->text();
110 110
 	}
111 111
 }
Please login to merge, or discard this patch.