Passed
Push — master ( 8ee621...33a572 )
by Daimona
01:38
created
includes/Task/CreatePages.php 1 patch
Spacing   +11 added lines, -11 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
 
@@ -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 CreatePages' );
18 18
 		$users = $this->getDataProvider()->getUsersToProcess();
19 19
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param string $user
36 36
 	 * @param array $groups
37 37
 	 */
38
-	protected function processUser( string $user, array $groups ) {
38
+	protected function processUser ( string $user, array $groups ) {
39 39
 		try {
40 40
 			$num = $this->getLastPageNum( $user ) + 1;
41 41
 		} catch ( TaskException $e ) {
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 * @return int
66 66
 	 * @throws TaskException
67 67
 	 */
68
-	protected function getLastPageNum( string $user ) : int {
68
+	protected function getLastPageNum ( string $user ) : int {
69 69
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
70
-		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1];
70
+		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ];
71 71
 		$params = [
72 72
 			'action' => 'query',
73 73
 			'list' => 'allpages',
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 	 * @param string $user
103 103
 	 * @param array $groups
104 104
 	 */
105
-	protected function createPage( string $title, string $user, array $groups ) {
105
+	protected function createPage ( string $title, string $user, array $groups ) {
106 106
 		$this->getLogger()->info( "Creating page $title" );
107 107
 		$text = $this->getConfig()->get( 'ric-page-text' );
108 108
 		$textParams = [
109 109
 			'$user' => $user,
110
-			'$date' => $groups['sysop'],
111
-			'$burocrate' => $groups['bureaucrat'] ?? '',
112
-			'$checkuser' => $groups['checkuser'] ?? ''
110
+			'$date' => $groups[ 'sysop' ],
111
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
112
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
113 113
 		];
114 114
 		$text = strtr( $text, $textParams );
115 115
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $title
129 129
 	 * @param string $newText
130 130
 	 */
131
-	protected function createBasePage( string $title, string $newText ) {
131
+	protected function createBasePage ( string $title, string $newText ) {
132 132
 		$this->getLogger()->info( "Creating base page $title" );
133 133
 
134 134
 		$params = [
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $title
146 146
 	 * @param string $newText
147 147
 	 */
148
-	protected function updateBasePage( string $title, string $newText ) {
148
+	protected function updateBasePage ( string $title, string $newText ) {
149 149
 		$this->getLogger()->info( "Updating base page $title" );
150 150
 
151 151
 		$params = [
Please login to merge, or discard this patch.
includes/Task/UpdatesAround.php 1 patch
Spacing   +13 added lines, -13 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
 
@@ -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 UpdatesAround' );
18 18
 
19 19
 		$pages = $this->getDataProvider()->getCreatedPages();
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string[] $pages
39 39
 	 */
40
-	protected function addToMainPage( array $pages ) {
40
+	protected function addToMainPage ( array $pages ) {
41 41
 		$this->getLogger()->info(
42 42
 			'Adding the following to main: ' . implode( ', ', $pages )
43 43
 		);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$summary = preg_replace_callback(
55 55
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
56 56
 			function ( $matches ) {
57
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
57
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
58 58
 			},
59 59
 			$summary
60 60
 		);
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @param string[] $pages
75 75
 	 */
76
-	protected function addVote( array $pages ) {
76
+	protected function addVote ( array $pages ) {
77 77
 		$this->getLogger()->info(
78 78
 			'Adding the following to votes: ' . implode( ', ', $pages )
79 79
 		);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		$time = WikiController::getTimeWithArticle( time() + ( 60 * 60 * 24 * 7 ) );
85 85
 		$newLines = '';
86 86
 		foreach ( $pages as $page ) {
87
-			$user = explode( '/', $page )[2];
87
+			$user = explode( '/', $page )[ 2 ];
88 88
 			$newLines .= "*[[Utente:$user|]]. La [[$page|procedura]] termina $time;\n";
89 89
 		}
90 90
 
@@ -94,14 +94,14 @@  discard block
 block discarded – undo
94 94
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
95 95
 		} else {
96 96
 			// Start section
97
-			$matches = [];
97
+			$matches = [ ];
98 98
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
99 99
 				throw new TaskException( 'Intro not found in vote page' );
100 100
 			}
101 101
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
102 102
 			// Replace semicolon with full stop
103 103
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
104
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
104
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
105 105
 		}
106 106
 
107 107
 		$summary = strtr(
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		$summary = preg_replace_callback(
112 112
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
113 113
 			function ( $matches ) {
114
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
114
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
115 115
 			},
116 116
 			$summary
117 117
 		);
@@ -130,26 +130,26 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @param int $amount
132 132
 	 */
133
-	protected function addNews( int $amount ) {
133
+	protected function addNews ( int $amount ) {
134 134
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
135 135
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
136 136
 
137 137
 		$content = $this->getController()->getPageContent( $newsPage );
138 138
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
139 139
 
140
-		$matches = [];
140
+		$matches = [ ];
141 141
 		if ( preg_match( $reg, $content, $matches ) === false ) {
142 142
 			throw new TaskException( 'Param not found in news page' );
143 143
 		}
144 144
 
145
-		$newNum = (int)$matches[2] + $amount;
145
+		$newNum = (int)$matches[ 2 ] + $amount;
146 146
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
147 147
 
148 148
 		$summary = strtr( $this->getConfig()->get( 'ric-news-page-summary' ), [ '$num' => $amount ] );
149 149
 		$summary = preg_replace_callback(
150 150
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
151 151
 			function ( $matches ) {
152
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
152
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
153 153
 			},
154 154
 			$summary
155 155
 		);
Please login to merge, or discard this patch.
includes/Task/ClosePages.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;
4 4
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @inheritDoc
18 18
 	 */
19
-	public function run() : TaskResult {
19
+	public function run () : TaskResult {
20 20
 		$this->getLogger()->info( 'Starting task ClosePages' );
21 21
 
22 22
 		$titles = $this->getPagesList();
@@ -41,13 +41,13 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return string[]
43 43
 	 */
44
-	protected function getPagesList() : array {
44
+	protected function getPagesList () : array {
45 45
 		$allPages = $this->getDataProvider()->getOpenPages();
46
-		$ret = [];
46
+		$ret = [ ];
47 47
 		foreach ( $allPages as $page ) {
48 48
 			$created = $this->getController()->getPageCreationTS( $page );
49 49
 			if ( time() - $created <= 60 * 60 * 24 * 7 && !WikiController::hasOpposition( $page ) ) {
50
-				$ret[] = $page;
50
+				$ret[ ] = $page;
51 51
 			}
52 52
 		}
53 53
 		return $ret;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 * @param string[] $titles
59 59
 	 * @see UpdatesAround::addToMainPage()
60 60
 	 */
61
-	protected function removeFromMainPage( array $titles ) {
61
+	protected function removeFromMainPage ( array $titles ) {
62 62
 		$this->getLogger()->info( 'Removing from main: ' . implode( ', ', $titles ) );
63 63
 
64 64
 		$mainPage = $this->getConfig()->get( 'ric-main-page' );
65 65
 		$content = $this->getController()->getPageContent( $mainPage );
66
-		$translations = [];
66
+		$translations = [ ];
67 67
 		foreach ( $titles as $title ) {
68 68
 			$translations[ '{{' . $title . '}}' ] = '';
69 69
 		}
@@ -81,24 +81,24 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @param string[] $titles
83 83
 	 */
84
-	protected function addToArchive( array $titles ) {
84
+	protected function addToArchive ( array $titles ) {
85 85
 		$this->getLogger()->info( 'Adding to archive: ' . implode( ', ', $titles ) );
86 86
 
87 87
 		$archiveTitle = $this->getConfig()->get( 'close-archive-title' );
88 88
 		$archiveTitle = "$archiveTitle/" . date( 'Y' );
89 89
 
90 90
 		$append = '';
91
-		$archivedList = [];
91
+		$archivedList = [ ];
92 92
 		foreach ( $titles as $page ) {
93 93
 			$append .= '{{' . $page . "}}\n";
94
-			$archivedList[] = explode( '/', $page, 3 )[2];
94
+			$archivedList[ ] = explode( '/', $page, 3 )[ 2 ];
95 95
 		}
96 96
 
97 97
 		if ( count( $archivedList ) > 1 ) {
98 98
 			$last = array_pop( $archivedList );
99 99
 			$userNums = implode( ', ', $archivedList ) . " e $last";
100 100
 		} else {
101
-			$userNums = $archivedList[0];
101
+			$userNums = $archivedList[ 0 ];
102 102
 		}
103 103
 
104 104
 		$summary = strtr(
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param string $title
120 120
 	 * @see CreatePages::updateBasePage()
121 121
 	 */
122
-	protected function updateBasePage( string $title ) {
122
+	protected function updateBasePage ( string $title ) {
123 123
 		$this->getLogger()->info( "Updating base page $title" );
124 124
 
125 125
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal WTF Phan what's wrong w/ u?
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @param string[] $titles
141 141
 	 * @see UpdatesAround::addVote()
142 142
 	 */
143
-	protected function updateVote( array $titles ) {
143
+	protected function updateVote ( array $titles ) {
144 144
 		$votePage = $this->getConfig()->get( 'ric-vote-page' );
145 145
 		$content = $this->getController()->getPageContent( $votePage );
146 146
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		$summary = preg_replace_callback(
160 160
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
161 161
 			function ( $matches ) {
162
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
162
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
163 163
 			},
164 164
 			$summary
165 165
 		);
@@ -178,19 +178,19 @@  discard block
 block discarded – undo
178 178
 	 * @throws TaskException
179 179
 	 * @see UpdatesAround::addNews()
180 180
 	 */
181
-	protected function updateNews( int $amount ) {
181
+	protected function updateNews ( int $amount ) {
182 182
 		$this->getLogger()->info( "Decreasing the news counter by $amount" );
183 183
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
184 184
 
185 185
 		$content = $this->getController()->getPageContent( $newsPage );
186 186
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
187 187
 
188
-		$matches = [];
188
+		$matches = [ ];
189 189
 		if ( preg_match( $reg, $content, $matches ) === false ) {
190 190
 			throw new TaskException( 'Param not found in news page' );
191 191
 		}
192 192
 
193
-		$newNum = (int)$matches[2] - $amount;
193
+		$newNum = (int)$matches[ 2 ] - $amount;
194 194
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
195 195
 
196 196
 		$summary = strtr(
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 		$summary = preg_replace_callback(
201 201
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
202 202
 			function ( $matches ) {
203
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
203
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
204 204
 			},
205 205
 			$summary
206 206
 		);
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 	 *
220 220
 	 * @param string[] $titles
221 221
 	 */
222
-	protected function updateAdminList( array $titles ) {
222
+	protected function updateAdminList ( array $titles ) {
223 223
 		$listTitle = $this->getConfig()->get( 'admins-list' );
224 224
 		$content = $this->getController()->getPageContent( $listTitle );
225 225
 		$newDate = date( 'Ymd', strtotime( '+1 year' ) );
226 226
 
227
-		$names = [];
227
+		$names = [ ];
228 228
 		foreach ( $titles as $title ) {
229
-			$user = explode( '/', $title )[2];
230
-			$names[] = $user;
229
+			$user = explode( '/', $title )[ 2 ];
230
+			$names[ ] = $user;
231 231
 			$reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+(?= *\|(?: *pausa)? *\}\})!";
232 232
 			$content = preg_replace( $reg, '$1' . $newDate, $content );
233 233
 		}
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 			$lastUser = array_pop( $names );
237 237
 			$usersList = implode( ', ', $names ) . " e $lastUser";
238 238
 		} else {
239
-			$usersList = $names[0];
239
+			$usersList = $names[ 0 ];
240 240
 		}
241 241
 
242 242
 		$summary = strtr(
Please login to merge, or discard this patch.
includes/WikiController.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;
4 4
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	/** @var string[] */
20 20
 	private $tokens;
21 21
 
22
-	public function __construct() {
22
+	public function __construct () {
23 23
 		$this->logger = new Logger;
24 24
 	}
25 25
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @return string
31 31
 	 * @throws MissingPageException
32 32
 	 */
33
-	public function getPageContent( string $title ) : string {
33
+	public function getPageContent ( string $title ) : string {
34 34
 		$this->logger->debug( "Retrieving page $title" );
35 35
 		$params = [
36 36
 			'action' => 'query',
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 			throw new MissingPageException( $title );
48 48
 		}
49 49
 
50
-		return $page->revisions[0]->slots->main->{ '*' };
50
+		return $page->revisions[ 0 ]->slots->main->{ '*' };
51 51
 	}
52 52
 
53 53
 	/**
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param array $params
57 57
 	 * @throws EditException
58 58
 	 */
59
-	public function editPage( array $params ) {
59
+	public function editPage ( array $params ) {
60 60
 		$this->login();
61 61
 
62 62
 		$params = [
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return string
79 79
 	 * @fixme Not the right place for this
80 80
 	 */
81
-	public static function getTimeWithArticle( int $timestamp ) : string {
81
+	public static function getTimeWithArticle ( int $timestamp ) : string {
82 82
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
83 83
 		$endTime = strftime( '%e %B alle %R', $timestamp );
84 84
 		// Remove the left space if day has a single digit
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 	 * @return bool
95 95
 	 * @fixme Not the right place for this
96 96
 	 */
97
-	public static function hasOpposition( string $page ) : bool {
97
+	public static function hasOpposition ( string $page ) : bool {
98 98
 		$params = [
99 99
 			'action' => 'query',
100 100
 			'prop' => 'revisions',
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 		];
106 106
 		$res = RequestBase::newFromParams( $params )->execute();
107 107
 		$page = reset( $res->query->pages );
108
-		$content = $page->revisions[0]->slots->main->{ '*' };
108
+		$content = $page->revisions[ 0 ]->slots->main->{ '*' };
109 109
 		// Let's hope that this is good enough...
110 110
 		$votes = substr_count( $content, "\n\# *(?![#*])" );
111 111
 		return $votes >= 15;
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
116 116
 	 * @throws LoginException
117 117
 	 */
118
-	public function login() {
118
+	public function login () {
119 119
 		if ( self::$loggedIn ) {
120 120
 			$this->logger->debug( 'Already logged in' );
121 121
 			return;
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
 		self::$loggedIn = true;
144 144
 		// Clear tokens cache
145
-		$this->tokens = [];
145
+		$this->tokens = [ ];
146 146
 		$this->logger->info( 'Login succeeded' );
147 147
 	}
148 148
 
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param string $type
153 153
 	 * @return string
154 154
 	 */
155
-	public function getToken( string $type ) : string {
155
+	public function getToken ( string $type ) : string {
156 156
 		if ( !isset( $this->tokens[ $type ] ) ) {
157 157
 			$params = [
158 158
 				'action' => 'query',
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @param string $title
176 176
 	 * @return int
177 177
 	 */
178
-	public function getPageCreationTS( string $title ) : int {
178
+	public function getPageCreationTS ( string $title ) : int {
179 179
 		$params = [
180 180
 			'action' => 'query',
181 181
 			'prop' => 'revisions',
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 
189 189
 		$res = ( RequestBase::newFromParams( $params ) )->execute();
190 190
 		$data = $res->query->pages;
191
-		return strtotime( reset( $data )->revisions[0]->timestamp );
191
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
192 192
 	}
193 193
 
194 194
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param string $title
198 198
 	 * @param string $reason
199 199
 	 */
200
-	public function protectPage( string $title, string $reason ) {
200
+	public function protectPage ( string $title, string $reason ) {
201 201
 		$this->logger->info( "Protecting page $title" );
202 202
 		$this->login();
203 203
 
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +14 added lines, -16 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
 
@@ -12,20 +12,20 @@  discard block
 block discarded – undo
12 12
 	private $users;
13 13
 
14 14
 	/** @var string[] */
15
-	private $createdPages = [];
15
+	private $createdPages = [ ];
16 16
 
17 17
 	/**
18 18
 	 * Get a list of users to execute tasks on.
19 19
 	 *
20 20
 	 * @return array[]
21 21
 	 */
22
-	public function getUsersToProcess() : array {
22
+	public function getUsersToProcess () : array {
23 23
 		if ( $this->users === null ) {
24 24
 			$this->getLogger()->debug( 'Retrieving users list' );
25 25
 			$content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) );
26 26
 			$listUsers = json_decode( $content, true );
27 27
 
28
-			$this->users = [];
28
+			$this->users = [ ];
29 29
 			foreach ( $listUsers as $user => $groups ) {
30 30
 				$timestamp = $this->getValidTimestamp( $groups );
31 31
 
@@ -47,13 +47,11 @@  discard block
 block discarded – undo
47 47
 	 * @param array $groups
48 48
 	 * @return int
49 49
 	 */
50
-	private function getValidTimestamp( array $groups ) : int {
50
+	private function getValidTimestamp ( array $groups ) : int {
51 51
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
52
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
53
-			0;
52
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
54 53
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
55
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
56
-			0;
54
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
57 55
 
58 56
 		$timestamp = max( $bureaucrat, $checkuser );
59 57
 		if ( $timestamp === 0 ) {
@@ -67,7 +65,7 @@  discard block
 block discarded – undo
67 65
 	 *
68 66
 	 * @return string[] Their titles
69 67
 	 */
70
-	public function getOpenPages() : array {
68
+	public function getOpenPages () : array {
71 69
 		$baseTitle = $this->getConfig()->get( 'ric-main-page' );
72 70
 		$params = [
73 71
 			'action' => 'query',
@@ -79,10 +77,10 @@  discard block
 block discarded – undo
79 77
 
80 78
 		$res = RequestBase::newFromParams( $params )->execute();
81 79
 		$pages = $res->query->pages;
82
-		$ret = [];
80
+		$ret = [ ];
83 81
 		foreach ( reset( $pages )->templates as $page ) {
84 82
 			if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
85
-				$ret[] = $page->title;
83
+				$ret[ ] = $page->title;
86 84
 			}
87 85
 		}
88 86
 		return $ret;
@@ -93,21 +91,21 @@  discard block
 block discarded – undo
93 91
 	 *
94 92
 	 * @param string $name
95 93
 	 */
96
-	public function removeUser( string $name ) {
94
+	public function removeUser ( string $name ) {
97 95
 		unset( $this->users[ $name ] );
98 96
 	}
99 97
 
100 98
 	/**
101 99
 	 * @return string[]
102 100
 	 */
103
-	public function getCreatedPages() : array {
101
+	public function getCreatedPages () : array {
104 102
 		return $this->createdPages;
105 103
 	}
106 104
 
107 105
 	/**
108 106
 	 * @param string $title
109 107
 	 */
110
-	public function addCreatedPages( string $title ) {
111
-		$this->createdPages[] = $title;
108
+	public function addCreatedPages ( string $title ) {
109
+		$this->createdPages[ ] = $title;
112 110
 	}
113 111
 }
Please login to merge, or discard this patch.
includes/Task/StartVote.php 1 patch
Spacing   +16 added lines, -16 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
 
@@ -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 StartVote' );
18 18
 
19 19
 		$pages = $this->getDataProvider()->getOpenPages();
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	/**
32 32
 	 * @param string[] $pages
33 33
 	 */
34
-	protected function processPages( array $pages ) {
35
-		$actualPages = [];
34
+	protected function processPages ( array $pages ) {
35
+		$actualPages = [ ];
36 36
 		foreach ( $pages as $page ) {
37 37
 			if ( WikiController::hasOpposition( $page ) ) {
38 38
 				try {
39 39
 					$this->openVote( $page );
40
-					$actualPages[] = $page;
40
+					$actualPages[ ] = $page;
41 41
 				} catch ( TaskException $e ) {
42 42
 					$this->getLogger()->warning( $e->getMessage() );
43 43
 				}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @param string $title
59 59
 	 * @throws TaskException
60 60
 	 */
61
-	protected function openVote( string $title ) {
61
+	protected function openVote ( string $title ) {
62 62
 		$this->getLogger()->info( "Starting vote on $title" );
63 63
 
64 64
 		$content = $this->getController()->getPageContent( $title );
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @see ClosePages::updateVote()
102 102
 	 * @see UpdatesAround::addVote()
103 103
 	 */
104
-	protected function updateVotePage( array $titles ) {
104
+	protected function updateVotePage ( array $titles ) {
105 105
 		$votePage = $this->getConfig()->get( 'ric-vote-page' );
106 106
 		$content = $this->getController()->getPageContent( $votePage );
107 107
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		$newLines = '';
117 117
 		$time = WikiController::getTimeWithArticle( time() + ( 60 * 60 * 24 * 14 ) );
118 118
 		foreach ( $titles as $title ) {
119
-			$user = explode( '/', $title )[2];
119
+			$user = explode( '/', $title )[ 2 ];
120 120
 			$newLines .= "*[[Utente:$user|]]. La [[$title|votazione]] termina $time;\n";
121 121
 		}
122 122
 
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
127 127
 		} else {
128 128
 			// Start section
129
-			$matches = [];
129
+			$matches = [ ];
130 130
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
131 131
 				throw new TaskException( 'Intro not found in vote page' );
132 132
 			}
133 133
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
134 134
 			// Replace semicolon with full stop
135 135
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
136
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
136
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
137 137
 		}
138 138
 
139 139
 		$summary = strtr(
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 		$summary = preg_replace_callback(
144 144
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
145 145
 			function ( $matches ) {
146
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
146
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
147 147
 			},
148 148
 			$summary
149 149
 		);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @see UpdatesAround::addNews()
165 165
 	 * @see ClosePages::updateNews()
166 166
 	 */
167
-	protected function updateNews( int $amount ) {
167
+	protected function updateNews ( int $amount ) {
168 168
 		$this->getLogger()->info( "Turning $amount pages into votes" );
169 169
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
170 170
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		$regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
173 173
 		$regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!';
174 174
 
175
-		$tacMatches = $votMatches = [];
175
+		$tacMatches = $votMatches = [ ];
176 176
 		if ( preg_match( $regTac, $content, $tacMatches ) === false ) {
177 177
 			throw new TaskException( 'Param "tacite" not found in news page' );
178 178
 		}
@@ -180,8 +180,8 @@  discard block
 block discarded – undo
180 180
 			throw new TaskException( 'Param "voto" not found in news page' );
181 181
 		}
182 182
 
183
-		$newTac = (int)$tacMatches[2] - $amount;
184
-		$newVot = (int)$votMatches[2] + $amount;
183
+		$newTac = (int)$tacMatches[ 2 ] - $amount;
184
+		$newVot = (int)$votMatches[ 2 ] + $amount;
185 185
 
186 186
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
187 187
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 		$summary = preg_replace_callback(
194 194
 			'!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!',
195 195
 			function ( $matches ) {
196
-				return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] );
196
+				return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] );
197 197
 			},
198 198
 			$summary
199 199
 		);
Please login to merge, or discard this patch.