Passed
Push — master ( 70f962...881d3c )
by Daimona
01:31
created
includes/Task/StartVote.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\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 runInternal() : int {
26
+	public function runInternal () : int {
27 27
 		$pages = $this->getDataProvider()->getOpenPages();
28 28
 
29 29
 		if ( !$pages ) {
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 * @param PageRiconferma[] $pages
38 38
 	 * @return int a STATUS_* constant
39 39
 	 */
40
-	protected function processPages( array $pages ) : int {
41
-		$donePages = [];
40
+	protected function processPages ( array $pages ) : int {
41
+		$donePages = [ ];
42 42
 		foreach ( $pages as $page ) {
43 43
 			if ( $page->hasOpposition() && !$page->isVote() ) {
44 44
 				$this->openVote( $page );
45
-				$donePages[] = $page;
45
+				$donePages[ ] = $page;
46 46
 			}
47 47
 		}
48 48
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param PageRiconferma $page
62 62
 	 */
63
-	protected function openVote( PageRiconferma $page ) {
63
+	protected function openVote ( PageRiconferma $page ) {
64 64
 		$this->getLogger()->info( "Starting vote on $page" );
65 65
 
66 66
 		$content = $page->getContent();
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 	 * @see SimpleUpdates::updateVotazioni()
100 100
 	 * @see OpenUpdates::addToVotazioni()
101 101
 	 */
102
-	protected function updateVotazioni( array $pages ) {
102
+	protected function updateVotazioni ( array $pages ) {
103 103
 		$votePage = new Page( $this->getOpt( 'vote-page-title' ) );
104 104
 
105
-		$users = [];
105
+		$users = [ ];
106 106
 		foreach ( $pages as $page ) {
107
-			$users[] = $page->getUser();
107
+			$users[ ] = $page->getUser();
108 108
 		}
109 109
 		$usersReg = Element::regexFromArray( $users );
110 110
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @see SimpleUpdates::updateNews()
143 143
 	 * @see OpenUpdates::addToNews()
144 144
 	 */
145
-	protected function updateNews( int $amount ) {
145
+	protected function updateNews ( int $amount ) {
146 146
 		$this->getLogger()->info( "Turning $amount pages into votes" );
147 147
 		$newsPage = new Page( $this->getOpt( 'news-page-title' ) );
148 148
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 			throw new TaskException( 'Param "voto" not found in news page' );
158 158
 		}
159 159
 
160
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
161
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
160
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
161
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
162 162
 
163 163
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
164 164
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Wiki/Controller.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\Wiki;
4 4
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @param string $domain The URL of the wiki, if different from default
29 29
 	 */
30
-	public function __construct( string $domain = DEFAULT_URL ) {
30
+	public function __construct ( string $domain = DEFAULT_URL ) {
31 31
 		$this->logger = new Logger;
32 32
 		$this->domain = $domain;
33 33
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @throws MissingPageException
42 42
 	 * @throws MissingSectionException
43 43
 	 */
44
-	public function getPageContent( string $title, int $section = null ) : string {
44
+	public function getPageContent ( string $title, int $section = null ) : string {
45 45
 		$msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' );
46 46
 		$this->logger->debug( $msg );
47 47
 		$params = [
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		];
54 54
 
55 55
 		if ( $section !== null ) {
56
-			$params['rvsection'] = $section;
56
+			$params[ 'rvsection' ] = $section;
57 57
 		}
58 58
 
59 59
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			throw new MissingPageException( $title );
64 64
 		}
65 65
 
66
-		$mainSlot = $page->revisions[0]->slots->main;
66
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
67 67
 
68 68
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
69 69
 			throw new MissingSectionException( $title, $section );
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param array $params
78 78
 	 * @throws EditException
79 79
 	 */
80
-	public function editPage( array $params ) {
80
+	public function editPage ( array $params ) {
81 81
 		$this->login();
82 82
 
83 83
 		$params = [
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 		] + $params;
87 87
 
88 88
 		if ( Config::getInstance()->get( 'bot-edits' ) ) {
89
-			$params['bot'] = 1;
89
+			$params[ 'bot' ] = 1;
90 90
 		}
91 91
 
92 92
 		$res = RequestBase::newFromParams( $params )
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
108 108
 	 * @throws LoginException
109 109
 	 */
110
-	public function login() {
110
+	public function login () {
111 111
 		if ( self::$loggedIn ) {
112 112
 			return;
113 113
 		}
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 		self::$loggedIn = true;
136 136
 		// Clear tokens cache
137
-		$this->tokens = [];
137
+		$this->tokens = [ ];
138 138
 		$this->logger->info( 'Login succeeded' );
139 139
 	}
140 140
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @param string $type
145 145
 	 * @return string
146 146
 	 */
147
-	public function getToken( string $type ) : string {
147
+	public function getToken ( string $type ) : string {
148 148
 		if ( !isset( $this->tokens[ $type ] ) ) {
149 149
 			$params = [
150 150
 				'action' => 'query',
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param string $title
168 168
 	 * @return int
169 169
 	 */
170
-	public function getPageCreationTS( string $title ) : int {
170
+	public function getPageCreationTS ( string $title ) : int {
171 171
 		$params = [
172 172
 			'action' => 'query',
173 173
 			'prop' => 'revisions',
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
182 182
 		$data = $res->query->pages;
183
-		return strtotime( reset( $data )->revisions[0]->timestamp );
183
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
184 184
 	}
185 185
 
186 186
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param string $title
190 190
 	 * @param string $reason
191 191
 	 */
192
-	public function protectPage( string $title, string $reason ) {
192
+	public function protectPage ( string $title, string $reason ) {
193 193
 		$this->logger->info( "Protecting page $title" );
194 194
 		$this->login();
195 195
 
Please login to merge, or discard this patch.
includes/Logger.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;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @param string $minlevel
17 17
 	 */
18
-	public function __construct( $minlevel = LogLevel::INFO ) {
18
+	public function __construct ( $minlevel = LogLevel::INFO ) {
19 19
 		$this->minLevel = $this->levelToInt( $minlevel );
20 20
 	}
21 21
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param string $level
26 26
 	 * @return int
27 27
 	 */
28
-	private function levelToInt( string $level ) : int {
28
+	private function levelToInt ( string $level ) : int {
29 29
 		// Order matters
30 30
 		$mapping = [
31 31
 			LogLevel::DEBUG,
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	/**
44 44
 	 * @inheritDoc
45 45
 	 */
46
-	public function log( $level, $message, array $context = [] ) {
46
+	public function log ( $level, $message, array $context = [ ] ) {
47 47
 		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
48 48
 			printf( "%s [%s] - %s\n", date( 'd M H:i:s' ), $level, $message );
49 49
 		}
Please login to merge, or discard this patch.
includes/Task/Subtask/ClosePages.php 1 patch
Spacing   +5 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\Task\Subtask;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 
20 20
 		if ( !$pages ) {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	/**
37 37
 	 * @param PageRiconferma $page
38 38
 	 */
39
-	protected function addVoteCloseText( PageRiconferma $page ) {
39
+	protected function addVoteCloseText ( PageRiconferma $page ) {
40 40
 		$content = $page->getContent();
41 41
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
42 42
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -51,15 +51,14 @@  discard block
 block discarded – undo
51 51
 	 * @param PageRiconferma $page
52 52
 	 * @see CreatePages::updateBasePage()
53 53
 	 */
54
-	protected function updateBasePage( PageRiconferma $page ) {
54
+	protected function updateBasePage ( PageRiconferma $page ) {
55 55
 		$this->getLogger()->info( "Updating base page for $page" );
56 56
 
57 57
 		$basePage = new Page( $page->getBaseTitle() );
58 58
 		$current = $basePage->getContent();
59 59
 
60 60
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
61
-			'non riconfermato' :
62
-			'riconfermato';
61
+			'non riconfermato' : 'riconfermato';
63 62
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
64 63
 
65 64
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
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
 
@@ -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
 		$failed = $this->getFailures();
21 21
 		if ( !$failed ) {
22 22
 			return TaskResult::STATUS_NOTHING;
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return PageRiconferma[]
40 40
 	 */
41
-	private function getFailures() : array {
42
-		$ret = [];
41
+	private function getFailures () : array {
42
+		$ret = [ ];
43 43
 		$allPages = $this->getDataProvider()->getPagesToClose();
44 44
 		foreach ( $allPages as $page ) {
45 45
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
46
-				$ret[] = $page;
46
+				$ret[ ] = $page;
47 47
 			}
48 48
 		}
49 49
 		return $ret;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @param User[] $users
54 54
 	 */
55
-	protected function updateBurList( array $users ) {
55
+	protected function updateBurList ( array $users ) {
56 56
 		$this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) );
57 57
 		$remList = Element::regexFromArray( $users );
58 58
 		$burList = new Page( $this->getOpt( 'bur-list-title' ) );
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @param PageRiconferma[] $pages
77 77
 	 */
78
-	protected function requestRemoval( array $pages ) {
78
+	protected function requestRemoval ( array $pages ) {
79 79
 		$this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) );
80 80
 
81 81
 		$flagRemPage = new Page(
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @param PageRiconferma[] $pages
113 113
 	 */
114
-	protected function updateAnnunci( array $pages ) {
114
+	protected function updateAnnunci ( array $pages ) {
115 115
 		$this->getLogger()->info( 'Updating annunci' );
116 116
 		$section = 1;
117 117
 
118
-		$names = [];
118
+		$names = [ ];
119 119
 		$text = '';
120 120
 		foreach ( $pages as $page ) {
121 121
 			$user = $page->getUser()->getName();
122
-			$names[] = $user;
122
+			$names[ ] = $user;
123 123
 			$text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text();
124 124
 		}
125 125
 
@@ -151,16 +151,16 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param PageRiconferma[] $pages
153 153
 	 */
154
-	protected function updateUltimeNotizie( array $pages ) {
154
+	protected function updateUltimeNotizie ( array $pages ) {
155 155
 		$this->getLogger()->info( 'Updating ultime notizie' );
156 156
 		$notiziePage = new Page( $this->getOpt( 'ultimenotizie-page-title' ) );
157 157
 
158
-		$names = [];
158
+		$names = [ ];
159 159
 		$text = '';
160 160
 		$msg = $this->msg( 'ultimenotizie-text' );
161 161
 		foreach ( $pages as $page ) {
162 162
 			$user = $page->getUser()->getName();
163
-			$names[] = $user;
163
+			$names[ ] = $user;
164 164
 			$text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text();
165 165
 		}
166 166
 
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 	 * @param PageRiconferma[] $pages
190 190
 	 * @return User[]
191 191
 	 */
192
-	private function getFailedBureaucrats( array $pages ) : array {
193
-		$ret = [];
192
+	private function getFailedBureaucrats ( array $pages ) : array {
193
+		$ret = [ ];
194 194
 		foreach ( $pages as $page ) {
195 195
 			$user = $page->getUser();
196 196
 			if ( $user->inGroup( 'bureaucrat' ) ) {
197
-				$ret[] = $user;
197
+				$ret[ ] = $user;
198 198
 			}
199 199
 		}
200 200
 		return $ret;
Please login to merge, or discard this patch.
includes/Task/UpdateList.php 1 patch
Spacing   +20 added lines, -20 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
 		$this->botList = PageBotList::get()->getAdminsList();
33 33
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * @return array
55 55
 	 */
56
-	protected function getActualAdmins() : array {
56
+	protected function getActualAdmins () : array {
57 57
 		$params = [
58 58
 			'action' => 'query',
59 59
 			'list' => 'allusers',
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 	 * @param \stdClass $data
71 71
 	 * @return array
72 72
 	 */
73
-	protected function extractAdmins( \stdClass $data ) : array {
74
-		$ret = [];
73
+	protected function extractAdmins ( \stdClass $data ) : array {
74
+		$ret = [ ];
75 75
 		$blacklist = $this->getOpt( 'exclude-admins' );
76 76
 		foreach ( $data->query->allusers as $u ) {
77 77
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return array[]
90 90
 	 */
91
-	protected function getMissingGroups() : array {
92
-		$missing = [];
91
+	protected function getMissingGroups () : array {
92
+		$missing = [ ];
93 93
 		foreach ( $this->actualList as $adm => $groups ) {
94
-			$curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) );
94
+			$curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) );
95 95
 
96 96
 			foreach ( $curMissing as $group ) {
97 97
 				try {
98 98
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
99 99
 				} catch ( TaskException $e ) {
100
-					$this->errors[] = $e->getMessage();
100
+					$this->errors[ ] = $e->getMessage();
101 101
 				}
102 102
 			}
103 103
 		}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @return string
113 113
 	 * @throws TaskException
114 114
 	 */
115
-	protected function getFlagDate( string $admin, string $group ) : string {
115
+	protected function getFlagDate ( string $admin, string $group ) : string {
116 116
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
117 117
 
118 118
 		$url = DEFAULT_URL;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @param string $group
148 148
 	 * @return string|null
149 149
 	 */
150
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
150
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
151 151
 		$ts = null;
152 152
 		foreach ( $data->query->logevents as $entry ) {
153 153
 			if ( isset( $entry->params ) ) {
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return array[]
168 168
 	 */
169
-	protected function getExtraGroups() : array {
170
-		$extra = [];
169
+	protected function getExtraGroups () : array {
170
+		$extra = [ ];
171 171
 		foreach ( $this->botList as $name => $groups ) {
172 172
 			// These are not groups
173 173
 			unset( $groups[ 'override' ], $groups[ 'override-perm' ] );
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @param array[] $extra
188 188
 	 * @return array[]
189 189
 	 */
190
-	protected function getNewContent( array $missing, array $extra ) : array {
190
+	protected function getNewContent ( array $missing, array $extra ) : array {
191 191
 		$newContent = $this->botList;
192 192
 		foreach ( $newContent as $user => $groups ) {
193 193
 			if ( isset( $missing[ $user ] ) ) {
@@ -212,15 +212,15 @@  discard block
 block discarded – undo
212 212
 	 * @param array[] $newContent
213 213
 	 * @return array[]
214 214
 	 */
215
-	protected function removeOverrides( array $newContent ) : array {
216
-		$removed = [];
215
+	protected function removeOverrides ( array $newContent ) : array {
216
+		$removed = [ ];
217 217
 		foreach ( $newContent as $user => $groups ) {
218 218
 			$ts = PageBotList::getValidFlagTimestamp( $groups );
219
-			if ( isset( $groups['override'] ) && ( date( 'd/m', $ts ) ===
219
+			if ( isset( $groups[ 'override' ] ) && ( date( 'd/m', $ts ) ===
220 220
 				date( 'd/m', strtotime( '- 1 days' ) ) )
221 221
 			) {
222 222
 				unset( $newContent[ $user ][ 'override' ] );
223
-				$removed[] = $user;
223
+				$removed[ ] = $user;
224 224
 			}
225 225
 		}
226 226
 
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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 	const VERSION = '1.0';
13 13
 
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		$this->logger = new Logger;
16 16
 	}
17 17
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param string $mode
22 22
 	 * @param string|null $name
23 23
 	 */
24
-	private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
24
+	private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
25 25
 		$activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name";
26 26
 		$this->logger->info( "Running $activity" );
27 27
 		$manager = new TaskManager;
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		$base = "Execution of $activity";
31 31
 		if ( $res->isOK() ) {
32 32
 			$msg = $res->getStatus() === TaskResult::STATUS_NOTHING ?
33
-				': nothing to do' :
34
-				' completed successfully';
33
+				': nothing to do' : ' completed successfully';
35 34
 			$this->logger->info( $base . $msg . ".\n$line\n\n" );
36 35
 		} else {
37 36
 			$this->logger->error( "$base failed.\n$res\n$line\n\n" );
@@ -41,7 +40,7 @@  discard block
 block discarded – undo
41 40
 	/**
42 41
 	 * Entry point for the whole process
43 42
 	 */
44
-	public function runAll() {
43
+	public function runAll () {
45 44
 		$this->run();
46 45
 	}
47 46
 
@@ -50,7 +49,7 @@  discard block
 block discarded – undo
50 49
 	 *
51 50
 	 * @param string $task
52 51
 	 */
53
-	public function runTask( string $task ) {
52
+	public function runTask ( string $task ) {
54 53
 		$this->run( TaskManager::MODE_TASK, $task );
55 54
 	}
56 55
 
@@ -59,7 +58,7 @@  discard block
 block discarded – undo
59 58
 	 *
60 59
 	 * @param string $subtask
61 60
 	 */
62
-	public function runSubtask( string $subtask ) {
61
+	public function runSubtask ( string $subtask ) {
63 62
 		$this->run( TaskManager::MODE_SUBTASK, $subtask );
64 63
 	}
65 64
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/ArchivePages.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\Subtask;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 
20 20
 		if ( !$pages ) {
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param PageRiconferma[] $pages
34 34
 	 * @see OpenUpdates::addToMainPage()
35 35
 	 */
36
-	protected function removeFromMainPage( array $pages ) {
36
+	protected function removeFromMainPage ( array $pages ) {
37 37
 		$this->getLogger()->info(
38 38
 			'Removing from main: ' . implode( ', ', $pages )
39 39
 		);
40 40
 
41 41
 		$mainPage = new Page( $this->getOpt( 'main-page-title' ) );
42
-		$remove = [];
42
+		$remove = [ ];
43 43
 		foreach ( $pages as $page ) {
44
-			$remove[] = '{{' . $page->getTitle() . "}}\n";
44
+			$remove[ ] = '{{' . $page->getTitle() . "}}\n";
45 45
 		}
46 46
 
47 47
 		$newContent = str_replace( $remove, '', $mainPage->getContent() );
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param PageRiconferma[] $pages
72 72
 	 */
73
-	protected function addToArchive( array $pages ) {
73
+	protected function addToArchive ( array $pages ) {
74 74
 		$this->getLogger()->info(
75 75
 			'Adding to archive: ' . implode( ', ', $pages )
76 76
 		);
77 77
 
78
-		$simple = $votes = [];
78
+		$simple = $votes = [ ];
79 79
 		foreach ( $pages as $page ) {
80 80
 			if ( $page->isVote() ) {
81
-				$votes[] = $page;
81
+				$votes[ ] = $page;
82 82
 			} else {
83
-				$simple[] = $page;
83
+				$simple[ ] = $page;
84 84
 			}
85 85
 		}
86 86
 
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 * @param string $archiveTitle
102 102
 	 * @param array $pages
103 103
 	 */
104
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
104
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
105 105
 		$archivePage = new Page( "$archiveTitle/" . date( 'Y' ) );
106 106
 		$exists = $archivePage->exists();
107 107
 
108 108
 		$append = "\n";
109
-		$archivedList = [];
109
+		$archivedList = [ ];
110 110
 		foreach ( $pages as $page ) {
111 111
 			$append .= '{{' . $page->getTitle() . "}}\n";
112
-			$archivedList[] = $page->getUserNum();
112
+			$archivedList[ ] = $page->getUserNum();
113 113
 		}
114 114
 
115 115
 		$summary = $this->msg( 'close-archive-summary' )
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @param string $archiveTitle
132 132
 	 */
133
-	private function addArchiveYear( string $archiveTitle ) {
133
+	private function addArchiveYear ( string $archiveTitle ) {
134 134
 		$page = new Page( $archiveTitle );
135 135
 		$year = date( 'Y' );
136 136
 
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
 
@@ -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
 		$pages = $this->getDataProvider()->getPagesToClose();
22 22
 
23 23
 		if ( !$pages ) {
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 	 * @param PageRiconferma[] $pages
40 40
 	 * @see OpenUpdates::addToVotazioni()
41 41
 	 */
42
-	protected function updateVotazioni( array $pages ) {
42
+	protected function updateVotazioni ( array $pages ) {
43 43
 		$this->getLogger()->info(
44 44
 			'Updating votazioni: ' . implode( ', ', $pages )
45 45
 		);
46 46
 		$votePage = new Page( $this->getOpt( 'vote-page-title' ) );
47 47
 
48
-		$users = [];
48
+		$users = [ ];
49 49
 		foreach ( $pages as $page ) {
50
-			$users[] = $page->getUser();
50
+			$users[ ] = $page->getUser();
51 51
 		}
52 52
 		$usersReg = Element::regexFromArray( $users );
53 53
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param array $pages
69 69
 	 * @see OpenUpdates::addToNews()
70 70
 	 */
71
-	protected function updateNews( array $pages ) {
71
+	protected function updateNews ( array $pages ) {
72 72
 		$simpleAmount = $voteAmount = 0;
73 73
 		foreach ( $pages as $page ) {
74 74
 			if ( $page->isVote() ) {
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
89 89
 		$voteMatches = $newsPage->getMatch( $voteReg );
90 90
 
91
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
92
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
91
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
92
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
93 93
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() );
94 94
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
95 95
 
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @param bool[] $outcomes
109 109
 	 */
110
-	protected function updateAdminList( array $outcomes ) {
110
+	protected function updateAdminList ( array $outcomes ) {
111 111
 		$this->getLogger()->info( 'Updating admin list' );
112 112
 		$adminsPage = new Page( $this->getOpt( 'admins-list-title' ) );
113 113
 		$newContent = $adminsPage->getContent();
114 114
 
115
-		$riconfNames = $removeNames = [];
115
+		$riconfNames = $removeNames = [ ];
116 116
 		foreach ( $outcomes as $username => $confirmed ) {
117 117
 			$user = new User( $username );
118 118
 			$userReg = $user->getRegex();
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 					'${1}' . date( 'Ymd' ) . '|' . $nextDate . '$2',
125 125
 					$newContent
126 126
 				);
127
-				$riconfNames[] = $username;
127
+				$riconfNames[ ] = $username;
128 128
 			} else {
129 129
 				$newContent = preg_replace( $reg, '', $newContent );
130
-				$removeNames[] = $username;
130
+				$removeNames[ ] = $username;
131 131
 			}
132 132
 		}
133 133
 
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
 	 * @param User $user
151 151
 	 * @return int
152 152
 	 */
153
-	private function getNextTs( User $user ) : int {
153
+	private function getNextTs ( User $user ) : int {
154 154
 		// If there's an "override", we ignore it, supposing that it's been already used for
155 155
 		// this time, but not yet removed in UpdateList. This will also discard "override"s added
156 156
 		// for the next year before the procedure is closed.
157 157
 		// @todo Avoid the limitation above
158 158
 		$groups = $user->getGroupsWithDates();
159
-		if ( isset( $groups['override-perm'] ) ) {
159
+		if ( isset( $groups[ 'override-perm' ] ) ) {
160 160
 			$date = \DateTime::createFromFormat(
161 161
 				'd/m/Y',
162
-				$groups['override-perm'] . '/' . date( 'Y' )
162
+				$groups[ 'override-perm' ] . '/' . date( 'Y' )
163 163
 			);
164 164
 			if ( $date < new \DateTime ) {
165 165
 				$date->modify( '+1 year' );
@@ -172,21 +172,21 @@  discard block
 block discarded – undo
172 172
 	/**
173 173
 	 * @param bool[] $outcomes
174 174
 	 */
175
-	protected function updateCUList( array $outcomes ) {
175
+	protected function updateCUList ( array $outcomes ) {
176 176
 		$this->getLogger()->info( 'Updating CU list.' );
177 177
 		$cuList = new Page( $this->getOpt( 'cu-list-title' ) );
178 178
 		$newContent = $cuList->getContent();
179 179
 
180
-		$riconfNames = $removeNames = [];
180
+		$riconfNames = $removeNames = [ ];
181 181
 		foreach ( $outcomes as $user => $confirmed ) {
182 182
 			$userReg = ( new User( $user ) )->getRegex();
183 183
 			$reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
184 184
 			if ( $confirmed ) {
185 185
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent );
186
-				$riconfNames[] = $user;
186
+				$riconfNames[ ] = $user;
187 187
 			} else {
188 188
 				$newContent = preg_replace( $reg, '', $newContent );
189
-				$removeNames[] = $user;
189
+				$removeNames[ ] = $user;
190 190
 			}
191 191
 		}
192 192
 
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	 * @param PageRiconferma[] $pages
211 211
 	 * @return bool[]
212 212
 	 */
213
-	private function getGroupOutcomes( string $group, array $pages ) : array {
214
-		$ret = [];
213
+	private function getGroupOutcomes ( string $group, array $pages ) : array {
214
+		$ret = [ ];
215 215
 		foreach ( $pages as $page ) {
216 216
 			$user = $page->getUser();
217 217
 			if ( $user->inGroup( $group ) ) {
Please login to merge, or discard this patch.