Passed
Push — master ( e4a382...56087c )
by Daimona
01:45
created
includes/TaskDataProvider.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
 	/** @var array[] */
15 15
 	private $processUsers;
16 16
 	/** @var PageRiconferma[] */
17
-	private $createdPages = [];
17
+	private $createdPages = [ ];
18 18
 
19 19
 	/**
20 20
 	 * Get a list of users to execute tasks on.
21 21
 	 *
22 22
 	 * @return array[]
23 23
 	 */
24
-	public function getUsersToProcess() : array {
24
+	public function getUsersToProcess () : array {
25 25
 		if ( $this->processUsers === null ) {
26
-			$this->processUsers = [];
26
+			$this->processUsers = [ ];
27 27
 			foreach ( PageBotList::get()->getAdminsList() as $user => $groups ) {
28 28
 				if ( $this->shouldAddUser( $groups ) ) {
29 29
 					$this->processUsers[ $user ] = $groups;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param array[] $groups
41 41
 	 * @return bool
42 42
 	 */
43
-	private function shouldAddUser( array $groups ) : bool {
43
+	private function shouldAddUser ( array $groups ) : bool {
44 44
 		$override = true;
45 45
 		$timestamp = PageBotList::getOverrideTimestamp( $groups );
46 46
 
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return PageRiconferma[]
61 61
 	 */
62
-	public function getOpenPages() : array {
62
+	public function getOpenPages () : array {
63 63
 		static $list = null;
64 64
 		if ( $list === null ) {
65
-			$list = [];
65
+			$list = [ ];
66 66
 			$mainTitle = $this->getConfig()->get( 'main-page-title' );
67 67
 			$params = [
68 68
 				'action' => 'query',
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			$pages = RequestBase::newFromParams( $params )->execute()->query->pages;
77 77
 			foreach ( reset( $pages )->templates as $page ) {
78 78
 				if ( preg_match( "!$titleReg\/[^\/]+\/\d!", $page->title ) ) {
79
-					$list[] = new PageRiconferma( $page->title );
79
+					$list[ ] = new PageRiconferma( $page->title );
80 80
 				}
81 81
 			}
82 82
 		}
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return PageRiconferma[]
91 91
 	 */
92
-	public function getPagesToClose() : array {
92
+	public function getPagesToClose () : array {
93 93
 		static $list = null;
94 94
 		if ( $list === null ) {
95
-			$list = [];
95
+			$list = [ ];
96 96
 			foreach ( $this->getOpenPages() as $page ) {
97 97
 				if ( time() > $page->getEndTimestamp() ) {
98
-					$list[] = $page;
98
+					$list[ ] = $page;
99 99
 				}
100 100
 			}
101 101
 		}
@@ -107,22 +107,22 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @param string $name
109 109
 	 */
110
-	public function removeUser( string $name ) {
110
+	public function removeUser ( string $name ) {
111 111
 		unset( $this->processUsers[ $name ] );
112 112
 	}
113 113
 
114 114
 	/**
115 115
 	 * @return PageRiconferma[]
116 116
 	 */
117
-	public function getCreatedPages() : array {
117
+	public function getCreatedPages () : array {
118 118
 		return $this->createdPages;
119 119
 	}
120 120
 
121 121
 	/**
122 122
 	 * @param PageRiconferma $page
123 123
 	 */
124
-	public function addCreatedPages( PageRiconferma $page ) {
125
-		$this->createdPages[] = $page;
124
+	public function addCreatedPages ( PageRiconferma $page ) {
125
+		$this->createdPages[ ] = $page;
126 126
 	}
127 127
 
128 128
 	/**
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 	 * @param PageRiconferma[] $pages
133 133
 	 * @return bool[]
134 134
 	 */
135
-	public function getGroupOutcomes( string $group, array $pages ) : array {
136
-		$ret = [];
135
+	public function getGroupOutcomes ( string $group, array $pages ) : array {
136
+		$ret = [ ];
137 137
 		foreach ( $pages as $page ) {
138 138
 			$user = $page->getUser();
139 139
 			if ( $user->inGroup( $group ) ) {
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
 		$this->getLogger()->debug( 'Retrieving admins - API' );
58 58
 		$params = [
59 59
 			'action' => 'query',
@@ -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->getConfig()->get( '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_key( $groups, $this->botList[$adm] ?? [] );
95
+			$curMissing = array_diff_key( $groups, $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;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param string $group
149 149
 	 * @return string|null
150 150
 	 */
151
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
151
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
152 152
 		$ts = null;
153 153
 		foreach ( $data->query->logevents as $entry ) {
154 154
 			if ( isset( $entry->params ) ) {
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return array[]
169 169
 	 */
170
-	protected function getExtraGroups() : array {
171
-		$extra = [];
170
+	protected function getExtraGroups () : array {
171
+		$extra = [ ];
172 172
 		foreach ( $this->botList as $name => $groups ) {
173 173
 			// These are not groups
174 174
 			unset( $groups[ 'override' ], $groups[ 'override-perm' ] );
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @param array[] $extra
189 189
 	 * @return array[]
190 190
 	 */
191
-	protected function getNewContent( array $missing, array $extra ) : array {
191
+	protected function getNewContent ( array $missing, array $extra ) : array {
192 192
 		$newContent = $this->botList;
193 193
 		foreach ( $newContent as $user => $groups ) {
194 194
 			if ( isset( $missing[ $user ] ) ) {
@@ -213,15 +213,15 @@  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 219
 			$ts = PageBotList::getValidFlagTimestamp( $groups );
220
-			if ( isset( $groups['override'] ) && ( date( 'd/m', $ts ) ===
220
+			if ( isset( $groups[ 'override' ] ) && ( date( 'd/m', $ts ) ===
221 221
 				date( 'd/m', strtotime( '- 1 days' ) ) )
222 222
 			) {
223 223
 				unset( $newContent[ $user ][ 'override' ] );
224
-				$removed[] = $user;
224
+				$removed[ ] = $user;
225 225
 			}
226 226
 		}
227 227
 
Please login to merge, or discard this patch.
includes/Task/Subtask/FailedUpdates.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
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function runInternal() : int {
18
+	public function runInternal () : int {
19 19
 		$failed = $this->getFailures();
20 20
 		if ( $failed ) {
21 21
 			$bureaucrats = array_keys( $this->getDataProvider()->getGroupOutcomes( 'bureaucrat', $failed ) );
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return PageRiconferma[]
37 37
 	 */
38
-	private function getFailures() : array {
39
-		$ret = [];
38
+	private function getFailures () : array {
39
+		$ret = [ ];
40 40
 		$allPages = $this->getDataProvider()->getPagesToClose();
41 41
 		foreach ( $allPages as $page ) {
42 42
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
43
-				$ret[] = $page;
43
+				$ret[ ] = $page;
44 44
 			}
45 45
 		}
46 46
 		return $ret;
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * @param string[] $users
51 51
 	 */
52
-	protected function updateBurList( array $users ) {
52
+	protected function updateBurList ( array $users ) {
53 53
 		$this->getLogger()->info( 'Updating bureaucrats list.' );
54 54
 
55 55
 		$this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) );
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @param PageRiconferma[] $pages
76 76
 	 */
77
-	protected function requestRemoval( array $pages ) {
77
+	protected function requestRemoval ( array $pages ) {
78 78
 		$this->getLogger()->info(
79 79
 			'Requesting removal on meta for: ' . implode( ', ', $pages )
80 80
 		);
@@ -113,16 +113,16 @@  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
 		$msg = $this->msg( 'annunci-text' );
123 123
 		foreach ( $pages as $page ) {
124 124
 			$user = $page->getUser()->getName();
125
-			$names[] = $user;
125
+			$names[ ] = $user;
126 126
 			$text .= $msg->params( [ '$user' => $user ] )->text();
127 127
 		}
128 128
 
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 *
155 155
 	 * @param PageRiconferma[] $pages
156 156
 	 */
157
-	protected function updateUltimeNotizie( array $pages ) {
157
+	protected function updateUltimeNotizie ( array $pages ) {
158 158
 		$this->getLogger()->info( 'Updating ultime notizie' );
159 159
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) );
160 160
 
161
-		$names = [];
161
+		$names = [ ];
162 162
 		$text = '';
163 163
 		$msg = $this->msg( 'ultimenotizie-text' );
164 164
 		foreach ( $pages as $page ) {
165 165
 			$user = $page->getUser()->getName();
166 166
 			$title = $page->getTitle();
167
-			$names[] = $user;
167
+			$names[ ] = $user;
168 168
 			$text .= $msg->params( [ '$user' => $user, '$title' => $title ] )->text();
169 169
 		}
170 170
 
Please login to merge, or discard this patch.
includes/Task/Subtask/SimpleUpdates.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\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,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param PageRiconferma[] $pages
39 39
 	 * @see UpdatesAround::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
 		);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @param array $pages
71 71
 	 * @see UpdatesAround::addToNews()
72 72
 	 */
73
-	protected function updateNews( array $pages ) {
73
+	protected function updateNews ( array $pages ) {
74 74
 		$simpleAmount = $voteAmount = 0;
75 75
 		foreach ( $pages as $page ) {
76 76
 			if ( $page->isVote() ) {
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
94 94
 		$voteMatches = $newsPage->getMatch( $voteReg );
95 95
 
96
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
97
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
96
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
97
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
98 98
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
99 99
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
100 100
 
@@ -112,22 +112,22 @@  discard block
 block discarded – undo
112 112
 	 *
113 113
 	 * @param bool[] $outcomes
114 114
 	 */
115
-	protected function updateAdminList( array $outcomes ) {
115
+	protected function updateAdminList ( array $outcomes ) {
116 116
 		$this->getLogger()->info( 'Updating admin list' );
117 117
 
118 118
 		$adminsPage = new Page( $this->getConfig()->get( 'admins-list-title' ) );
119 119
 		$newContent = $adminsPage->getContent();
120 120
 
121
-		$riconfNames = $removeNames = [];
121
+		$riconfNames = $removeNames = [ ];
122 122
 		foreach ( $outcomes as $user => $confirmed ) {
123 123
 			$userReg = ( new User( $user ) )->getRegex();
124 124
 			$reg = "!(\{\{Amministratore\/riga\|$userReg.+\| *)\d+( *\|[ \w]*\}\}.*\n)!";
125 125
 			if ( $confirmed ) {
126 126
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:Ymd|+1 year}}$2', $newContent );
127
-				$riconfNames[] = $user;
127
+				$riconfNames[ ] = $user;
128 128
 			} else {
129 129
 				$newContent = preg_replace( $reg, '', $newContent );
130
-				$removeNames[] = $user;
130
+				$removeNames[ ] = $user;
131 131
 			}
132 132
 		}
133 133
 
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
 	/**
148 148
 	 * @param bool[] $outcomes
149 149
 	 */
150
-	protected function updateCUList( array $outcomes ) {
150
+	protected function updateCUList ( array $outcomes ) {
151 151
 		$this->getLogger()->info( 'Updating CU list.' );
152 152
 		$cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) );
153 153
 		$newContent = $cuList->getContent();
154 154
 
155
-		$riconfNames = $removeNames = [];
155
+		$riconfNames = $removeNames = [ ];
156 156
 		foreach ( $outcomes as $user => $confirmed ) {
157 157
 			$userReg = ( new User( $user ) )->getRegex();
158 158
 			$reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
159 159
 			if ( $confirmed ) {
160 160
 				$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
161
-				$riconfNames[] = $user;
161
+				$riconfNames[ ] = $user;
162 162
 			} else {
163 163
 				$newContent = preg_replace( $reg, '', $newContent );
164
-				$removeNames[] = $user;
164
+				$removeNames[ ] = $user;
165 165
 			}
166 166
 		}
167 167
 
Please login to merge, or discard this patch.