Passed
Push — master ( 935a55...baa252 )
by Daimona
01:37
created
includes/Wiki/Page/PageBotList.php 1 patch
Spacing   +18 added lines, -20 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\Wiki\Page;
4 4
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	 * @private Use self::get()
20 20
 	 * @param Wiki $wiki
21 21
 	 */
22
-	public function __construct( Wiki $wiki ) {
22
+	public function __construct ( Wiki $wiki ) {
23 23
 		parent::__construct( Config::getInstance()->get( 'list-title' ), $wiki );
24 24
 	}
25 25
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param Wiki $wiki
30 30
 	 * @return self
31 31
 	 */
32
-	public static function get( Wiki $wiki ) : self {
32
+	public static function get ( Wiki $wiki ) : self {
33 33
 		static $instance = null;
34 34
 		if ( $instance === null ) {
35 35
 			$instance = new self( $wiki );
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 	 * @param string[] $groups
42 42
 	 * @return int|null
43 43
 	 */
44
-	public static function getOverrideTimestamp( array $groups ) : ?int {
44
+	public static function getOverrideTimestamp ( array $groups ) : ?int {
45 45
 		if ( !array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) {
46 46
 			return null;
47 47
 		}
48 48
 
49 49
 		// A one-time override takes precedence
50 50
 		if ( array_key_exists( 'override', $groups ) ) {
51
-			$date = $groups['override'];
51
+			$date = $groups[ 'override' ];
52 52
 		} else {
53
-			$date = $groups['override-prem'] . '/' . date( 'Y' );
53
+			$date = $groups[ 'override-prem' ] . '/' . date( 'Y' );
54 54
 		}
55 55
 		return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp();
56 56
 	}
@@ -61,17 +61,15 @@  discard block
 block discarded – undo
61 61
 	 * @param array $groups
62 62
 	 * @return int
63 63
 	 */
64
-	public static function getValidFlagTimestamp( array $groups ): int {
65
-		$checkuser = isset( $groups['checkuser'] ) ?
66
-			\DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() :
67
-			0;
68
-		$bureaucrat = isset( $groups['bureaucrat'] ) ?
69
-			\DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() :
70
-			0;
64
+	public static function getValidFlagTimestamp ( array $groups ): int {
65
+		$checkuser = isset( $groups[ 'checkuser' ] ) ?
66
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
67
+		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
68
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
71 69
 
72 70
 		$timestamp = max( $bureaucrat, $checkuser );
73 71
 		if ( $timestamp === 0 ) {
74
-			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp();
72
+			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp();
75 73
 		}
76 74
 		return $timestamp;
77 75
 	}
@@ -80,14 +78,14 @@  discard block
 block discarded – undo
80 78
 	 * @param array $groups
81 79
 	 * @return bool
82 80
 	 */
83
-	public static function isOverrideExpired( array $groups ) : bool {
84
-		if ( !isset( $groups['override'] ) ) {
81
+	public static function isOverrideExpired ( array $groups ) : bool {
82
+		if ( !isset( $groups[ 'override' ] ) ) {
85 83
 			return false;
86 84
 		}
87 85
 
88 86
 		$flagTS = self::getValidFlagTimestamp( $groups );
89 87
 		$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
90
-		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
88
+		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
91 89
 		$delay = 60 * 60 * 24 * 3;
92 90
 
93 91
 		return time() > $usualTS + $delay && time() > $overrideTS + $delay;
@@ -98,9 +96,9 @@  discard block
 block discarded – undo
98 96
 	 *
99 97
 	 * @return User[]
100 98
 	 */
101
-	public function getAdminsList() : array {
99
+	public function getAdminsList () : array {
102 100
 		if ( $this->adminsList === null ) {
103
-			$this->adminsList = [];
101
+			$this->adminsList = [ ];
104 102
 			foreach ( $this->getDecodedContent() as $user => $info ) {
105 103
 				$userObj = new User( $user, $this->wiki );
106 104
 				$userObj->setInfo( $info );
@@ -115,7 +113,7 @@  discard block
 block discarded – undo
115 113
 	 *
116 114
 	 * @return array[]
117 115
 	 */
118
-	public function getDecodedContent() : array {
116
+	public function getDecodedContent () : array {
119 117
 		return json_decode( $this->getContent(), true );
120 118
 	}
121 119
 }
Please login to merge, or discard this patch.
includes/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;
4 4
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	/**
27 27
 	 * @param string $key
28 28
 	 */
29
-	public function __construct( string $key ) {
29
+	public function __construct ( string $key ) {
30 30
 		$this->value = Config::getInstance()->getWikiMessage( $key );
31 31
 	}
32 32
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param array $args
35 35
 	 * @return self
36 36
 	 */
37
-	public function params( array $args ) : self {
37
+	public function params ( array $args ) : self {
38 38
 		$this->value = strtr( $this->value, $args );
39 39
 		return $this;
40 40
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 * @return string
44 44
 	 */
45
-	public function text() : string {
45
+	public function text () : string {
46 46
 		$this->parsePlurals();
47 47
 		return $this->value;
48 48
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * Replace {{$plur|<amount>|sing|plur}}
52 52
 	 */
53
-	protected function parsePlurals() {
53
+	protected function parsePlurals () {
54 54
 		$reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!';
55 55
 
56 56
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		$this->value = preg_replace_callback(
60 60
 			$reg,
61 61
 			function ( $matches ) {
62
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
62
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
63 63
 			},
64 64
 			$this->value
65 65
 		);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param string $timeString Full format, e.g. "15 aprile 2019 18:27"
72 72
 	 * @return int
73 73
 	 */
74
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
74
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
75 75
 		$englishTime = str_ireplace(
76 76
 			array_values( self::MONTHS ),
77 77
 			array_keys( self::MONTHS ),
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
 	 * @param string $emptyText
90 90
 	 * @return string
91 91
 	 */
92
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
92
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
93 93
 		if ( count( $data ) > 1 ) {
94 94
 			$last = array_pop( $data );
95 95
 			$ret = implode( ', ', $data ) . " e $last";
96 96
 		} elseif ( $data ) {
97
-			$ret = (string)$data[0];
97
+			$ret = (string)$data[ 0 ];
98 98
 		} else {
99 99
 			$ret = $emptyText;
100 100
 		}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 		return $ret;
103 103
 	}
104 104
 
105
-	public function __toString() {
105
+	public function __toString () {
106 106
 		return $this->text();
107 107
 	}
108 108
 }
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
 
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 	/**
21 21
 	 * @inheritDoc
22 22
 	 */
23
-	protected function getSubtasksMap(): array {
23
+	protected function getSubtasksMap (): array {
24 24
 		// Everything is done here.
25
-		return [];
25
+		return [ ];
26 26
 	}
27 27
 
28 28
 	/**
29 29
 	 * @inheritDoc
30 30
 	 */
31
-	public function runInternal() : int {
31
+	public function runInternal () : int {
32 32
 		$this->actualList = $this->getActualAdmins();
33 33
 		$pageBotList = PageBotList::get( $this->getWiki() );
34 34
 		$this->botList = $pageBotList->getDecodedContent();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	/**
56 56
 	 * @return array
57 57
 	 */
58
-	protected function getActualAdmins() : array {
58
+	protected function getActualAdmins () : array {
59 59
 		$params = [
60 60
 			'action' => 'query',
61 61
 			'list' => 'allusers',
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
 	 * @param \stdClass $data
73 73
 	 * @return array
74 74
 	 */
75
-	protected function extractAdmins( \stdClass $data ) : array {
76
-		$ret = [];
75
+	protected function extractAdmins ( \stdClass $data ) : array {
76
+		$ret = [ ];
77 77
 		$blacklist = $this->getOpt( 'exclude-admins' );
78 78
 		foreach ( $data->query->allusers as $u ) {
79 79
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -90,16 +90,16 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @return array[]
92 92
 	 */
93
-	protected function getMissingGroups() : array {
94
-		$missing = [];
93
+	protected function getMissingGroups () : array {
94
+		$missing = [ ];
95 95
 		foreach ( $this->actualList as $adm => $groups ) {
96
-			$curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) );
96
+			$curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) );
97 97
 
98 98
 			foreach ( $curMissing as $group ) {
99 99
 				try {
100 100
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
101 101
 				} catch ( TaskException $e ) {
102
-					$this->errors[] = $e->getMessage();
102
+					$this->errors[ ] = $e->getMessage();
103 103
 				}
104 104
 			}
105 105
 		}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return string
115 115
 	 * @throws TaskException
116 116
 	 */
117
-	protected function getFlagDate( string $admin, string $group ) : string {
117
+	protected function getFlagDate ( string $admin, string $group ) : string {
118 118
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
119 119
 
120 120
 		$url = DEFAULT_URL;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param string $group
151 151
 	 * @return string|null
152 152
 	 */
153
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
153
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
154 154
 		$ts = null;
155 155
 		foreach ( $data->query->logevents as $entry ) {
156 156
 			if (
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return array[]
171 171
 	 */
172
-	protected function getExtraGroups() : array {
173
-		$extra = [];
172
+	protected function getExtraGroups () : array {
173
+		$extra = [ ];
174 174
 		foreach ( $this->botList as $name => $groups ) {
175 175
 			$groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) );
176 176
 			if ( !isset( $this->actualList[ $name ] ) ) {
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @param string[] $names
187 187
 	 * @return \stdClass
188 188
 	 */
189
-	private function getRenameEntries( array $names ) : \stdClass {
189
+	private function getRenameEntries ( array $names ) : \stdClass {
190 190
 		$titles = array_map( function ( $x ) {
191 191
 			return "Utente:$x";
192 192
 		}, $names );
@@ -210,14 +210,14 @@  discard block
 block discarded – undo
210 210
 	 * @param string[] $names
211 211
 	 * @return string[] [ old_name => new_name ]
212 212
 	 */
213
-	protected function getRenamedUsers( array $names ) : array {
213
+	protected function getRenamedUsers ( array $names ) : array {
214 214
 		if ( !$names ) {
215
-			return [];
215
+			return [ ];
216 216
 		}
217 217
 		$this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) );
218 218
 
219 219
 		$data = $this->getRenameEntries( $names );
220
-		$ret = [];
220
+		$ret = [ ];
221 221
 		foreach ( $data->query->logevents as $entry ) {
222 222
 			// 1 month is arbitrary
223 223
 			if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) {
@@ -235,18 +235,18 @@  discard block
 block discarded – undo
235 235
 	 * @param array &$newContent
236 236
 	 * @param array $removed
237 237
 	 */
238
-	private function handleRenames( array &$newContent, array $removed ) : void {
238
+	private function handleRenames ( array &$newContent, array $removed ) : void {
239 239
 		$renameMap = $this->getRenamedUsers( array_keys( $removed ) );
240 240
 		foreach ( $removed as $oldName => $info ) {
241 241
 			if (
242 242
 				array_key_exists( $oldName, $renameMap ) &&
243
-				array_key_exists( $renameMap[$oldName], $newContent )
243
+				array_key_exists( $renameMap[ $oldName ], $newContent )
244 244
 			) {
245 245
 				// This user was renamed! Add this name as alias, if they're still listed
246 246
 				$newName = $renameMap[ $oldName ];
247 247
 				$this->getLogger()->info( "Found rename $oldName -> $newName" );
248
-				$aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) );
249
-				$newContent[ $newName ]['aliases'] = $aliases;
248
+				$aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) );
249
+				$newContent[ $newName ][ 'aliases' ] = $aliases;
250 250
 				// Transfer overrides to the new name.
251 251
 				$overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] );
252 252
 				$newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides );
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	 * @param array[] $extra
261 261
 	 * @return string[] Removed users
262 262
 	 */
263
-	private function handleExtraAndMissing( array &$newContent, array $missing, array $extra ) : array {
264
-		$removed = [];
263
+	private function handleExtraAndMissing ( array &$newContent, array $missing, array $extra ) : array {
264
+		$removed = [ ];
265 265
 		foreach ( $newContent as $user => $groups ) {
266 266
 			if ( isset( $missing[ $user ] ) ) {
267 267
 				$newContent[ $user ] = array_merge( $groups, $missing[ $user ] );
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 				if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) {
272 272
 					$newContent[ $user ] = $newGroups;
273 273
 				} else {
274
-					$removed[$user] = $newContent[$user];
274
+					$removed[ $user ] = $newContent[ $user ];
275 275
 					unset( $newContent[ $user ] );
276 276
 				}
277 277
 			}
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	 * @param array[] $extra
289 289
 	 * @return array[]
290 290
 	 */
291
-	protected function getNewContent( array $missing, array $extra ) : array {
291
+	protected function getNewContent ( array $missing, array $extra ) : array {
292 292
 		$newContent = $this->botList;
293 293
 
294 294
 		$removed = $this->handleExtraAndMissing( $newContent, $missing, $extra );
@@ -308,12 +308,12 @@  discard block
 block discarded – undo
308 308
 	 *
309 309
 	 * @param array[] &$newContent
310 310
 	 */
311
-	protected function removeOverrides( array &$newContent ) : void {
312
-		$removed = [];
311
+	protected function removeOverrides ( array &$newContent ) : void {
312
+		$removed = [ ];
313 313
 		foreach ( $newContent as $user => $groups ) {
314 314
 			if ( PageBotList::isOverrideExpired( $groups ) ) {
315 315
 				unset( $newContent[ $user ][ 'override' ] );
316
-				$removed[] = $user;
316
+				$removed[ ] = $user;
317 317
 			}
318 318
 		}
319 319
 
Please login to merge, or discard this patch.
includes/Task/Subtask/ArchivePages.php 1 patch
Spacing   +14 added lines, -14 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
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @inheritDoc
15 15
 	 */
16
-	public function runInternal() : int {
16
+	public function runInternal () : int {
17 17
 		$pages = $this->getDataProvider()->getPagesToClose();
18 18
 
19 19
 		if ( !$pages ) {
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 	 * @param PageRiconferma[] $pages
33 33
 	 * @see OpenUpdates::addToMainPage()
34 34
 	 */
35
-	protected function removeFromMainPage( array $pages ) {
35
+	protected function removeFromMainPage ( array $pages ) {
36 36
 		$this->getLogger()->info(
37 37
 			'Removing from main: ' . implode( ', ', $pages )
38 38
 		);
39 39
 
40 40
 		$mainPage = $this->getPage( $this->getOpt( 'main-page-title' ) );
41
-		$remove = [];
41
+		$remove = [ ];
42 42
 		foreach ( $pages as $page ) {
43 43
 			// Order matters here. It's not guaranteed that there'll be a newline, but avoid
44 44
 			// regexps for that single character.
45
-			$remove[] = '{{' . $page->getTitle() . "}}\n";
46
-			$remove[] = '{{' . $page->getTitle() . '}}';
45
+			$remove[ ] = '{{' . $page->getTitle() . "}}\n";
46
+			$remove[ ] = '{{' . $page->getTitle() . '}}';
47 47
 		}
48 48
 
49 49
 		$newContent = str_replace( $remove, '', $mainPage->getContent() );
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param PageRiconferma[] $pages
74 74
 	 */
75
-	protected function addToArchive( array $pages ) {
75
+	protected function addToArchive ( array $pages ) {
76 76
 		$this->getLogger()->info(
77 77
 			'Adding to archive: ' . implode( ', ', $pages )
78 78
 		);
79 79
 
80
-		$simple = $votes = [];
80
+		$simple = $votes = [ ];
81 81
 		foreach ( $pages as $page ) {
82 82
 			if ( $page->isVote() ) {
83
-				$votes[] = $page;
83
+				$votes[ ] = $page;
84 84
 			} else {
85
-				$simple[] = $page;
85
+				$simple[ ] = $page;
86 86
 			}
87 87
 		}
88 88
 
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 	 * @param string $archiveTitle
104 104
 	 * @param PageRiconferma[] $pages
105 105
 	 */
106
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
106
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
107 107
 		$archivePage = $this->getPage( "$archiveTitle/" . date( 'Y' ) );
108 108
 		$existed = $archivePage->exists();
109 109
 
110 110
 		$append = "\n";
111
-		$archivedList = [];
111
+		$archivedList = [ ];
112 112
 		foreach ( $pages as $page ) {
113 113
 			$append .= '{{' . $page->getTitle() . "}}\n";
114
-			$archivedList[] = $page->getUserNum();
114
+			$archivedList[ ] = $page->getUserNum();
115 115
 		}
116 116
 
117 117
 		$summary = $this->msg( 'close-archive-summary' )
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param string $archiveTitle
134 134
 	 */
135
-	private function addArchiveYear( string $archiveTitle ) {
135
+	private function addArchiveYear ( string $archiveTitle ) {
136 136
 		$page = $this->getPage( $archiveTitle );
137 137
 		$year = date( 'Y' );
138 138
 
Please login to merge, or discard this patch.
includes/Task/Subtask/SimpleUpdates.php 1 patch
Spacing   +23 added lines, -23 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
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @inheritDoc
18 18
 	 */
19
-	public function runInternal() : int {
19
+	public function runInternal () : int {
20 20
 		$pages = $this->getDataProvider()->getPagesToClose();
21 21
 
22 22
 		if ( !$pages ) {
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @param PageRiconferma[] $pages
39 39
 	 * @see OpenUpdates::addToVotazioni()
40 40
 	 */
41
-	protected function updateVotazioni( array $pages ) {
41
+	protected function updateVotazioni ( array $pages ) {
42 42
 		$this->getLogger()->info(
43 43
 			'Updating votazioni: ' . implode( ', ', $pages )
44 44
 		);
45 45
 		$votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) );
46 46
 
47
-		$users = [];
47
+		$users = [ ];
48 48
 		foreach ( $pages as $page ) {
49
-			$users[] = $page->getUser();
49
+			$users[ ] = $page->getUser();
50 50
 		}
51 51
 		$usersReg = Element::regexFromArray( $users );
52 52
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param array $pages
68 68
 	 * @see OpenUpdates::addToNews()
69 69
 	 */
70
-	protected function updateNews( array $pages ) {
70
+	protected function updateNews ( array $pages ) {
71 71
 		$simpleAmount = $voteAmount = 0;
72 72
 		foreach ( $pages as $page ) {
73 73
 			if ( $page->isVote() ) {
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
88 88
 		$voteMatches = $newsPage->getMatch( $voteReg );
89 89
 
90
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
91
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
90
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
91
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
92 92
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() );
93 93
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
94 94
 
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param bool[] $outcomes
108 108
 	 */
109
-	protected function updateAdminList( array $outcomes ) {
109
+	protected function updateAdminList ( array $outcomes ) {
110 110
 		$this->getLogger()->info( 'Updating admin list' );
111 111
 		$adminsPage = $this->getPage( $this->getOpt( 'admins-list-title' ) );
112 112
 		$newContent = $adminsPage->getContent();
113 113
 
114
-		$riconfNames = $removeNames = [];
114
+		$riconfNames = $removeNames = [ ];
115 115
 		foreach ( $outcomes as $username => $confirmed ) {
116 116
 			$user = $this->getUser( $username );
117 117
 			$userReg = $user->getRegex();
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 					'${1}{{subst:#timel:Ymd}}|' . $nextDate . '$2',
124 124
 					$newContent
125 125
 				);
126
-				$riconfNames[] = $username;
126
+				$riconfNames[ ] = $username;
127 127
 			} else {
128 128
 				$newContent = preg_replace( $reg, '', $newContent );
129
-				$removeNames[] = $username;
129
+				$removeNames[ ] = $username;
130 130
 			}
131 131
 		}
132 132
 
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 	 * @param User $user
150 150
 	 * @return int
151 151
 	 */
152
-	private function getNextTs( User $user ) : int {
152
+	private function getNextTs ( User $user ) : int {
153 153
 		$userInfo = $user->getUserInfo();
154
-		if ( isset( $userInfo['override-perm'] ) ) {
154
+		if ( isset( $userInfo[ 'override-perm' ] ) ) {
155 155
 			$date = \DateTime::createFromFormat(
156 156
 				'd/m/Y',
157
-				$userInfo['override-perm'] . '/' . date( 'Y' )
157
+				$userInfo[ 'override-perm' ] . '/' . date( 'Y' )
158 158
 			);
159 159
 			if ( $date < new \DateTime ) {
160 160
 				$date->modify( '+1 year' );
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 		} else {
164 164
 			$ts = PageBotList::getValidFlagTimestamp( $userInfo );
165 165
 			$res = strtotime( date( 'Y', strtotime( '+1 year' ) ) . date( '-m-d', $ts ) );
166
-			if ( isset( $userInfo['override'] ) ) {
167
-				$date = \DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] );
166
+			if ( isset( $userInfo[ 'override' ] ) ) {
167
+				$date = \DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] );
168 168
 				if ( $date > new \DateTime ) {
169 169
 					$res = $date->getTimestamp();
170 170
 				}
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
 	/**
177 177
 	 * @param bool[] $outcomes
178 178
 	 */
179
-	protected function updateCUList( array $outcomes ) {
179
+	protected function updateCUList ( array $outcomes ) {
180 180
 		$this->getLogger()->info( 'Updating CU list.' );
181 181
 		$cuList = $this->getPage( $this->getOpt( 'cu-list-title' ) );
182 182
 		$newContent = $cuList->getContent();
183 183
 
184
-		$riconfNames = $removeNames = [];
184
+		$riconfNames = $removeNames = [ ];
185 185
 		foreach ( $outcomes as $user => $confirmed ) {
186 186
 			$userReg = $this->getUser( $user )->getRegex();
187 187
 			$reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
188 188
 			if ( $confirmed ) {
189 189
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent );
190
-				$riconfNames[] = $user;
190
+				$riconfNames[ ] = $user;
191 191
 			} else {
192 192
 				$newContent = preg_replace( $reg, '', $newContent );
193
-				$removeNames[] = $user;
193
+				$removeNames[ ] = $user;
194 194
 			}
195 195
 		}
196 196
 
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @param PageRiconferma[] $pages
215 215
 	 * @return bool[]
216 216
 	 */
217
-	private function getGroupOutcomes( string $group, array $pages ) : array {
218
-		$ret = [];
217
+	private function getGroupOutcomes ( string $group, array $pages ) : array {
218
+		$ret = [ ];
219 219
 		foreach ( $pages as $page ) {
220 220
 			$user = $page->getUser();
221 221
 			if ( $user->inGroup( $group ) ) {
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +15 added lines, -15 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
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/** @var User[]|null */
15 15
 	private $processUsers;
16 16
 	/** @var PageRiconferma[] */
17
-	private $createdPages = [];
17
+	private $createdPages = [ ];
18 18
 	/** @var PageRiconferma[]|null */
19 19
 	private $openPages;
20 20
 	/** @var PageRiconferma[]|null */
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	 *
26 26
 	 * @return User[]
27 27
 	 */
28
-	public function getUsersToProcess() : array {
28
+	public function getUsersToProcess () : array {
29 29
 		if ( $this->processUsers === null ) {
30
-			$this->processUsers = [];
30
+			$this->processUsers = [ ];
31 31
 			foreach ( PageBotList::get( $this->getWiki() )->getAdminsList() as $name => $user ) {
32 32
 				if ( $this->shouldAddUser( $user ) ) {
33 33
 					$this->processUsers[ $name ] = $user;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param User $user
45 45
 	 * @return bool
46 46
 	 */
47
-	private function shouldAddUser( User $user ) : bool {
47
+	private function shouldAddUser ( User $user ) : bool {
48 48
 		$timestamp = PageBotList::getOverrideTimestamp( $user->getUserInfo() );
49 49
 		$override = $timestamp !== null;
50 50
 
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return PageRiconferma[]
64 64
 	 */
65
-	public function getOpenPages() : array {
65
+	public function getOpenPages () : array {
66 66
 		if ( $this->openPages === null ) {
67
-			$this->openPages = [];
67
+			$this->openPages = [ ];
68 68
 			$mainTitle = $this->getOpt( 'main-page-title' );
69 69
 			$params = [
70 70
 				'action' => 'query',
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			$pages = RequestBase::newFromParams( $params )->execute()->query->pages;
79 79
 			foreach ( reset( $pages )->templates as $page ) {
80 80
 				if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) {
81
-					$this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() );
81
+					$this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() );
82 82
 				}
83 83
 			}
84 84
 		}
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
 	 *
92 92
 	 * @return PageRiconferma[]
93 93
 	 */
94
-	public function getPagesToClose() : array {
94
+	public function getPagesToClose () : array {
95 95
 		if ( $this->pagesToClose === null ) {
96
-			$this->pagesToClose = [];
96
+			$this->pagesToClose = [ ];
97 97
 			foreach ( $this->getOpenPages() as $page ) {
98 98
 				if ( time() > $page->getEndTimestamp() ) {
99
-					$this->pagesToClose[] = $page;
99
+					$this->pagesToClose[ ] = $page;
100 100
 				}
101 101
 			}
102 102
 		}
@@ -108,21 +108,21 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param string $name
110 110
 	 */
111
-	public function removeUser( string $name ) {
111
+	public function removeUser ( string $name ) {
112 112
 		unset( $this->processUsers[ $name ] );
113 113
 	}
114 114
 
115 115
 	/**
116 116
 	 * @return PageRiconferma[]
117 117
 	 */
118
-	public function getCreatedPages() : array {
118
+	public function getCreatedPages () : array {
119 119
 		return $this->createdPages;
120 120
 	}
121 121
 
122 122
 	/**
123 123
 	 * @param PageRiconferma $page
124 124
 	 */
125
-	public function addCreatedPage( PageRiconferma $page ) {
126
-		$this->createdPages[] = $page;
125
+	public function addCreatedPage ( PageRiconferma $page ) {
126
+		$this->createdPages[ ] = $page;
127 127
 	}
128 128
 }
Please login to merge, or discard this patch.