Passed
Push — master ( 31e6ff...8cfe0d )
by Daimona
01:32
created
includes/Page.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
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @param string $title
18 18
 	 */
19
-	public function __construct( string $title ) {
19
+	public function __construct ( string $title ) {
20 20
 		$this->title = $title;
21 21
 		$this->controller = new WikiController();
22 22
 	}
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @return string
26 26
 	 */
27
-	public function getTitle() : string {
27
+	public function getTitle () : string {
28 28
 		return $this->title;
29 29
 	}
30 30
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param int|null $section A section number to retrieve the content of that section
35 35
 	 * @return string
36 36
 	 */
37
-	public function getContent( int $section = null ) : string {
37
+	public function getContent ( int $section = null ) : string {
38 38
 		if ( $this->content === null ) {
39 39
 			$this->content = $this->controller->getPageContent( $this->title, $section );
40 40
 		}
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @param array $params
48 48
 	 */
49
-	public function edit( array $params ) {
49
+	public function edit ( array $params ) {
50 50
 		$params = [
51 51
 			'title' => $this->getTitle()
52 52
 		] + $params;
53 53
 
54 54
 		$this->controller->editPage( $params );
55
-		if ( isset( $params['text'] ) ) {
56
-			$this->content = $params['text'];
57
-		} elseif ( isset( $params['appendtext'] ) ) {
58
-			$this->content .= $params['appendtext'];
55
+		if ( isset( $params[ 'text' ] ) ) {
56
+			$this->content = $params[ 'text' ];
57
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
58
+			$this->content .= $params[ 'appendtext' ];
59 59
 		} else {
60 60
 			// Clear the cache anyway
61 61
 			( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) );
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return string
70 70
 	 */
71
-	public function __toString() {
71
+	public function __toString () {
72 72
 		return $this->getTitle();
73 73
 	}
74 74
 }
Please login to merge, or discard this patch.
includes/Task/UpdatesAround.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function run() : TaskResult {
18
+	public function run () : TaskResult {
19 19
 		$this->getLogger()->info( 'Starting task UpdatesAround' );
20 20
 
21 21
 		$pages = $this->getDataProvider()->getCreatedPages();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param PageRiconferma[] $pages
41 41
 	 */
42
-	protected function addToMainPage( array $pages ) {
42
+	protected function addToMainPage ( array $pages ) {
43 43
 		$this->getLogger()->info(
44 44
 			'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) )
45 45
 		);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param PageRiconferma[] $pages
68 68
 	 */
69
-	protected function addVote( array $pages ) {
69
+	protected function addVote ( array $pages ) {
70 70
 		$this->getLogger()->info(
71 71
 			'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) )
72 72
 		);
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
88 88
 		} else {
89 89
 			// Start section
90
-			$matches = [];
90
+			$matches = [ ];
91 91
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
92 92
 				throw new TaskException( 'Intro not found in vote page' );
93 93
 			}
94 94
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
95 95
 			// Replace semicolon with full stop
96 96
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
97
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
97
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
98 98
 		}
99 99
 
100 100
 		$summary = $this->msg( 'ric-vote-page-summary' )
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @param int $amount
115 115
 	 */
116
-	protected function addNews( int $amount ) {
116
+	protected function addNews ( int $amount ) {
117 117
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
118 118
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) );
119 119
 
120 120
 		$content = $newsPage->getContent();
121 121
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
122 122
 
123
-		$matches = [];
123
+		$matches = [ ];
124 124
 		if ( preg_match( $reg, $content, $matches ) === false ) {
125 125
 			throw new TaskException( 'Param not found in news page' );
126 126
 		}
127 127
 
128
-		$newNum = (int)$matches[2] + $amount;
128
+		$newNum = (int)$matches[ 2 ] + $amount;
129 129
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
130 130
 
131 131
 		$summary = $this->msg( 'ric-news-page-summary' )
Please login to merge, or discard this patch.
includes/Task/ClosePages.php 1 patch
Spacing   +54 added lines, -55 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
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function run() : TaskResult {
18
+	public function run () : TaskResult {
19 19
 		$this->getLogger()->info( 'Starting task ClosePages' );
20 20
 
21 21
 		$pages = $this->getPagesList();
@@ -52,12 +52,12 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return PageRiconferma[]
54 54
 	 */
55
-	protected function getPagesList() : array {
55
+	protected function getPagesList () : array {
56 56
 		$allPages = $this->getDataProvider()->getOpenPages();
57
-		$ret = [];
57
+		$ret = [ ];
58 58
 		foreach ( $allPages as $page ) {
59 59
 			if ( time() > $page->getEndTimestamp() ) {
60
-				$ret[] = $page;
60
+				$ret[ ] = $page;
61 61
 			}
62 62
 		}
63 63
 		return $ret;
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 * @param PageRiconferma[] $pages
70 70
 	 * @return PageRiconferma[]
71 71
 	 */
72
-	private function getFailures( array $pages ) : array {
73
-		$ret = [];
72
+	private function getFailures ( array $pages ) : array {
73
+		$ret = [ ];
74 74
 		foreach ( $pages as $page ) {
75 75
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
76
-				$ret[] = $page;
76
+				$ret[ ] = $page;
77 77
 			}
78 78
 		}
79 79
 		return $ret;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	/**
83 83
 	 * @param PageRiconferma $page
84 84
 	 */
85
-	protected function addVoteCloseText( PageRiconferma $page ) {
85
+	protected function addVoteCloseText ( PageRiconferma $page ) {
86 86
 		$content = $page->getContent();
87 87
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
88 88
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	 * @param PageRiconferma[] $pages
101 101
 	 * @see UpdatesAround::addToMainPage()
102 102
 	 */
103
-	protected function removeFromMainPage( array $pages ) {
103
+	protected function removeFromMainPage ( array $pages ) {
104 104
 		$this->getLogger()->info(
105 105
 			'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) )
106 106
 		);
107 107
 
108 108
 		$mainPage = new Page( $this->getConfig()->get( 'ric-main-page' ) );
109
-		$translations = [];
109
+		$translations = [ ];
110 110
 		foreach ( $pages as $page ) {
111 111
 			$translations[ '{{' . $page->getTitle() . '}}' ] = '';
112 112
 		}
@@ -124,17 +124,17 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param PageRiconferma[] $pages
126 126
 	 */
127
-	protected function addToArchive( array $pages ) {
127
+	protected function addToArchive ( array $pages ) {
128 128
 		$this->getLogger()->info(
129 129
 			'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) )
130 130
 		);
131 131
 
132
-		$simple = $votes = [];
132
+		$simple = $votes = [ ];
133 133
 		foreach ( $pages as $page ) {
134 134
 			if ( $page->isVote() ) {
135
-				$votes[] = $page;
135
+				$votes[ ] = $page;
136 136
 			} else {
137
-				$simple[] = $page;
137
+				$simple[ ] = $page;
138 138
 			}
139 139
 		}
140 140
 
@@ -151,21 +151,21 @@  discard block
 block discarded – undo
151 151
 	 * @param string $archiveTitle
152 152
 	 * @param array $pages
153 153
 	 */
154
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
154
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
155 155
 		$curTitle = "$archiveTitle/" . date( 'Y' );
156 156
 
157 157
 		$append = '';
158
-		$archivedList = [];
158
+		$archivedList = [ ];
159 159
 		foreach ( $pages as $page ) {
160 160
 			$append .= '{{' . $page->getTitle() . "}}\n";
161
-			$archivedList[] = $page->getUserNum();
161
+			$archivedList[ ] = $page->getUserNum();
162 162
 		}
163 163
 
164 164
 		if ( count( $archivedList ) > 1 ) {
165 165
 			$last = array_pop( $archivedList );
166 166
 			$userNums = implode( ', ', $archivedList ) . " e $last";
167 167
 		} else {
168
-			$userNums = $archivedList[0];
168
+			$userNums = $archivedList[ 0 ];
169 169
 		}
170 170
 
171 171
 		$summary = $this->msg( 'close-archive-summary' )
@@ -184,15 +184,14 @@  discard block
 block discarded – undo
184 184
 	 * @param PageRiconferma $page
185 185
 	 * @see CreatePages::updateBasePage()
186 186
 	 */
187
-	protected function updateBasePage( PageRiconferma $page ) {
187
+	protected function updateBasePage ( PageRiconferma $page ) {
188 188
 		$this->getLogger()->info( "Updating base page for $page" );
189 189
 
190 190
 		$basePage = new Page( $page->getBaseTitle() );
191 191
 		$current = $basePage->getContent();
192 192
 
193 193
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
194
-			'non riconfermato' :
195
-			'riconfermato';
194
+			'non riconfermato' : 'riconfermato';
196 195
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
197 196
 
198 197
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
@@ -208,16 +207,16 @@  discard block
 block discarded – undo
208 207
 	 * @param PageRiconferma[] $pages
209 208
 	 * @see UpdatesAround::addVote()
210 209
 	 */
211
-	protected function updateVote( array $pages ) {
210
+	protected function updateVote ( array $pages ) {
212 211
 		$this->getLogger()->info(
213 212
 			'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) )
214 213
 		);
215 214
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) );
216 215
 		$content = $votePage->getContent();
217 216
 
218
-		$titles = [];
217
+		$titles = [ ];
219 218
 		foreach ( $pages as $page ) {
220
-			$titles[] = preg_quote( $page->getTitle() );
219
+			$titles[ ] = preg_quote( $page->getTitle() );
221 220
 		}
222 221
 
223 222
 		$titleReg = implode( '|', array_map( 'preg_quote', $titles ) );
@@ -248,7 +247,7 @@  discard block
 block discarded – undo
248 247
 	 * @param array $pages
249 248
 	 * @see UpdatesAround::addNews()
250 249
 	 */
251
-	protected function updateNews( array $pages ) {
250
+	protected function updateNews ( array $pages ) {
252 251
 		$simpleAmount = $voteAmount = 0;
253 252
 		foreach ( $pages as $page ) {
254 253
 			if ( $page->isVote() ) {
@@ -268,12 +267,12 @@  discard block
 block discarded – undo
268 267
 		$simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
269 268
 		$voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
270 269
 
271
-		$simpleMatches = $voteMatches = [];
270
+		$simpleMatches = $voteMatches = [ ];
272 271
 		preg_match( $simpleReg, $content, $simpleMatches );
273 272
 		preg_match( $voteReg, $content, $voteMatches );
274 273
 
275
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
276
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
274
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
275
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
277 276
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
278 277
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
279 278
 
@@ -293,7 +292,7 @@  discard block
 block discarded – undo
293 292
 	 *
294 293
 	 * @param PageRiconferma[] $pages
295 294
 	 */
296
-	protected function updateAdminList( array $pages ) {
295
+	protected function updateAdminList ( array $pages ) {
297 296
 		$this->getLogger()->info(
298 297
 			'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) )
299 298
 		);
@@ -301,17 +300,17 @@  discard block
 block discarded – undo
301 300
 		$newContent = $adminsPage->getContent();
302 301
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
303 302
 
304
-		$riconfNames = $removeNames = [];
303
+		$riconfNames = $removeNames = [ ];
305 304
 		foreach ( $pages as $page ) {
306 305
 			$user = $page->getUser();
307 306
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!";
308 307
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
309 308
 				// Remove the line
310 309
 				$newContent = preg_replace( $reg, '', $newContent );
311
-				$removeNames[] = $user;
310
+				$removeNames[ ] = $user;
312 311
 			} else {
313 312
 				$newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent );
314
-				$riconfNames[] = $user;
313
+				$riconfNames[ ] = $user;
315 314
 			}
316 315
 		}
317 316
 
@@ -319,7 +318,7 @@  discard block
 block discarded – undo
319 318
 			$lastUser = array_pop( $riconfNames );
320 319
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
321 320
 		} elseif ( $riconfNames ) {
322
-			$riconfList = $riconfNames[0];
321
+			$riconfList = $riconfNames[ 0 ];
323 322
 		} else {
324 323
 			$riconfList = 'nessuno';
325 324
 		}
@@ -328,7 +327,7 @@  discard block
 block discarded – undo
328 327
 			$lastUser = array_pop( $removeNames );
329 328
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
330 329
 		} elseif ( $removeNames ) {
331
-			$removeList = $removeNames[0];
330
+			$removeList = $removeNames[ 0 ];
332 331
 		} else {
333 332
 			$removeList = 'nessuno';
334 333
 		}
@@ -351,13 +350,13 @@  discard block
 block discarded – undo
351 350
 	/**
352 351
 	 * @param PageRiconferma[] $pages
353 352
 	 */
354
-	protected function updateCUList( array $pages ) {
353
+	protected function updateCUList ( array $pages ) {
355 354
 		$this->getLogger()->info( 'Checking if CU list needs updating.' );
356 355
 		$cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) );
357 356
 		$admins = $this->getDataProvider()->getUsersList();
358 357
 		$newContent = $cuList->getContent();
359 358
 
360
-		$riconfNames = $removeNames = [];
359
+		$riconfNames = $removeNames = [ ];
361 360
 		foreach ( $pages as $page ) {
362 361
 			$user = $page->getUser();
363 362
 			if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) {
@@ -365,10 +364,10 @@  discard block
 block discarded – undo
365 364
 				if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
366 365
 					// Remove the line
367 366
 					$newContent = preg_replace( $reg, '', $newContent );
368
-					$removeNames[] = $user;
367
+					$removeNames[ ] = $user;
369 368
 				} else {
370 369
 					$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
371
-					$riconfNames[] = $user;
370
+					$riconfNames[ ] = $user;
372 371
 				}
373 372
 			}
374 373
 		}
@@ -385,7 +384,7 @@  discard block
 block discarded – undo
385 384
 			$lastUser = array_pop( $riconfNames );
386 385
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
387 386
 		} elseif ( $riconfNames ) {
388
-			$riconfList = $riconfNames[0];
387
+			$riconfList = $riconfNames[ 0 ];
389 388
 		} else {
390 389
 			$riconfList = 'nessuno';
391 390
 		}
@@ -394,7 +393,7 @@  discard block
 block discarded – undo
394 393
 			$lastUser = array_pop( $removeNames );
395 394
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
396 395
 		} elseif ( $removeNames ) {
397
-			$removeList = $removeNames[0];
396
+			$removeList = $removeNames[ 0 ];
398 397
 		} else {
399 398
 			$removeList = 'nessuno';
400 399
 		}
@@ -416,17 +415,17 @@  discard block
 block discarded – undo
416 415
 	/**
417 416
 	 * @param PageRiconferma[] $pages
418 417
 	 */
419
-	protected function updateBurList( array $pages ) {
418
+	protected function updateBurList ( array $pages ) {
420 419
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
421
-		$admins =  $this->getDataProvider()->getUsersList();
420
+		$admins = $this->getDataProvider()->getUsersList();
422 421
 
423
-		$remove = [];
422
+		$remove = [ ];
424 423
 		foreach ( $pages as $page ) {
425 424
 			$user = $page->getUser();
426 425
 			if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) &&
427 426
 				$page->getOutcome() & PageRiconferma::OUTCOME_FAIL
428 427
 			) {
429
-				$remove[] = $user;
428
+				$remove[ ] = $user;
430 429
 			}
431 430
 		}
432 431
 
@@ -445,7 +444,7 @@  discard block
 block discarded – undo
445 444
 			$lastUser = array_pop( $remove );
446 445
 			$removeList = implode( ', ', $remove ) . " e $lastUser";
447 446
 		} else {
448
-			$removeList = $remove[0];
447
+			$removeList = $remove[ 0 ];
449 448
 		}
450 449
 
451 450
 		$summary = $this->msg( 'bur-list-update-summary' )
@@ -464,7 +463,7 @@  discard block
 block discarded – undo
464 463
 	 *
465 464
 	 * @param PageRiconferma[] $pages
466 465
 	 */
467
-	protected function requestRemoval( array $pages ) {
466
+	protected function requestRemoval ( array $pages ) {
468 467
 		$this->getLogger()->info(
469 468
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
470 469
 		);
@@ -508,14 +507,14 @@  discard block
 block discarded – undo
508 507
 	 *
509 508
 	 * @param PageRiconferma[] $pages
510 509
 	 */
511
-	protected function updateAnnunci( array $pages ) {
510
+	protected function updateAnnunci ( array $pages ) {
512 511
 		$this->getLogger()->info( 'Updating annunci' );
513 512
 
514
-		$names = [];
513
+		$names = [ ];
515 514
 		$text = '';
516 515
 		foreach ( $pages as $page ) {
517 516
 			$user = $page->getUser();
518
-			$names[] = $user;
517
+			$names[ ] = $user;
519 518
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
520 519
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
521 520
 		}
@@ -538,7 +537,7 @@  discard block
 block discarded – undo
538 537
 			$lastUser = array_pop( $names );
539 538
 			$namesList = implode( ', ', $names ) . " e $lastUser";
540 539
 		} else {
541
-			$namesList = $names[0];
540
+			$namesList = $names[ 0 ];
542 541
 		}
543 542
 
544 543
 		$summary = $this->msg( 'annunci-summary' )
@@ -557,16 +556,16 @@  discard block
 block discarded – undo
557 556
 	 *
558 557
 	 * @param PageRiconferma[] $pages
559 558
 	 */
560
-	protected function updateUltimeNotizie( array $pages ) {
559
+	protected function updateUltimeNotizie ( array $pages ) {
561 560
 		$this->getLogger()->info( 'Updating ultime notizie' );
562 561
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-title' ) );
563 562
 
564
-		$names = [];
563
+		$names = [ ];
565 564
 		$text = '';
566 565
 		foreach ( $pages as $page ) {
567 566
 			$user = $page->getUser();
568 567
 			$title = $page->getTitle();
569
-			$names[] = $user;
568
+			$names[ ] = $user;
570 569
 			$text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
571 570
 				'[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.';
572 571
 		}
@@ -585,7 +584,7 @@  discard block
 block discarded – undo
585 584
 			$lastUser = array_pop( $names );
586 585
 			$namesList = implode( ', ', $names ) . " e $lastUser";
587 586
 		} else {
588
-			$namesList = $names[0];
587
+			$namesList = $names[ 0 ];
589 588
 		}
590 589
 
591 590
 		$summary = $this->msg( 'ultimenotizie-summary' )
Please login to merge, or discard this patch.
includes/Task/StartVote.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\Task;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function run() : TaskResult {
18
+	public function run () : TaskResult {
19 19
 		$this->getLogger()->info( 'Starting task StartVote' );
20 20
 
21 21
 		$pages = $this->getDataProvider()->getOpenPages();
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @param PageRiconferma[] $pages
35 35
 	 */
36
-	protected function processPages( array $pages ) {
37
-		$actualPages = [];
36
+	protected function processPages ( array $pages ) {
37
+		$actualPages = [ ];
38 38
 		foreach ( $pages as $page ) {
39 39
 			if ( $page->hasOpposition() && !$page->isVote() ) {
40 40
 				$this->openVote( $page );
41
-				$actualPages[] = $page;
41
+				$actualPages[ ] = $page;
42 42
 			}
43 43
 		}
44 44
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @param PageRiconferma $page
57 57
 	 */
58
-	protected function openVote( PageRiconferma $page ) {
58
+	protected function openVote ( PageRiconferma $page ) {
59 59
 		$this->getLogger()->info( "Starting vote on $page" );
60 60
 
61 61
 		$content = $page->getContent();
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 	 * @see ClosePages::updateVote()
95 95
 	 * @see UpdatesAround::addVote()
96 96
 	 */
97
-	protected function updateVotePage( array $pages ) {
97
+	protected function updateVotePage ( array $pages ) {
98 98
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) );
99 99
 		$content = $votePage->getContent();
100 100
 
101
-		$titles = [];
101
+		$titles = [ ];
102 102
 		foreach ( $pages as $page ) {
103
-			$titles[] = preg_quote( $page->getTitle() );
103
+			$titles[ ] = preg_quote( $page->getTitle() );
104 104
 		}
105 105
 		$titleReg = implode( '|', array_map( 'preg_quote', $titles ) );
106 106
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm";
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
124 124
 		} else {
125 125
 			// Start section
126
-			$matches = [];
126
+			$matches = [ ];
127 127
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
128 128
 				throw new TaskException( 'Intro not found in vote page' );
129 129
 			}
130 130
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
131 131
 			// Replace semicolon with full stop
132 132
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
133
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
133
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
134 134
 		}
135 135
 
136 136
 		$summary = $this->msg( 'vote-start-vote-page-summary' )
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @see UpdatesAround::addNews()
153 153
 	 * @see ClosePages::updateNews()
154 154
 	 */
155
-	protected function updateNews( int $amount ) {
155
+	protected function updateNews ( int $amount ) {
156 156
 		$this->getLogger()->info( "Turning $amount pages into votes" );
157 157
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) );
158 158
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
161 161
 		$regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
162 162
 
163
-		$tacMatches = $votMatches = [];
163
+		$tacMatches = $votMatches = [ ];
164 164
 		if ( preg_match( $regTac, $content, $tacMatches ) === false ) {
165 165
 			throw new TaskException( 'Param "tacite" not found in news page' );
166 166
 		}
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 			throw new TaskException( 'Param "voto" not found in news page' );
169 169
 		}
170 170
 
171
-		$newTac = (int)$tacMatches[2] - $amount ?: '';
172
-		$newVot = (int)$votMatches[2] + $amount ?: '';
171
+		$newTac = (int)$tacMatches[ 2 ] - $amount ?: '';
172
+		$newVot = (int)$votMatches[ 2 ] + $amount ?: '';
173 173
 
174 174
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
175 175
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +15 added lines, -17 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
 
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 	/** @var array[] */
14 14
 	private $allUsers;
15 15
 	/** @var PageRiconferma[] */
16
-	private $createdPages = [];
16
+	private $createdPages = [ ];
17 17
 
18 18
 	/**
19 19
 	 * Get the full content of the JSON users list
20 20
 	 *
21 21
 	 * @return array[]
22 22
 	 */
23
-	public function getUsersList() : array {
23
+	public function getUsersList () : array {
24 24
 		if ( $this->allUsers === null ) {
25 25
 			$this->getLogger()->debug( 'Retrieving users list' );
26 26
 			$content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) );
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return array[]
37 37
 	 */
38
-	public function getUsersToProcess() : array {
38
+	public function getUsersToProcess () : array {
39 39
 		if ( $this->processUsers === null ) {
40
-			$this->processUsers = [];
40
+			$this->processUsers = [ ];
41 41
 			foreach ( $this->getUsersList() as $user => $groups ) {
42 42
 				$timestamp = $this->getValidTimestamp( $groups );
43 43
 
@@ -59,13 +59,11 @@  discard block
 block discarded – undo
59 59
 	 * @param array $groups
60 60
 	 * @return int
61 61
 	 */
62
-	private function getValidTimestamp( array $groups ) : int {
62
+	private function getValidTimestamp ( array $groups ) : int {
63 63
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
64
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
65
-			0;
64
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
66 65
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
67
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
68
-			0;
66
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
69 67
 
70 68
 		$timestamp = max( $bureaucrat, $checkuser );
71 69
 		if ( $timestamp === 0 ) {
@@ -79,7 +77,7 @@  discard block
 block discarded – undo
79 77
 	 *
80 78
 	 * @return PageRiconferma[]
81 79
 	 */
82
-	public function getOpenPages() : array {
80
+	public function getOpenPages () : array {
83 81
 		$baseTitle = $this->getConfig()->get( 'ric-main-page' );
84 82
 		$params = [
85 83
 			'action' => 'query',
@@ -91,10 +89,10 @@  discard block
 block discarded – undo
91 89
 
92 90
 		$res = RequestBase::newFromParams( $params )->execute();
93 91
 		$pages = $res->query->pages;
94
-		$ret = [];
92
+		$ret = [ ];
95 93
 		foreach ( reset( $pages )->templates as $page ) {
96 94
 			if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
97
-				$ret[] = new PageRiconferma( $page->title );
95
+				$ret[ ] = new PageRiconferma( $page->title );
98 96
 			}
99 97
 		}
100 98
 		return $ret;
@@ -105,21 +103,21 @@  discard block
 block discarded – undo
105 103
 	 *
106 104
 	 * @param string $name
107 105
 	 */
108
-	public function removeUser( string $name ) {
106
+	public function removeUser ( string $name ) {
109 107
 		unset( $this->processUsers[ $name ] );
110 108
 	}
111 109
 
112 110
 	/**
113 111
 	 * @return PageRiconferma[]
114 112
 	 */
115
-	public function getCreatedPages() : array {
113
+	public function getCreatedPages () : array {
116 114
 		return $this->createdPages;
117 115
 	}
118 116
 
119 117
 	/**
120 118
 	 * @param PageRiconferma $page
121 119
 	 */
122
-	public function addCreatedPages( PageRiconferma $page ) {
123
-		$this->createdPages[] = $page;
120
+	public function addCreatedPages ( PageRiconferma $page ) {
121
+		$this->createdPages[ ] = $page;
124 122
 	}
125 123
 }
Please login to merge, or discard this patch.