Passed
Push — master ( b5a9ea...e4a382 )
by Daimona
01:58
created
includes/TaskDataProvider.php 1 patch
Spacing   +15 added lines, -15 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,21 +107,21 @@  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
 }
Please login to merge, or discard this patch.
includes/Message.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;
4 4
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @param string $key
30 30
 	 */
31
-	public function __construct( string $key ) {
31
+	public function __construct ( string $key ) {
32 32
 		$this->key = $key;
33 33
 		$this->value = Config::getInstance()->getWikiMessage( $key );
34 34
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param array $args
38 38
 	 * @return self
39 39
 	 */
40
-	public function params( array $args ) : self {
40
+	public function params ( array $args ) : self {
41 41
 		$this->value = strtr( $this->value, $args );
42 42
 		return $this;
43 43
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @return string
47 47
 	 */
48
-	public function text() : string {
48
+	public function text () : string {
49 49
 		$this->parsePlurals();
50 50
 		return $this->value;
51 51
 	}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * Replace {{$plur|<amount>|sing|plur}}
55 55
 	 */
56
-	protected function parsePlurals() {
56
+	protected function parsePlurals () {
57 57
 		$reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!';
58 58
 
59 59
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		$this->value = preg_replace_callback(
63 63
 			$reg,
64 64
 			function ( $matches ) {
65
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
65
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
66 66
 			},
67 67
 			$this->value
68 68
 		);
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param int $timestamp
75 75
 	 * @return string
76 76
 	 */
77
-	public static function getTimeWithArticle( int $timestamp ) : string {
77
+	public static function getTimeWithArticle ( int $timestamp ) : string {
78 78
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
79 79
 		$timeString = strftime( '%e %B alle %R', $timestamp );
80 80
 		// Remove the left space if day has a single digit
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param string $timeString
92 92
 	 * @return int
93 93
 	 */
94
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
94
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
95 95
 		$englishTime = str_ireplace(
96 96
 			array_values( self::MONTHS ),
97 97
 			array_keys( self::MONTHS ),
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 	 * @param string $emptyText
111 111
 	 * @return string
112 112
 	 */
113
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
113
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
114 114
 		if ( count( $data ) > 1 ) {
115 115
 			$last = array_pop( $data );
116 116
 			$ret = implode( ', ', $data ) . " e $last";
117 117
 		} elseif ( $data ) {
118
-			$ret = (string)$data[0];
118
+			$ret = (string)$data[ 0 ];
119 119
 		} else {
120 120
 			$ret = $emptyText;
121 121
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 		return $ret;
124 124
 	}
125 125
 
126
-	public function __toString() {
126
+	public function __toString () {
127 127
 		return $this->text();
128 128
 	}
129 129
 }
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
 
@@ -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
 		$pages = $this->getDataProvider()->getPagesToClose();
20 20
 
21 21
 		if ( !$pages ) {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param PageRiconferma[] $pages
35 35
 	 * @see UpdatesAround::addToVotazioni()
36 36
 	 */
37
-	protected function updateVotazioni( array $pages ) {
37
+	protected function updateVotazioni ( array $pages ) {
38 38
 		$this->getLogger()->info(
39 39
 			'Updating votazioni: ' . implode( ', ', $pages )
40 40
 		);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @param array $pages
67 67
 	 * @see UpdatesAround::addToNews()
68 68
 	 */
69
-	protected function updateNews( array $pages ) {
69
+	protected function updateNews ( array $pages ) {
70 70
 		$simpleAmount = $voteAmount = 0;
71 71
 		foreach ( $pages as $page ) {
72 72
 			if ( $page->isVote() ) {
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
90 90
 		$voteMatches = $newsPage->getMatch( $voteReg );
91 91
 
92
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
93
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
92
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
93
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
94 94
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content );
95 95
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
96 96
 
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param PageRiconferma[] $pages
110 110
 	 */
111
-	protected function updateAdminList( array $pages ) {
111
+	protected function updateAdminList ( array $pages ) {
112 112
 		$this->getLogger()->info(
113 113
 			'Updating admin list: ' . implode( ', ', $pages )
114 114
 		);
115 115
 		$adminsPage = new Page( $this->getConfig()->get( 'admins-list-title' ) );
116 116
 		$newContent = $adminsPage->getContent();
117 117
 
118
-		$riconfNames = $removeNames = [];
118
+		$riconfNames = $removeNames = [ ];
119 119
 		foreach ( $pages as $page ) {
120 120
 			$user = $page->getUser();
121 121
 			$reg = '!(\{\{Amministratore\/riga\|' . $user->getRegex() . ".+\| *)\d+( *\|[ \w]*\}\}.*\n)!";
122 122
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
123 123
 				$newContent = preg_replace( $reg, '', $newContent );
124
-				$removeNames[] = $user->getName();
124
+				$removeNames[ ] = $user->getName();
125 125
 			} else {
126 126
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:Ymd|+1 year}}$2', $newContent );
127
-				$riconfNames[] = $user->getName();
127
+				$riconfNames[ ] = $user->getName();
128 128
 			}
129 129
 		}
130 130
 
@@ -144,22 +144,22 @@  discard block
 block discarded – undo
144 144
 	/**
145 145
 	 * @param PageRiconferma[] $pages
146 146
 	 */
147
-	protected function updateCUList( array $pages ) {
147
+	protected function updateCUList ( array $pages ) {
148 148
 		$this->getLogger()->info( 'Checking if CU list needs updating.' );
149 149
 		$cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) );
150 150
 		$newContent = $cuList->getContent();
151 151
 
152
-		$riconfNames = $removeNames = [];
152
+		$riconfNames = $removeNames = [ ];
153 153
 		foreach ( $pages as $page ) {
154 154
 			$user = $page->getUser();
155 155
 			if ( $user->inGroup( 'checkuser' ) ) {
156 156
 				$reg = '!(\{\{ *Checkuser *\| *' . $user->getRegex() . " *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
157 157
 				if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
158 158
 					$newContent = preg_replace( $reg, '', $newContent );
159
-					$removeNames[] = $user->getName();
159
+					$removeNames[ ] = $user->getName();
160 160
 				} else {
161 161
 					$newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent );
162
-					$riconfNames[] = $user->getName();
162
+					$riconfNames[ ] = $user->getName();
163 163
 				}
164 164
 			}
165 165
 		}
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
 		$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,17 +89,17 @@  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
-			$botList = $this->botList[$adm] ?? [];
96
-			$curMissing = array_diff_key( $groups, $botList[$adm] );
95
+			$botList = $this->botList[ $adm ] ?? [ ];
96
+			$curMissing = array_diff_key( $groups, $botList[ $adm ] );
97 97
 
98 98
 			foreach ( $curMissing as $group ) {
99 99
 				try {
100 100
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
101 101
 				} catch ( TaskException $e ) {
102
-					$this->errors[] = $e->getMessage();
102
+					$this->errors[ ] = $e->getMessage();
103 103
 				}
104 104
 			}
105 105
 		}
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @return string
115 115
 	 * @throws TaskException
116 116
 	 */
117
-	protected function getFlagDate( string $admin, string $group ) : string {
117
+	protected function getFlagDate ( string $admin, string $group ) : string {
118 118
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
119 119
 
120 120
 		$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 ] ) ) {
@@ -214,15 +214,15 @@  discard block
 block discarded – undo
214 214
 	 * @param array[] $newContent
215 215
 	 * @return array[]
216 216
 	 */
217
-	protected function removeOverrides( array $newContent ) : array {
218
-		$removed = [];
217
+	protected function removeOverrides ( array $newContent ) : array {
218
+		$removed = [ ];
219 219
 		foreach ( $newContent as $user => $groups ) {
220 220
 			$ts = PageBotList::getValidFlagTimestamp( $groups );
221
-			if ( isset( $groups['override'] ) && ( date( 'd/m', $ts ) ===
221
+			if ( isset( $groups[ 'override' ] ) && ( date( 'd/m', $ts ) ===
222 222
 				date( 'd/m', strtotime( '- 1 days' ) ) )
223 223
 			) {
224 224
 				unset( $newContent[ $user ][ 'override' ] );
225
-				$removed[] = $user;
225
+				$removed[ ] = $user;
226 226
 			}
227 227
 		}
228 228
 
Please login to merge, or discard this patch.