Passed
Push — master ( 8584e7...c84974 )
by Daimona
01:53
created
includes/Wiki/Page/PageRiconferma.php 1 patch
Spacing   +22 added lines, -22 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
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	private $supportSection;
14 14
 	private $opposeSection;
15 15
 	/** @var array Counts of votes for each section */
16
-	private $sectionCounts = [];
16
+	private $sectionCounts = [ ];
17 17
 
18 18
 	// Possible outcomes of a vote
19 19
 	public const OUTCOME_OK = 0;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * because they can vary depending on whether the page is a vote, which is relatively
33 33
 	 * expensive to know since it requires parsing the content of the page.
34 34
 	 */
35
-	private function defineSections() {
35
+	private function defineSections () {
36 36
 		$this->supportSection = $this->isVote() ? 3 : 0;
37 37
 		$this->opposeSection = $this->isVote() ? 4 : 3;
38 38
 	}
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return User
44 44
 	 */
45
-	public function getUser() : User {
46
-		$name = explode( '/', $this->title )[2];
45
+	public function getUser () : User {
46
+		$name = explode( '/', $this->title )[ 2 ];
47 47
 		return new User( $name, $this->wiki );
48 48
 	}
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return int
54 54
 	 */
55
-	public function getNum() : int {
55
+	public function getNum () : int {
56 56
 		$bits = explode( '/', $this->getTitle() );
57 57
 		return intval( end( $bits ) );
58 58
 	}
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return string
64 64
 	 */
65
-	public function getUserNum() : string {
66
-		return explode( '/', $this->getTitle(), 3 )[2];
65
+	public function getUserNum () : string {
66
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
67 67
 	}
68 68
 
69 69
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string
73 73
 	 */
74
-	public function getBaseTitle() : string {
74
+	public function getBaseTitle () : string {
75 75
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
76 76
 	}
77 77
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return int
82 82
 	 */
83
-	public function getOpposingCount() : int {
83
+	public function getOpposingCount () : int {
84 84
 		$this->defineSections();
85 85
 		return $this->getCountForSection( $this->opposeSection );
86 86
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return int
92 92
 	 * @throws \BadMethodCallException
93 93
 	 */
94
-	public function getSupportCount() : int {
94
+	public function getSupportCount () : int {
95 95
 		if ( !$this->isVote() ) {
96 96
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
97 97
 		}
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	 * @param int $secNum
106 106
 	 * @return int
107 107
 	 */
108
-	protected function getCountForSection( int $secNum ) : int {
108
+	protected function getCountForSection ( int $secNum ) : int {
109 109
 		if ( !isset( $this->sectionCounts[ $secNum ] ) ) {
110 110
 			$content = $this->wiki->getPageContent( $this->title, $secNum );
111 111
 			// Let's hope that this is good enough...
112
-			$this->sectionCounts[$secNum] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content );
112
+			$this->sectionCounts[ $secNum ] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content );
113 113
 		}
114
-		return $this->sectionCounts[$secNum];
114
+		return $this->sectionCounts[ $secNum ];
115 115
 	}
116 116
 
117 117
 	/**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return int
121 121
 	 */
122
-	protected function getQuorum() : int {
122
+	protected function getQuorum () : int {
123 123
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
124
-		return intval( $this->getMatch( $reg )[1] );
124
+		return intval( $this->getMatch( $reg )[ 1 ] );
125 125
 	}
126 126
 
127 127
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return bool
131 131
 	 */
132
-	public function hasOpposition() : bool {
132
+	public function hasOpposition () : bool {
133 133
 		return $this->getOpposingCount() >= self::REQUIRED_OPPOSE;
134 134
 	}
135 135
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return int One of the OUTCOME_* constants
140 140
 	 */
141
-	public function getOutcome() : int {
141
+	public function getOutcome () : int {
142 142
 		if ( !$this->isVote() ) {
143 143
 			return self::OUTCOME_OK;
144 144
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @throws \BadMethodCallException
162 162
 	 * @throws \LogicException
163 163
 	 */
164
-	public function getOutcomeText() : string {
164
+	public function getOutcomeText () : string {
165 165
 		if ( !$this->isVote() ) {
166 166
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
167 167
 		}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 *
196 196
 	 * @return bool
197 197
 	 */
198
-	public function isVote() : bool {
198
+	public function isVote () : bool {
199 199
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
200 200
 		return !$this->matches( $sectionReg );
201 201
 	}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @return int
207 207
 	 */
208
-	public function getCreationTimestamp() : int {
208
+	public function getCreationTimestamp () : int {
209 209
 		return $this->wiki->getPageCreationTS( $this->title );
210 210
 	}
211 211
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @return int
216 216
 	 */
217
-	public function getEndTimestamp() : int {
217
+	public function getEndTimestamp () : int {
218 218
 		if ( $this->isVote() ) {
219 219
 			$reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!";
220 220
 			list( , $hours, $day ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.
includes/Wiki/Element.php 1 patch
Spacing   +6 added lines, -6 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;
4 4
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	/**
13 13
 	 * @param Wiki $wiki
14 14
 	 */
15
-	public function __construct( Wiki $wiki ) {
15
+	public function __construct ( Wiki $wiki ) {
16 16
 		$this->wiki = $wiki;
17 17
 	}
18 18
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return string
23 23
 	 */
24
-	abstract public function getRegex() : string;
24
+	abstract public function getRegex () : string;
25 25
 
26 26
 	/**
27 27
 	 * Get a regex matching any element in the given array
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	 * @return string
31 31
 	 * @todo Is this the right place?
32 32
 	 */
33
-	public static function regexFromArray( array $elements ) : string {
34
-		$bits = [];
33
+	public static function regexFromArray ( array $elements ) : string {
34
+		$bits = [ ];
35 35
 		foreach ( $elements as $el ) {
36
-			$bits[] = $el->getRegex();
36
+			$bits[ ] = $el->getRegex();
37 37
 		}
38 38
 		return '(?:' . implode( '|', $bits ) . ')';
39 39
 	}
Please login to merge, or discard this patch.
includes/Task/UpdateList.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;
4 4
 
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 	/**
20 20
 	 * @inheritDoc
21 21
 	 */
22
-	protected function getSubtasksMap(): array {
22
+	protected function getSubtasksMap (): array {
23 23
 		// Everything is done here.
24
-		return [];
24
+		return [ ];
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * @inheritDoc
29 29
 	 */
30
-	public function runInternal() : int {
30
+	public function runInternal () : int {
31 31
 		$this->actualList = $this->getActualAdmins();
32 32
 		$pageBotList = PageBotList::get( $this->getWiki() );
33 33
 		$this->botList = $pageBotList->getAdminsList();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * @return array
56 56
 	 */
57
-	protected function getActualAdmins() : array {
57
+	protected function getActualAdmins () : array {
58 58
 		$params = [
59 59
 			'action' => 'query',
60 60
 			'list' => 'allusers',
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param \stdClass $data
72 72
 	 * @return array
73 73
 	 */
74
-	protected function extractAdmins( \stdClass $data ) : array {
75
-		$ret = [];
74
+	protected function extractAdmins ( \stdClass $data ) : array {
75
+		$ret = [ ];
76 76
 		$blacklist = $this->getOpt( 'exclude-admins' );
77 77
 		foreach ( $data->query->allusers as $u ) {
78 78
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return array[]
91 91
 	 */
92
-	protected function getMissingGroups() : array {
93
-		$missing = [];
92
+	protected function getMissingGroups () : array {
93
+		$missing = [ ];
94 94
 		foreach ( $this->actualList as $adm => $groups ) {
95
-			$curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) );
95
+			$curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) );
96 96
 
97 97
 			foreach ( $curMissing as $group ) {
98 98
 				try {
99 99
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
100 100
 				} catch ( TaskException $e ) {
101
-					$this->errors[] = $e->getMessage();
101
+					$this->errors[ ] = $e->getMessage();
102 102
 				}
103 103
 			}
104 104
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @return string
114 114
 	 * @throws TaskException
115 115
 	 */
116
-	protected function getFlagDate( string $admin, string $group ) : string {
116
+	protected function getFlagDate ( string $admin, string $group ) : string {
117 117
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
118 118
 
119 119
 		$url = DEFAULT_URL;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param string $group
150 150
 	 * @return string|null
151 151
 	 */
152
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
152
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
153 153
 		$ts = null;
154 154
 		foreach ( $data->query->logevents as $entry ) {
155 155
 			if ( isset( $entry->params ) ) {
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return array[]
170 170
 	 */
171
-	protected function getExtraGroups() : array {
172
-		$extra = [];
171
+	protected function getExtraGroups () : array {
172
+		$extra = [ ];
173 173
 		foreach ( $this->botList as $name => $groups ) {
174 174
 			// These are not groups
175 175
 			unset( $groups[ 'override' ], $groups[ 'override-perm' ] );
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param array[] $extra
190 190
 	 * @return array[]
191 191
 	 */
192
-	protected function getNewContent( array $missing, array $extra ) : array {
192
+	protected function getNewContent ( array $missing, array $extra ) : array {
193 193
 		$newContent = $this->botList;
194 194
 		foreach ( $newContent as $user => $groups ) {
195 195
 			if ( isset( $missing[ $user ] ) ) {
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	 * @param array[] $newContent
214 214
 	 * @return array[]
215 215
 	 */
216
-	protected function removeOverrides( array $newContent ) : array {
217
-		$removed = [];
216
+	protected function removeOverrides ( array $newContent ) : array {
217
+		$removed = [ ];
218 218
 		foreach ( $newContent as $user => $groups ) {
219
-			if ( !isset( $groups['override'] ) ) {
219
+			if ( !isset( $groups[ 'override' ] ) ) {
220 220
 				continue;
221 221
 			}
222 222
 
223 223
 			$flagTS = PageBotList::getValidFlagTimestamp( $groups );
224 224
 			$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
225
-			$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
225
+			$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
226 226
 			$delay = 60 * 60 * 24 * 3;
227 227
 
228 228
 			if ( time() > $usualTS + $delay && time() > $overrideTS + $delay ) {
229 229
 				unset( $newContent[ $user ][ 'override' ] );
230
-				$removed[] = $user;
230
+				$removed[ ] = $user;
231 231
 			}
232 232
 		}
233 233
 
Please login to merge, or discard this patch.
includes/Task/Task.php 1 patch
Spacing   +5 added lines, -5 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
 
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @return string[]
16 16
 	 */
17
-	abstract protected function getSubtasksMap() : array;
17
+	abstract protected function getSubtasksMap () : array;
18 18
 
19 19
 	/**
20 20
 	 * @param string $subtask Defined in self::SUBTASKS_MAP
21 21
 	 * @return TaskResult
22 22
 	 */
23
-	protected function runSubtask( string $subtask ) : TaskResult {
23
+	protected function runSubtask ( string $subtask ) : TaskResult {
24 24
 		$map = $this->getSubtasksMap();
25 25
 		if ( !isset( $map[ $subtask ] ) ) {
26 26
 			throw new \InvalidArgumentException( "'$subtask' is not a valid task." );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @inheritDoc
35 35
 	 */
36
-	final public function getOperationName(): string {
36
+	final public function getOperationName (): string {
37 37
 		return 'task';
38 38
 	}
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param string $class
44 44
 	 * @return Subtask
45 45
 	 */
46
-	private function getSubtaskInstance( string $class ) : Subtask {
46
+	private function getSubtaskInstance ( string $class ) : Subtask {
47 47
 		return new $class( $this->getLogger(), $this->getWiki(), $this->getDataProvider() );
48 48
 	}
49 49
 }
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 = new User( $username, $this->getWiki() );
117 117
 			$userReg = $user->getRegex();
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 					'${1}' . date( '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
 		$groups = $user->getGroupsWithDates();
154
-		if ( isset( $groups['override-perm'] ) ) {
154
+		if ( isset( $groups[ 'override-perm' ] ) ) {
155 155
 			$date = \DateTime::createFromFormat(
156 156
 				'd/m/Y',
157
-				$groups['override-perm'] . '/' . date( 'Y' )
157
+				$groups[ '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( $groups );
165 165
 			$res = strtotime( date( 'Y', strtotime( '+1 year' ) ) . date( '-m-d', $ts ) );
166
-			if ( isset( $groups['override'] ) ) {
167
-				$date = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] );
166
+			if ( isset( $groups[ 'override' ] ) ) {
167
+				$date = \DateTime::createFromFormat( 'd/m/Y', $groups[ '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 = ( new User( $user, $this->getWiki() ) )->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/Task/Subtask/FailedUpdates.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\Subtask;
4 4
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @inheritDoc
19 19
 	 */
20
-	public function runInternal() : int {
20
+	public function runInternal () : int {
21 21
 		$failed = $this->getFailures();
22 22
 		if ( !$failed ) {
23 23
 			return TaskResult::STATUS_NOTHING;
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @return PageRiconferma[]
41 41
 	 */
42
-	private function getFailures() : array {
43
-		$ret = [];
42
+	private function getFailures () : array {
43
+		$ret = [ ];
44 44
 		$allPages = $this->getDataProvider()->getPagesToClose();
45 45
 		foreach ( $allPages as $page ) {
46 46
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
47
-				$ret[] = $page;
47
+				$ret[ ] = $page;
48 48
 			}
49 49
 		}
50 50
 		return $ret;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * @param User[] $users
55 55
 	 */
56
-	protected function updateBurList( array $users ) {
56
+	protected function updateBurList ( array $users ) {
57 57
 		$this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) );
58 58
 		$remList = Element::regexFromArray( $users );
59 59
 		$burList = $this->getPage( $this->getOpt( 'bur-list-title' ) );
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param PageRiconferma[] $pages
78 78
 	 */
79
-	protected function requestRemoval( array $pages ) {
79
+	protected function requestRemoval ( array $pages ) {
80 80
 		$this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) );
81 81
 
82 82
 		$metaWiki = new Wiki( $this->getLogger(), META_URL );
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @param PageRiconferma[] $pages
115 115
 	 */
116
-	protected function updateAnnunci( array $pages ) {
116
+	protected function updateAnnunci ( array $pages ) {
117 117
 		$this->getLogger()->info( 'Updating annunci' );
118 118
 		$section = 1;
119 119
 
120
-		$names = [];
120
+		$names = [ ];
121 121
 		$text = '';
122 122
 		foreach ( $pages as $page ) {
123 123
 			$user = $page->getUser()->getName();
124
-			$names[] = $user;
124
+			$names[ ] = $user;
125 125
 			$text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text();
126 126
 		}
127 127
 
@@ -153,16 +153,16 @@  discard block
 block discarded – undo
153 153
 	 *
154 154
 	 * @param PageRiconferma[] $pages
155 155
 	 */
156
-	protected function updateUltimeNotizie( array $pages ) {
156
+	protected function updateUltimeNotizie ( array $pages ) {
157 157
 		$this->getLogger()->info( 'Updating ultime notizie' );
158 158
 		$notiziePage = $this->getPage( $this->getOpt( 'ultimenotizie-page-title' ) );
159 159
 
160
-		$names = [];
160
+		$names = [ ];
161 161
 		$text = '';
162 162
 		$msg = $this->msg( 'ultimenotizie-text' );
163 163
 		foreach ( $pages as $page ) {
164 164
 			$user = $page->getUser()->getName();
165
-			$names[] = $user;
165
+			$names[ ] = $user;
166 166
 			$text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text();
167 167
 		}
168 168
 
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 	 * @param PageRiconferma[] $pages
192 192
 	 * @return User[]
193 193
 	 */
194
-	private function getFailedBureaucrats( array $pages ) : array {
195
-		$ret = [];
194
+	private function getFailedBureaucrats ( array $pages ) : array {
195
+		$ret = [ ];
196 196
 		foreach ( $pages as $page ) {
197 197
 			$user = $page->getUser();
198 198
 			if ( $user->inGroup( 'bureaucrat' ) ) {
199
-				$ret[] = $user;
199
+				$ret[ ] = $user;
200 200
 			}
201 201
 		}
202 202
 		return $ret;
Please login to merge, or discard this patch.
includes/Task/TaskBase.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\Task;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class TaskBase extends ContextSource {
15 15
 	/** @var string[] */
16
-	protected $errors = [];
16
+	protected $errors = [ ];
17 17
 	/** @var TaskDataProvider */
18 18
 	protected $dataProvider;
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param Wiki $wiki
25 25
 	 * @param TaskDataProvider $dataProvider
26 26
 	 */
27
-	final public function __construct(
27
+	final public function __construct (
28 28
 		LoggerInterface $logger,
29 29
 		Wiki $wiki,
30 30
 		TaskDataProvider $dataProvider
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		$this->dataProvider = $dataProvider;
36 36
 	}
37 37
 
38
-	public function __destruct() {
38
+	public function __destruct () {
39 39
 		restore_error_handler();
40 40
 		restore_exception_handler();
41 41
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return TaskResult
47 47
 	 */
48
-	final public function run() : TaskResult {
48
+	final public function run () : TaskResult {
49 49
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
50 50
 		$opName = $this->getOperationName();
51 51
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return int One of the STATUS_* constants
78 78
 	 */
79
-	abstract protected function runInternal() : int;
79
+	abstract protected function runInternal () : int;
80 80
 
81 81
 	/**
82 82
 	 * How this operation should be called in logs
83 83
 	 *
84 84
 	 * @return string
85 85
 	 */
86
-	abstract public function getOperationName() : string;
86
+	abstract public function getOperationName () : string;
87 87
 
88 88
 	/**
89 89
 	 * Exception handler.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param \Throwable $ex
92 92
 	 * @protected
93 93
 	 */
94
-	public function handleException( \Throwable $ex ) {
94
+	public function handleException ( \Throwable $ex ) {
95 95
 		$this->getLogger()->error(
96 96
 			( new \ReflectionClass( $ex ) )->getShortName() . ': ' .
97 97
 			$ex->getMessage() . "\nin " . $ex->getFile() . ' line ' .
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
 	 * @throws \ErrorException
110 110
 	 * @protected
111 111
 	 */
112
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
112
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
113 113
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
114 114
 	}
115 115
 
116 116
 	/**
117 117
 	 * @return TaskDataProvider
118 118
 	 */
119
-	protected function getDataProvider() : TaskDataProvider {
119
+	protected function getDataProvider () : TaskDataProvider {
120 120
 		return $this->dataProvider;
121 121
 	}
122 122
 }
Please login to merge, or discard this patch.
includes/TaskManager.php 1 patch
Spacing   +8 added lines, -8 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
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 * @param LoggerInterface $logger
56 56
 	 * @param Wiki $wiki
57 57
 	 */
58
-	public function __construct( LoggerInterface $logger, Wiki $wiki ) {
58
+	public function __construct ( LoggerInterface $logger, Wiki $wiki ) {
59 59
 		$this->logger = $logger;
60 60
 		$this->wiki = $wiki;
61 61
 		$this->provider = new TaskDataProvider( $this->logger, $this->wiki );
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
69 69
 	 * @return TaskResult
70 70
 	 */
71
-	public function run( string $mode, string $name = null ) : TaskResult {
71
+	public function run ( string $mode, string $name = null ) : TaskResult {
72 72
 		if ( $mode === self::MODE_COMPLETE ) {
73 73
 			return $this->runAllTasks();
74 74
 		} elseif ( $name === null ) {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return TaskResult
85 85
 	 */
86
-	protected function runAllTasks() : TaskResult {
86
+	protected function runAllTasks () : TaskResult {
87 87
 		$orderedList = [
88 88
 			'update-list',
89 89
 			'start-new',
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @param string $name
106 106
 	 * @return TaskResult
107 107
 	 */
108
-	protected function runTask( string $name ) : TaskResult {
108
+	protected function runTask ( string $name ) : TaskResult {
109 109
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
110 110
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
111 111
 		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 * @param string $name
121 121
 	 * @return TaskResult
122 122
 	 */
123
-	protected function runSubtask( string $name ) : TaskResult {
123
+	protected function runSubtask ( string $name ) : TaskResult {
124 124
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
125 125
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
126 126
 		}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @param string $class
136 136
 	 * @return Task
137 137
 	 */
138
-	private function getTaskInstance( string $class ) : Task {
138
+	private function getTaskInstance ( string $class ) : Task {
139 139
 		return new $class( $this->logger, $this->wiki, $this->provider );
140 140
 	}
141 141
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $class
146 146
 	 * @return Subtask
147 147
 	 */
148
-	private function getSubtaskInstance( string $class ) : Subtask {
148
+	private function getSubtaskInstance ( string $class ) : Subtask {
149 149
 		return new $class( $this->logger, $this->wiki, $this->provider );
150 150
 	}
151 151
 }
Please login to merge, or discard this patch.
includes/Bot.php 1 patch
Spacing   +7 added lines, -8 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
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param LoggerInterface $logger
21 21
 	 * @param Wiki $wiki
22 22
 	 */
23
-	public function __construct( LoggerInterface $logger, Wiki $wiki ) {
23
+	public function __construct ( LoggerInterface $logger, Wiki $wiki ) {
24 24
 		$this->logger = $logger;
25 25
 		$this->wiki = $wiki;
26 26
 	}
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $mode
32 32
 	 * @param string|null $name
33 33
 	 */
34
-	private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
34
+	private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
35 35
 		$activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name";
36 36
 		$this->logger->info( "Running $activity" );
37 37
 		$manager = new TaskManager( $this->logger, $this->wiki );
@@ -40,8 +40,7 @@  discard block
 block discarded – undo
40 40
 		$base = "Execution of $activity";
41 41
 		if ( $res->isOK() ) {
42 42
 			$msg = $res->getStatus() === TaskResult::STATUS_NOTHING ?
43
-				': nothing to do' :
44
-				' completed successfully';
43
+				': nothing to do' : ' completed successfully';
45 44
 			$this->logger->info( $base . $msg . ".\n$line\n\n" );
46 45
 		} else {
47 46
 			$this->logger->error( "$base failed.\n$res\n$line\n\n" );
@@ -51,7 +50,7 @@  discard block
 block discarded – undo
51 50
 	/**
52 51
 	 * Entry point for the whole process
53 52
 	 */
54
-	public function runAll() {
53
+	public function runAll () {
55 54
 		$this->run();
56 55
 	}
57 56
 
@@ -60,7 +59,7 @@  discard block
 block discarded – undo
60 59
 	 *
61 60
 	 * @param string $task
62 61
 	 */
63
-	public function runTask( string $task ) {
62
+	public function runTask ( string $task ) {
64 63
 		$this->run( TaskManager::MODE_TASK, $task );
65 64
 	}
66 65
 
@@ -69,7 +68,7 @@  discard block
 block discarded – undo
69 68
 	 *
70 69
 	 * @param string $subtask
71 70
 	 */
72
-	public function runSubtask( string $subtask ) {
71
+	public function runSubtask ( string $subtask ) {
73 72
 		$this->run( TaskManager::MODE_SUBTASK, $subtask );
74 73
 	}
75 74
 }
Please login to merge, or discard this patch.