Passed
Push — master ( 2486a1...bd3758 )
by Daimona
01:48
created
includes/Task/ClosePages.php 1 patch
Spacing   +26 added lines, -26 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
 		$titles = $this->getPagesList();
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return string[]
42 42
 	 */
43
-	protected function getPagesList() : array {
43
+	protected function getPagesList () : array {
44 44
 		$allPages = $this->getTranscludedPages();
45
-		$ret = [];
45
+		$ret = [ ];
46 46
 		foreach ( $allPages as $page ) {
47 47
 			$created = $this->getController()->getPageCreationTS( $page );
48 48
 			if ( time() - $created <= 60 * 60 * 24 * 7 && !$this->hasOpposition( $page ) ) {
49
-				$ret[] = $page;
49
+				$ret[ ] = $page;
50 50
 			}
51 51
 		}
52 52
 		return $ret;
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 *
58 58
 	 * @return string[]
59 59
 	 */
60
-	protected function getTranscludedPages() : array {
60
+	protected function getTranscludedPages () : array {
61 61
 		$baseTitle = $this->getConfig()->get( 'ric-main-page' );
62 62
 		$params = [
63 63
 			'action' => 'query',
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 
70 70
 		$res = RequestBase::newFromParams( $params )->execute();
71 71
 		$pages = $res->query->pages;
72
-		$ret = [];
72
+		$ret = [ ];
73 73
 		foreach ( reset( $pages )->templates as $page ) {
74 74
 			if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
75
-				$ret[] = $page->title;
75
+				$ret[ ] = $page->title;
76 76
 			}
77 77
 		}
78 78
 		return $ret;
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @param string $page
83 83
 	 * @return bool
84 84
 	 */
85
-	protected function hasOpposition( string $page ) : bool {
85
+	protected function hasOpposition ( string $page ) : bool {
86 86
 		$params = [
87 87
 			'action' => 'query',
88 88
 			'prop' => 'revisions',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 		];
94 94
 		$res = RequestBase::newFromParams( $params )->execute();
95 95
 		$page = reset( $res->query->pages );
96
-		$content = $page->revisions[0]->slots->main->{ '*' };
96
+		$content = $page->revisions[ 0 ]->slots->main->{ '*' };
97 97
 		// Let's hope that this is good enough...
98 98
 		$votes = substr_count( $content, "\n\# *(?![#*])" );
99 99
 		return $votes >= 15;
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 	 * @param string[] $titles
105 105
 	 * @see UpdatesAround::addToMainPage()
106 106
 	 */
107
-	protected function removeFromMainPage( array $titles ) {
107
+	protected function removeFromMainPage ( array $titles ) {
108 108
 		$this->getLogger()->info( 'Removing from main: ' . implode( ', ', $titles ) );
109 109
 
110 110
 		$mainPage = $this->getConfig()->get( 'ric-main-page' );
111 111
 		$content = $this->getController()->getPageContent( $mainPage );
112
-		$translations = [];
112
+		$translations = [ ];
113 113
 		foreach ( $titles as $title ) {
114 114
 			$translations[ '{{' . $title . '}}' ] = '';
115 115
 		}
@@ -127,24 +127,24 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @param string[] $titles
129 129
 	 */
130
-	protected function addToArchive( array $titles ) {
130
+	protected function addToArchive ( array $titles ) {
131 131
 		$this->getLogger()->info( 'Adding to archive: ' . implode( ', ', $titles ) );
132 132
 
133 133
 		$archiveTitle = $this->getConfig()->get( 'close-archive-title' );
134 134
 		$archiveTitle = "$archiveTitle/" . date( 'Y' );
135 135
 
136 136
 		$append = '';
137
-		$archivedList = [];
137
+		$archivedList = [ ];
138 138
 		foreach ( $titles as $page ) {
139 139
 			$append .= '{{' . $page . "}}\n";
140
-			$archivedList[] = explode( '/', $page, 3 )[2];
140
+			$archivedList[ ] = explode( '/', $page, 3 )[ 2 ];
141 141
 		}
142 142
 
143 143
 		if ( count( $archivedList ) > 1 ) {
144 144
 			$last = array_pop( $archivedList );
145 145
 			$userNums = implode( ', ', $archivedList ) . " e $last";
146 146
 		} else {
147
-			$userNums = $archivedList[0];
147
+			$userNums = $archivedList[ 0 ];
148 148
 		}
149 149
 
150 150
 		$summary = strtr(
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param string $title
166 166
 	 * @see CreatePages::updateBasePage()
167 167
 	 */
168
-	protected function updateBasePage( string $title ) {
168
+	protected function updateBasePage ( string $title ) {
169 169
 		$this->getLogger()->info( "Updating base page $title" );
170 170
 
171 171
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal WTF Phan what's wrong w/ u?
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 * @param string[] $titles
187 187
 	 * @see UpdatesAround::addVote()
188 188
 	 */
189
-	protected function updateVote( array $titles ) {
189
+	protected function updateVote ( array $titles ) {
190 190
 		$votePage = $this->getConfig()->get( 'ric-vote-page' );
191 191
 		$content = $this->getController()->getPageContent( $votePage );
192 192
 
@@ -212,19 +212,19 @@  discard block
 block discarded – undo
212 212
 	 * @throws TaskException
213 213
 	 * @see UpdatesAround::addNews()
214 214
 	 */
215
-	protected function updateNews( int $amount ) {
215
+	protected function updateNews ( int $amount ) {
216 216
 		$this->getLogger()->info( "Decreasing the news counter by $amount" );
217 217
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
218 218
 
219 219
 		$content = $this->getController()->getPageContent( $newsPage );
220 220
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
221 221
 
222
-		$matches = [];
222
+		$matches = [ ];
223 223
 		if ( preg_match( $reg, $content, $matches ) === false ) {
224 224
 			throw new TaskException( 'Param not found in news page' );
225 225
 		}
226 226
 
227
-		$newNum = (int)$matches[2] - $amount;
227
+		$newNum = (int)$matches[ 2 ] - $amount;
228 228
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
229 229
 
230 230
 		$params = [
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 	 *
242 242
 	 * @param string[] $titles
243 243
 	 */
244
-	protected function updateAdminList( array $titles ) {
244
+	protected function updateAdminList ( array $titles ) {
245 245
 		$listTitle = $this->getConfig()->get( 'admins-list' );
246 246
 		$content = $this->getController()->getPageContent( $listTitle );
247 247
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
248 248
 
249
-		$names = [];
249
+		$names = [ ];
250 250
 		foreach ( $titles as $title ) {
251
-			$user = explode( '/', $title )[2];
252
-			$names[] = $user;
251
+			$user = explode( '/', $title )[ 2 ];
252
+			$names[ ] = $user;
253 253
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+(?= *\|(?: *pausa)? *\}\})!";
254 254
 			$content = preg_replace( $reg, '$1' . $newDate, $content );
255 255
 		}
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			$lastUser = array_pop( $names );
259 259
 			$usersList = implode( ', ', $names ) . " e $lastUser";
260 260
 		} else {
261
-			$usersList = $names[0];
261
+			$usersList = $names[ 0 ];
262 262
 		}
263 263
 
264 264
 		$summary = strtr(
Please login to merge, or discard this patch.