Passed
Push — master ( 6aef8a...1dba3f )
by Daimona
01:31
created
includes/Page/PageBotList.php 1 patch
Spacing   +4 added lines, -4 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\Page;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @private Use self::get()
13 13
 	 */
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		parent::__construct( Config::getInstance()->get( 'list-title' ) );
16 16
 	}
17 17
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return self
22 22
 	 */
23
-	public static function get() : self {
23
+	public static function get () : self {
24 24
 		static $instance = null;
25 25
 		if ( $instance === null ) {
26 26
 			$instance = new self;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return array[]
35 35
 	 */
36
-	public function getAdminsList() : array {
36
+	public function getAdminsList () : array {
37 37
 		return json_decode( $this->getContent(), true );
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/SimpleUpdates.php 1 patch
Spacing   +21 added lines, -21 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 run() : TaskResult {
16
+	public function run () : TaskResult {
17 17
 		$this->getLogger()->info( 'Starting task SimpleUpdates' );
18 18
 
19 19
 		$pages = $this->getDataProvider()->getPagesToClose();
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
 	 * @param PageRiconferma[] $pages
31 31
 	 * @see UpdatesAround::addVote()
32 32
 	 */
33
-	protected function updateVote( array $pages ) {
33
+	protected function updateVote ( array $pages ) {
34 34
 		$this->getLogger()->info(
35 35
 			'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) )
36 36
 		);
37 37
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) );
38 38
 
39
-		$titles = [];
39
+		$titles = [ ];
40 40
 		foreach ( $pages as $page ) {
41
-			$titles[] = preg_quote( $page->getTitle() );
41
+			$titles[ ] = preg_quote( $page->getTitle() );
42 42
 		}
43 43
 
44 44
 		$titleReg = implode( '|', $titles );
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param array $pages
68 68
 	 * @see UpdatesAround::addNews()
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,12 +87,12 @@  discard block
 block discarded – undo
87 87
 		$simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
88 88
 		$voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
89 89
 
90
-		$simpleMatches = $voteMatches = [];
90
+		$simpleMatches = $voteMatches = [ ];
91 91
 		preg_match( $simpleReg, $content, $simpleMatches );
92 92
 		preg_match( $voteReg, $content, $voteMatches );
93 93
 
94
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
95
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
94
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
95
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
96 96
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
97 97
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
98 98
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @param PageRiconferma[] $pages
112 112
 	 */
113
-	protected function updateAdminList( array $pages ) {
113
+	protected function updateAdminList ( array $pages ) {
114 114
 		$this->getLogger()->info(
115 115
 			'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) )
116 116
 		);
@@ -118,17 +118,17 @@  discard block
 block discarded – undo
118 118
 		$newContent = $adminsPage->getContent();
119 119
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
120 120
 
121
-		$riconfNames = $removeNames = [];
121
+		$riconfNames = $removeNames = [ ];
122 122
 		foreach ( $pages as $page ) {
123 123
 			$user = $page->getUser();
124 124
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!";
125 125
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
126 126
 				// Remove the line
127 127
 				$newContent = preg_replace( $reg, '', $newContent );
128
-				$removeNames[] = $user;
128
+				$removeNames[ ] = $user;
129 129
 			} else {
130 130
 				$newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent );
131
-				$riconfNames[] = $user;
131
+				$riconfNames[ ] = $user;
132 132
 			}
133 133
 		}
134 134
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			$lastUser = array_pop( $riconfNames );
137 137
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
138 138
 		} elseif ( $riconfNames ) {
139
-			$riconfList = $riconfNames[0];
139
+			$riconfList = $riconfNames[ 0 ];
140 140
 		} else {
141 141
 			$riconfList = 'nessuno';
142 142
 		}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 			$lastUser = array_pop( $removeNames );
146 146
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
147 147
 		} elseif ( $removeNames ) {
148
-			$removeList = $removeNames[0];
148
+			$removeList = $removeNames[ 0 ];
149 149
 		} else {
150 150
 			$removeList = 'nessuno';
151 151
 		}
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 	/**
167 167
 	 * @param PageRiconferma[] $pages
168 168
 	 */
169
-	protected function updateCUList( array $pages ) {
169
+	protected function updateCUList ( array $pages ) {
170 170
 		$this->getLogger()->info( 'Checking if CU list needs updating.' );
171 171
 		$cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) );
172 172
 		$admins = $this->getDataProvider()->getUsersList();
173 173
 		$newContent = $cuList->getContent();
174 174
 
175
-		$riconfNames = $removeNames = [];
175
+		$riconfNames = $removeNames = [ ];
176 176
 		foreach ( $pages as $page ) {
177 177
 			$user = $page->getUser();
178 178
 			if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) {
@@ -180,10 +180,10 @@  discard block
 block discarded – undo
180 180
 				if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
181 181
 					// Remove the line
182 182
 					$newContent = preg_replace( $reg, '', $newContent );
183
-					$removeNames[] = $user;
183
+					$removeNames[ ] = $user;
184 184
 				} else {
185 185
 					$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
186
-					$riconfNames[] = $user;
186
+					$riconfNames[ ] = $user;
187 187
 				}
188 188
 			}
189 189
 		}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$lastUser = array_pop( $riconfNames );
201 201
 			$riconfList = implode( ', ', $riconfNames ) . " e $lastUser";
202 202
 		} elseif ( $riconfNames ) {
203
-			$riconfList = $riconfNames[0];
203
+			$riconfList = $riconfNames[ 0 ];
204 204
 		} else {
205 205
 			$riconfList = 'nessuno';
206 206
 		}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 			$lastUser = array_pop( $removeNames );
210 210
 			$removeList = implode( ', ', $removeNames ) . " e $lastUser";
211 211
 		} elseif ( $removeNames ) {
212
-			$removeList = $removeNames[0];
212
+			$removeList = $removeNames[ 0 ];
213 213
 		} else {
214 214
 			$removeList = 'nessuno';
215 215
 		}
Please login to merge, or discard this patch.
includes/Task/StartVote.php 1 patch
Spacing   +17 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\Task;
4 4
 
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	protected function getSubtasksMap(): array {
18
+	protected function getSubtasksMap (): array {
19 19
 		// Everything is done here.
20
-		return [];
20
+		return [ ];
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	public function run() : TaskResult {
26
+	public function run () : TaskResult {
27 27
 		$this->getLogger()->info( 'Starting task StartVote' );
28 28
 
29 29
 		$pages = $this->getDataProvider()->getOpenPages();
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 	/**
42 42
 	 * @param PageRiconferma[] $pages
43 43
 	 */
44
-	protected function processPages( array $pages ) {
45
-		$actualPages = [];
44
+	protected function processPages ( array $pages ) {
45
+		$actualPages = [ ];
46 46
 		foreach ( $pages as $page ) {
47 47
 			if ( $page->hasOpposition() && !$page->isVote() ) {
48 48
 				$this->openVote( $page );
49
-				$actualPages[] = $page;
49
+				$actualPages[ ] = $page;
50 50
 			}
51 51
 		}
52 52
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @param PageRiconferma $page
65 65
 	 */
66
-	protected function openVote( PageRiconferma $page ) {
66
+	protected function openVote ( PageRiconferma $page ) {
67 67
 		$this->getLogger()->info( "Starting vote on $page" );
68 68
 
69 69
 		$content = $page->getContent();
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
 	 * @see SimpleUpdates::updateVote()
103 103
 	 * @see UpdatesAround::addVote()
104 104
 	 */
105
-	protected function updateVotePage( array $pages ) {
105
+	protected function updateVotePage ( array $pages ) {
106 106
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) );
107 107
 		$content = $votePage->getContent();
108 108
 
109
-		$titles = [];
109
+		$titles = [ ];
110 110
 		foreach ( $pages as $page ) {
111
-			$titles[] = preg_quote( $page->getTitle() );
111
+			$titles[ ] = preg_quote( $page->getTitle() );
112 112
 		}
113 113
 		$titleReg = implode( '|', $titles );
114 114
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm";
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
132 132
 		} else {
133 133
 			// Start section
134
-			$matches = [];
134
+			$matches = [ ];
135 135
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
136 136
 				throw new TaskException( 'Intro not found in vote page' );
137 137
 			}
138 138
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
139 139
 			// Replace semicolon with full stop
140 140
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
141
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
141
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
142 142
 		}
143 143
 
144 144
 		$summary = $this->msg( 'vote-start-vote-page-summary' )
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 	 * @see UpdatesAround::addNews()
161 161
 	 * @see SimpleUpdates::updateNews()
162 162
 	 */
163
-	protected function updateNews( int $amount ) {
163
+	protected function updateNews ( int $amount ) {
164 164
 		$this->getLogger()->info( "Turning $amount pages into votes" );
165 165
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) );
166 166
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		$regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
169 169
 		$regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
170 170
 
171
-		$tacMatches = $votMatches = [];
171
+		$tacMatches = $votMatches = [ ];
172 172
 		if ( preg_match( $regTac, $content, $tacMatches ) === false ) {
173 173
 			throw new TaskException( 'Param "tacite" not found in news page' );
174 174
 		}
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 			throw new TaskException( 'Param "voto" not found in news page' );
177 177
 		}
178 178
 
179
-		$newTac = (int)$tacMatches[2] - $amount ?: '';
180
-		$newVot = (int)$votMatches[2] + $amount ?: '';
179
+		$newTac = (int)$tacMatches[ 2 ] - $amount ?: '';
180
+		$newVot = (int)$votMatches[ 2 ] + $amount ?: '';
181 181
 
182 182
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
183 183
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.