Passed
Push — master ( fd4e50...5cd30c )
by Daimona
01:54
created
includes/Logger/MultiLogger.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\Logger;
4 4
 
@@ -10,12 +10,12 @@  discard block
 block discarded – undo
10 10
  */
11 11
 class MultiLogger extends AbstractLogger implements IFlushingAwareLogger {
12 12
 	/** @var IFlushingAwareLogger[] */
13
-	private $loggers = [];
13
+	private $loggers = [ ];
14 14
 
15 15
 	/**
16 16
 	 * @param IFlushingAwareLogger ...$loggers
17 17
 	 */
18
-	public function __construct( IFlushingAwareLogger ...$loggers ) {
18
+	public function __construct ( IFlushingAwareLogger ...$loggers ) {
19 19
 		$this->loggers = $loggers;
20 20
 	}
21 21
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @inheritDoc
24 24
 	 * @suppress PhanUnusedPublicMethodParameter
25 25
 	 */
26
-	public function log( $level, $message, array $context = [] ) {
26
+	public function log ( $level, $message, array $context = [ ] ) {
27 27
 		foreach ( $this->loggers as $logger ) {
28 28
 			$logger->log( $level, $message );
29 29
 		}
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @inheritDoc
34 34
 	 */
35
-	public function flush() : void {
35
+	public function flush () : void {
36 36
 		foreach ( $this->loggers as $logger ) {
37 37
 			$logger->flush();
38 38
 		}
Please login to merge, or discard this patch.
includes/Logger/SimpleLogger.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\Logger;
4 4
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @param string $minlevel
19 19
 	 */
20
-	public function __construct( $minlevel = LogLevel::INFO ) {
20
+	public function __construct ( $minlevel = LogLevel::INFO ) {
21 21
 		$this->minLevel = $this->levelToInt( $minlevel );
22 22
 	}
23 23
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @inheritDoc
26 26
 	 * @suppress PhanUnusedPublicMethodParameter
27 27
 	 */
28
-	public function log( $level, $message, array $context = [] ) {
28
+	public function log ( $level, $message, array $context = [ ] ) {
29 29
 		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
30 30
 			echo $this->getFormattedMessage( $level, $message ) . "\n";
31 31
 		}
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @inheritDoc
36 36
 	 */
37
-	public function flush() : void {
37
+	public function flush () : void {
38 38
 		// Everything else is printed immediately
39 39
 		echo "\n" . str_repeat( '-', 80 ) . "\n\n";
40 40
 	}
Please login to merge, or discard this patch.
includes/Task/TaskBase.php 1 patch
Spacing   +7 added lines, -7 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
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return TaskResult
40 40
 	 */
41
-	final public function run() : TaskResult {
41
+	final public function run () : TaskResult {
42 42
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
43 43
 		$opName = $this->getOperationName();
44 44
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return int One of the STATUS_* constants
71 71
 	 */
72
-	abstract protected function runInternal() : int;
72
+	abstract protected function runInternal () : int;
73 73
 
74 74
 	/**
75 75
 	 * How this operation should be called in logs
76 76
 	 *
77 77
 	 * @return string
78 78
 	 */
79
-	abstract public function getOperationName() : string;
79
+	abstract public function getOperationName () : string;
80 80
 
81 81
 	/**
82 82
 	 * @return TaskDataProvider
83 83
 	 */
84
-	protected function getDataProvider() : TaskDataProvider {
84
+	protected function getDataProvider () : TaskDataProvider {
85 85
 		return $this->dataProvider;
86 86
 	}
87 87
 }
Please login to merge, or discard this patch.
includes/Logger/IFlushingAwareLogger.php 1 patch
Spacing   +2 added lines, -2 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\Logger;
4 4
 
@@ -8,5 +8,5 @@  discard block
 block discarded – undo
8 8
  * Logger aware of flushing. Can be declared empty if the buffer is flushed immediately.
9 9
  */
10 10
 interface IFlushingAwareLogger extends LoggerInterface {
11
-	public function flush() : void;
11
+	public function flush () : void;
12 12
 }
Please login to merge, or discard this patch.
run.php 1 patch
Spacing   +3 added lines, -3 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
  * Entry point for the bot, called by CLI
4 4
  */
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 $type = current( array_keys( $taskOpt ) );
55 55
 try {
56 56
 	if ( $type === 'task' ) {
57
-		$bot->runTask( $taskOpt['task'] );
57
+		$bot->runTask( $taskOpt[ 'task' ] );
58 58
 	} elseif ( $type === 'subtask' ) {
59
-		$bot->runSubtask( $taskOpt['subtask'] );
59
+		$bot->runSubtask( $taskOpt[ 'subtask' ] );
60 60
 	} else {
61 61
 		$bot->runAll();
62 62
 	}
Please login to merge, or discard this patch.
includes/CLI.php 1 patch
Spacing   +12 added lines, -12 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
 
@@ -57,14 +57,14 @@  discard block
 block discarded – undo
57 57
 	/**
58 58
 	 * @return bool
59 59
 	 */
60
-	public static function isCLI() : bool {
60
+	public static function isCLI () : bool {
61 61
 		return PHP_SAPI === 'cli';
62 62
 	}
63 63
 
64 64
 	/**
65 65
 	 * Populate options and check for required ones
66 66
 	 */
67
-	public function __construct() {
67
+	public function __construct () {
68 68
 		$opts = getopt( self::SHORT_OPTS, self::LONG_OPTS );
69 69
 		$this->checkRequired( $opts );
70 70
 		$this->canonicalize( $opts );
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	/**
75 75
 	 * @param array $opts
76 76
 	 */
77
-	private function checkRequired( array $opts ) {
77
+	private function checkRequired ( array $opts ) {
78 78
 		foreach ( self::REQUIRED_OPTS as $opt ) {
79 79
 			if ( !array_key_exists( $opt, $opts ) ) {
80 80
 				exit( "Required option $opt missing." );
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * @param array &$opts
107 107
 	 */
108
-	private function canonicalize( array &$opts ) {
108
+	private function canonicalize ( array &$opts ) {
109 109
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
110 110
 			$pw = trim( file_get_contents( self::PASSWORD_FILE ) );
111
-			$opts['password'] = $pw;
112
-			unset( $opts['use-password-file'] );
111
+			$opts[ 'password' ] = $pw;
112
+			unset( $opts[ 'use-password-file' ] );
113 113
 		}
114 114
 	}
115 115
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * These are the options required by Config.
118 118
 	 * @return array
119 119
 	 */
120
-	public function getMainOpts() : array {
120
+	public function getMainOpts () : array {
121 121
 		return array_intersect_key(
122 122
 			$this->opts,
123 123
 			array_fill_keys( Config::REQUIRED_OPTS, true )
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 * @param mixed|null $default
130 130
 	 * @return mixed
131 131
 	 */
132
-	public function getOpt( string $opt, $default = null ) {
133
-		return $this->opts[$opt] ?? $default;
132
+	public function getOpt ( string $opt, $default = null ) {
133
+		return $this->opts[ $opt ] ?? $default;
134 134
 	}
135 135
 
136 136
 	/**
137 137
 	 * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ]
138 138
 	 */
139
-	public function getTaskOpt() : array {
139
+	public function getTaskOpt () : array {
140 140
 		return array_intersect_key(
141 141
 			$this->opts,
142 142
 			[ 'task' => true, 'subtask' => true ]
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	/**
147 147
 	 * @return string|null
148 148
 	 */
149
-	public function getURL() : ?string {
149
+	public function getURL () : ?string {
150 150
 		return $this->getOpt( 'force-url' );
151 151
 	}
152 152
 }
Please login to merge, or discard this patch.
includes/Request/RequestBase.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\Request;
4 4
 
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 	/** @var string */
31 31
 	protected $method = 'GET';
32 32
 	/** @var string[] */
33
-	protected $newCookies = [];
33
+	protected $newCookies = [ ];
34 34
 
35 35
 	/**
36 36
 	 * Use self::newFromParams, which will provide the right class to use
37 37
 	 *
38 38
 	 * @param array $params
39 39
 	 */
40
-	protected function __construct( array $params ) {
40
+	protected function __construct ( array $params ) {
41 41
 		$this->params = [ 'format' => 'json' ] + $params;
42 42
 		$this->url = DEFAULT_URL;
43 43
 	}
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param array $params
49 49
 	 * @return self
50 50
 	 */
51
-	public static function newFromParams( array $params ) : self {
51
+	public static function newFromParams ( array $params ) : self {
52 52
 		if ( extension_loaded( 'curl' ) ) {
53 53
 			$ret = new CurlRequest( $params );
54 54
 		} else {
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return self For chaining
64 64
 	 */
65
-	public function setPost() : self {
65
+	public function setPost () : self {
66 66
 		$this->method = 'POST';
67 67
 		return $this;
68 68
 	}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $url
74 74
 	 * @return self for chaining
75 75
 	 */
76
-	public function setUrl( string $url ) : self {
76
+	public function setUrl ( string $url ) : self {
77 77
 		$this->url = $url;
78 78
 		return $this;
79 79
 	}
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	 * @todo Return an iterable object which automatically continues the query only if the last
86 86
 	 *   entry available is reached.
87 87
 	 */
88
-	public function execute() : \stdClass {
88
+	public function execute () : \stdClass {
89 89
 		$curParams = $this->params;
90
-		$sets = [];
90
+		$sets = [ ];
91 91
 		do {
92 92
 			$res = $this->makeRequestInternal( $curParams );
93 93
 
94 94
 			$this->handleErrorAndWarnings( $res );
95
-			$sets[] = $res;
95
+			$sets[ ] = $res;
96 96
 
97 97
 			$finished = true;
98 98
 			if ( isset( $res->continue ) ) {
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 	 * @param array $params
111 111
 	 * @return \stdClass
112 112
 	 */
113
-	private function makeRequestInternal( array $params ) : \stdClass {
113
+	private function makeRequestInternal ( array $params ) : \stdClass {
114 114
 		if ( $this->method === 'POST' ) {
115
-			$params['maxlag'] = self::MAXLAG;
115
+			$params[ 'maxlag' ] = self::MAXLAG;
116 116
 		}
117 117
 		$params = http_build_query( $params );
118 118
 
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 	 * @param string $params
129 129
 	 * @return string
130 130
 	 */
131
-	abstract protected function reallyMakeRequest( string $params ) : string;
131
+	abstract protected function reallyMakeRequest ( string $params ) : string;
132 132
 
133 133
 	/**
134 134
 	 * After a request, set cookies for the next ones
135 135
 	 *
136 136
 	 * @param array $cookies
137 137
 	 */
138
-	protected function setCookies( array $cookies ) {
138
+	protected function setCookies ( array $cookies ) {
139 139
 		foreach ( $cookies as $cookie ) {
140 140
 			$bits = explode( ';', $cookie );
141
-			list( $name, $value ) = explode( '=', $bits[0] );
141
+			list( $name, $value ) = explode( '=', $bits[ 0 ] );
142 142
 			self::$cookiesToSet[ $name ] = $value;
143 143
 		}
144 144
 	}
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param \stdClass $res
150 150
 	 * @return APIRequestException
151 151
 	 */
152
-	private function getException( \stdClass $res ) : APIRequestException {
152
+	private function getException ( \stdClass $res ) : APIRequestException {
153 153
 		switch ( $res->error->code ) {
154 154
 			case 'missingtitle':
155 155
 				$ex = new MissingPageException;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @param \stdClass $res
173 173
 	 * @throws APIRequestException
174 174
 	 */
175
-	protected function handleErrorAndWarnings( \stdClass $res ) {
175
+	protected function handleErrorAndWarnings ( \stdClass $res ) {
176 176
 		if ( isset( $res->error ) ) {
177 177
 			throw $this->getException( $res );
178 178
 		} elseif ( isset( $res->warnings ) ) {
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @param \stdClass[] $sets
189 189
 	 * @return \stdClass
190 190
 	 */
191
-	private function mergeSets( array $sets ) : \stdClass {
191
+	private function mergeSets ( array $sets ) : \stdClass {
192 192
 		// Use the first set as template
193 193
 		$ret = array_shift( $sets );
194 194
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 * @param array|\stdClass $second
206 206
 	 * @return array|\stdClass array
207 207
 	 */
208
-	private function recursiveMerge( $first, $second ) {
208
+	private function recursiveMerge ( $first, $second ) {
209 209
 		$ret = $first;
210 210
 		if ( is_array( $second ) ) {
211 211
 			$ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second;
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return array
225 225
 	 */
226
-	protected function getHeaders() :array {
226
+	protected function getHeaders () :array {
227 227
 		$ret = self::HEADERS;
228 228
 		if ( self::$cookiesToSet ) {
229
-			$cookies = [];
229
+			$cookies = [ ];
230 230
 			foreach ( self::$cookiesToSet as $cname => $cval ) {
231
-				$cookies[] = trim( "$cname=$cval" );
231
+				$cookies[ ] = trim( "$cname=$cval" );
232 232
 			}
233
-			$ret[] = 'Cookie: ' . implode( '; ', $cookies );
233
+			$ret[ ] = 'Cookie: ' . implode( '; ', $cookies );
234 234
 		}
235 235
 		return $ret;
236 236
 	}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * @param array $headers
242 242
 	 * @return string
243 243
 	 */
244
-	protected function buildHeadersString( array $headers ) : string {
244
+	protected function buildHeadersString ( array $headers ) : string {
245 245
 		$ret = '';
246 246
 		foreach ( $headers as $header ) {
247 247
 			$ret .= "$header\r\n";
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
 		$userInfo = $user->getUserInfo();
154
-		if ( isset( $userInfo['override-perm'] ) ) {
154
+		if ( isset( $userInfo[ 'override-perm' ] ) ) {
155 155
 			$date = \DateTime::createFromFormat(
156 156
 				'd/m/Y',
157
-				$userInfo['override-perm'] . '/' . date( 'Y' )
157
+				$userInfo[ '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( $userInfo );
165 165
 			$res = strtotime( date( 'Y', strtotime( '+1 year' ) ) . date( '-m-d', $ts ) );
166
-			if ( isset( $userInfo['override'] ) ) {
167
-				$date = \DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] );
166
+			if ( isset( $userInfo[ 'override' ] ) ) {
167
+				$date = \DateTime::createFromFormat( 'd/m/Y', $userInfo[ '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/Wiki/Wiki.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\Wiki;
4 4
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param LoggerInterface $logger
29 29
 	 * @param string $domain The URL of the wiki, if different from default
30 30
 	 */
31
-	public function __construct( LoggerInterface $logger, string $domain = DEFAULT_URL ) {
31
+	public function __construct ( LoggerInterface $logger, string $domain = DEFAULT_URL ) {
32 32
 		$this->logger = $logger;
33 33
 		$this->domain = $domain;
34 34
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 * @throws MissingPageException
43 43
 	 * @throws MissingSectionException
44 44
 	 */
45
-	public function getPageContent( string $title, int $section = null ) : string {
45
+	public function getPageContent ( string $title, int $section = null ) : string {
46 46
 		$msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' );
47 47
 		$this->logger->debug( $msg );
48 48
 		$params = [
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		];
55 55
 
56 56
 		if ( $section !== null ) {
57
-			$params['rvsection'] = $section;
57
+			$params[ 'rvsection' ] = $section;
58 58
 		}
59 59
 
60 60
 		$req = $this->buildRequest( $params );
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			throw new MissingPageException( $title );
65 65
 		}
66 66
 
67
-		$mainSlot = $page->revisions[0]->slots->main;
67
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
68 68
 
69 69
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
70 70
 			throw new MissingSectionException( $title, $section );
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param array $params
79 79
 	 * @throws EditException
80 80
 	 */
81
-	public function editPage( array $params ) {
81
+	public function editPage ( array $params ) {
82 82
 		$this->login();
83 83
 
84 84
 		$params = [
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		] + $params;
88 88
 
89 89
 		if ( Config::getInstance()->get( 'bot-edits' ) ) {
90
-			$params['bot'] = 1;
90
+			$params[ 'bot' ] = 1;
91 91
 		}
92 92
 
93 93
 		$res = $this->buildRequest( $params )->setPost()->execute();
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
106 106
 	 * @throws LoginException
107 107
 	 */
108
-	public function login() {
108
+	public function login () {
109 109
 		if ( self::$loggedIn ) {
110 110
 			return;
111 111
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 
133 133
 		self::$loggedIn = true;
134 134
 		// Clear tokens cache
135
-		$this->tokens = [];
135
+		$this->tokens = [ ];
136 136
 		$this->logger->info( 'Login succeeded' );
137 137
 	}
138 138
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param string $type
143 143
 	 * @return string
144 144
 	 */
145
-	public function getToken( string $type ) : string {
145
+	public function getToken ( string $type ) : string {
146 146
 		if ( !isset( $this->tokens[ $type ] ) ) {
147 147
 			$params = [
148 148
 				'action' => 'query',
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param string $title
166 166
 	 * @return int
167 167
 	 */
168
-	public function getPageCreationTS( string $title ) : int {
168
+	public function getPageCreationTS ( string $title ) : int {
169 169
 		$params = [
170 170
 			'action' => 'query',
171 171
 			'prop' => 'revisions',
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
 		$res = $this->buildRequest( $params )->execute();
180 180
 		$data = $res->query->pages;
181
-		return strtotime( reset( $data )->revisions[0]->timestamp );
181
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
182 182
 	}
183 183
 
184 184
 	/**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @param string $title
188 188
 	 * @param string $reason
189 189
 	 */
190
-	public function protectPage( string $title, string $reason ) {
190
+	public function protectPage ( string $title, string $reason ) {
191 191
 		$this->logger->info( "Protecting page $title" );
192 192
 		$this->login();
193 193
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param array $params
209 209
 	 * @return RequestBase
210 210
 	 */
211
-	private function buildRequest( array $params ) : RequestBase {
211
+	private function buildRequest ( array $params ) : RequestBase {
212 212
 		return RequestBase::newFromParams( $params )->setUrl( $this->domain );
213 213
 	}
214 214
 }
Please login to merge, or discard this patch.