Passed
Push — master ( bcff1e...74dea7 )
by Daimona
01:53
created
src/Task/UpdateList.php 1 patch
Spacing   +31 added lines, -31 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
 
@@ -23,15 +23,15 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	protected function getSubtasksMap(): array {
26
+	protected function getSubtasksMap (): array {
27 27
 		// Everything is done here.
28
-		return [];
28
+		return [ ];
29 29
 	}
30 30
 
31 31
 	/**
32 32
 	 * @inheritDoc
33 33
 	 */
34
-	public function runInternal(): int {
34
+	public function runInternal (): int {
35 35
 		$this->actualList = $this->getActualAdmins();
36 36
 		$pageBotList = $this->getBotList();
37 37
 		$this->botList = $pageBotList->getDecodedContent();
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * @return string[][]
60 60
 	 * @phan-return array<string,string[]>
61 61
 	 */
62
-	protected function getActualAdmins(): array {
62
+	protected function getActualAdmins (): array {
63 63
 		$params = [
64 64
 			'action' => 'query',
65 65
 			'list' => 'allusers',
@@ -77,8 +77,8 @@  discard block
 block discarded – undo
77 77
 	 * @return string[][]
78 78
 	 * @phan-return array<string,string[]>
79 79
 	 */
80
-	protected function extractAdmins( Generator $data ): array {
81
-		$ret = [];
80
+	protected function extractAdmins ( Generator $data ): array {
81
+		$ret = [ ];
82 82
 		$blacklist = $this->getOpt( 'exclude-admins' );
83 83
 		foreach ( $data as $u ) {
84 84
 			if ( in_array( $u->name, $blacklist, true ) ) {
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
 	 *
96 96
 	 * @return string[][]
97 97
 	 */
98
-	protected function getMissingGroups(): array {
99
-		$missing = [];
98
+	protected function getMissingGroups (): array {
99
+		$missing = [ ];
100 100
 		foreach ( $this->actualList as $admin => $data ) {
101
-			$missingProps = array_diff( $data, array_keys( $this->botList[$admin] ?? [] ) );
101
+			$missingProps = array_diff( $data, array_keys( $this->botList[ $admin ] ?? [ ] ) );
102 102
 			$missingGroups = array_diff( $missingProps, self::NON_GROUP_KEYS );
103 103
 
104 104
 			foreach ( $missingGroups as $group ) {
105 105
 				$ts = $this->getFlagDate( $admin, $group );
106 106
 				if ( $ts === null ) {
107
-					$aliases = $data['aliases'] ?? [];
107
+					$aliases = $data[ 'aliases' ] ?? [ ];
108 108
 					if ( $aliases ) {
109 109
 						$this->getLogger()->info( "No $group flag date for $admin, trying aliases" );
110 110
 						foreach ( $aliases as $alias ) {
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 						}
116 116
 					}
117 117
 					if ( $ts === null ) {
118
-						$this->errors[] = "$group flag date unavailable for $admin";
118
+						$this->errors[ ] = "$group flag date unavailable for $admin";
119 119
 						continue;
120 120
 					}
121 121
 				}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param string $group
133 133
 	 * @return string|null
134 134
 	 */
135
-	protected function getFlagDate( string $admin, string $group ): ?string {
135
+	protected function getFlagDate ( string $admin, string $group ): ?string {
136 136
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
137 137
 
138 138
 		$wiki = $this->getWiki();
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param string $group
164 164
 	 * @return string|null
165 165
 	 */
166
-	private function extractTimestamp( Generator $data, string $group ): ?string {
166
+	private function extractTimestamp ( Generator $data, string $group ): ?string {
167 167
 		$ts = null;
168 168
 		foreach ( $data as $entry ) {
169 169
 			if (
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 	 *
183 183
 	 * @return string[][]
184 184
 	 */
185
-	protected function getExtraGroups(): array {
186
-		$extra = [];
185
+	protected function getExtraGroups (): array {
186
+		$extra = [ ];
187 187
 		foreach ( $this->botList as $name => $groups ) {
188 188
 			$groups = array_diff_key( $groups, array_fill_keys( self::NON_GROUP_KEYS, 1 ) );
189 189
 			if ( !isset( $this->actualList[ $name ] ) ) {
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @param string[] $names
200 200
 	 * @return Generator
201 201
 	 */
202
-	private function getRenameEntries( array $names ): Generator {
202
+	private function getRenameEntries ( array $names ): Generator {
203 203
 		$titles = array_map( static function ( string $x ): string {
204 204
 			return "Utente:$x";
205 205
 		}, $names );
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 	 * @param string[] $names
224 224
 	 * @return string[] [ old_name => new_name ]
225 225
 	 */
226
-	protected function getRenamedUsers( array $names ): array {
226
+	protected function getRenamedUsers ( array $names ): array {
227 227
 		if ( !$names ) {
228
-			return [];
228
+			return [ ];
229 229
 		}
230 230
 		$this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) );
231 231
 
232 232
 		$data = $this->getRenameEntries( $names );
233
-		$ret = [];
233
+		$ret = [ ];
234 234
 		foreach ( $data as $entry ) {
235 235
 			// 1 month is arbitrary
236 236
 			if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) {
@@ -249,18 +249,18 @@  discard block
 block discarded – undo
249 249
 	 * @phan-param array<string,array<string,string|string[]>> $newContent
250 250
 	 * @param string[][] $removed
251 251
 	 */
252
-	private function handleRenames( array &$newContent, array $removed ): void {
252
+	private function handleRenames ( array &$newContent, array $removed ): void {
253 253
 		$renameMap = $this->getRenamedUsers( array_keys( $removed ) );
254 254
 		foreach ( $removed as $oldName => $info ) {
255 255
 			if (
256 256
 				array_key_exists( $oldName, $renameMap ) &&
257
-				array_key_exists( $renameMap[$oldName], $newContent )
257
+				array_key_exists( $renameMap[ $oldName ], $newContent )
258 258
 			) {
259 259
 				// This user was renamed! Add this name as alias, if they're still listed
260 260
 				$newName = $renameMap[ $oldName ];
261 261
 				$this->getLogger()->info( "Found rename $oldName -> $newName" );
262
-				$aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'] ?? [], [ $oldName ] ) );
263
-				$newContent[ $newName ]['aliases'] = $aliases;
262
+				$aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ] ?? [ ], [ $oldName ] ) );
263
+				$newContent[ $newName ][ 'aliases' ] = $aliases;
264 264
 				// Transfer overrides to the new name.
265 265
 				$overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] );
266 266
 				$newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides );
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
 	 * @param string[][] $extra
276 276
 	 * @return string[][] Removed users
277 277
 	 */
278
-	private function handleExtraAndMissing(
278
+	private function handleExtraAndMissing (
279 279
 		array &$newContent,
280 280
 		array $missing,
281 281
 		array $extra
282 282
 	): array {
283
-		$removed = [];
283
+		$removed = [ ];
284 284
 		foreach ( $newContent as $user => $data ) {
285 285
 			if ( isset( $missing[ $user ] ) ) {
286 286
 				$newContent[ $user ] = array_merge( $data, $missing[ $user ] );
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 				if ( array_diff_key( $newGroups, array_fill_keys( self::NON_GROUP_KEYS, 1 ) ) ) {
291 291
 					$newContent[ $user ] = $newGroups;
292 292
 				} else {
293
-					$removed[$user] = $data;
293
+					$removed[ $user ] = $data;
294 294
 					unset( $newContent[ $user ] );
295 295
 				}
296 296
 			}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 * @param string[][] $extra
308 308
 	 * @return array[]
309 309
 	 */
310
-	protected function getNewContent( array $missing, array $extra ): array {
310
+	protected function getNewContent ( array $missing, array $extra ): array {
311 311
 		$newContent = $this->botList;
312 312
 
313 313
 		$removed = $this->handleExtraAndMissing( $newContent, $missing, $extra );
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
 	 *
327 327
 	 * @param array[] &$newContent
328 328
 	 */
329
-	protected function removeOverrides( array &$newContent ): void {
330
-		$removed = [];
329
+	protected function removeOverrides ( array &$newContent ): void {
330
+		$removed = [ ];
331 331
 		foreach ( $newContent as $user => $groups ) {
332 332
 			if ( PageBotList::isOverrideExpired( $groups ) ) {
333 333
 				unset( $newContent[ $user ][ 'override' ] );
334
-				$removed[] = $user;
334
+				$removed[ ] = $user;
335 335
 			}
336 336
 		}
337 337
 
Please login to merge, or discard this patch.