Passed
Push — master ( 9623d2...497244 )
by Daimona
01:54
created
includes/Config.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;
4 4
 
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	/** @var self */
12 12
 	private static $instance;
13 13
 	/** @var array */
14
-	private $opts = [];
14
+	private $opts = [ ];
15 15
 
16 16
 	/**
17 17
 	 * Use self::init() and self::getInstance()
18 18
 	 */
19
-	private function __construct() {
19
+	private function __construct () {
20 20
 	}
21 21
 
22 22
 	/**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param array $confValues
26 26
 	 * @throws ConfigException
27 27
 	 */
28
-	public static function init( array $confValues ) : void {
28
+	public static function init ( array $confValues ) : void {
29 29
 		if ( self::$instance ) {
30 30
 			throw new ConfigException( 'Config was already initialized' );
31 31
 		}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param string $key
45 45
 	 * @param mixed $value
46 46
 	 */
47
-	protected function set( string $key, $value ) : void {
47
+	protected function set ( string $key, $value ) : void {
48 48
 		$this->opts[ $key ] = $value;
49 49
 	}
50 50
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @return self
55 55
 	 * @throws ConfigException
56 56
 	 */
57
-	public static function getInstance() : self {
57
+	public static function getInstance () : self {
58 58
 		if ( !self::$instance ) {
59 59
 			throw new ConfigException( 'Config not yet initialized' );
60 60
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return mixed
69 69
 	 * @throws ConfigException
70 70
 	 */
71
-	public function get( string $opt ) {
71
+	public function get ( string $opt ) {
72 72
 		if ( !isset( $this->opts[ $opt ] ) ) {
73 73
 			throw new ConfigException( "Config option '$opt' not set." );
74 74
 		}
Please login to merge, or discard this patch.
includes/Task/Subtask/UserNotice.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\Task\Subtask;
4 4
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	/**
13 13
 	 * @inheritDoc
14 14
 	 */
15
-	public function runInternal() : int {
15
+	public function runInternal () : int {
16 16
 		$pages = $this->getDataProvider()->getCreatedPages();
17 17
 		$users = $this->getDataProvider()->getUsersToProcess();
18 18
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 			return TaskResult::STATUS_NOTHING;
21 21
 		}
22 22
 
23
-		$ricNums = [];
23
+		$ricNums = [ ];
24 24
 		foreach ( $pages as $page ) {
25 25
 			$ricNums[ $page->getUserName() ] = $page->getNum();
26 26
 		}
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param User $user
39 39
 	 * @param int $ricNum
40 40
 	 */
41
-	protected function addMsg( User $user, int $ricNum ) : void {
41
+	protected function addMsg ( User $user, int $ricNum ) : void {
42 42
 		$this->getLogger()->info( "Leaving msg to $user" );
43 43
 		$msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text();
44 44
 
Please login to merge, or discard this patch.
includes/Task/UpdateList.php 1 patch
Spacing   +30 added lines, -30 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
 
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	/**
19 19
 	 * @inheritDoc
20 20
 	 */
21
-	protected function getSubtasksMap(): array {
21
+	protected function getSubtasksMap (): array {
22 22
 		// Everything is done here.
23
-		return [];
23
+		return [ ];
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * @inheritDoc
28 28
 	 */
29
-	public function runInternal() : int {
29
+	public function runInternal () : int {
30 30
 		$this->actualList = $this->getActualAdmins();
31 31
 		$pageBotList = $this->getBotList();
32 32
 		$this->botList = $pageBotList->getDecodedContent();
@@ -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, true ) ) {
@@ -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
 		$wiki = $this->getWiki();
@@ -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 (
@@ -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
 			$groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) );
173 173
 			if ( !isset( $this->actualList[ $name ] ) ) {
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * @param string[] $names
184 184
 	 * @return \stdClass
185 185
 	 */
186
-	private function getRenameEntries( array $names ) : \stdClass {
186
+	private function getRenameEntries ( array $names ) : \stdClass {
187 187
 		$titles = array_map( static function ( $x ) {
188 188
 			return "Utente:$x";
189 189
 		}, $names );
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 	 * @param string[] $names
208 208
 	 * @return string[] [ old_name => new_name ]
209 209
 	 */
210
-	protected function getRenamedUsers( array $names ) : array {
210
+	protected function getRenamedUsers ( array $names ) : array {
211 211
 		if ( !$names ) {
212
-			return [];
212
+			return [ ];
213 213
 		}
214 214
 		$this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) );
215 215
 
216 216
 		$data = $this->getRenameEntries( $names );
217
-		$ret = [];
217
+		$ret = [ ];
218 218
 		foreach ( $data->query->logevents as $entry ) {
219 219
 			// 1 month is arbitrary
220 220
 			if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) {
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
 	 * @param array &$newContent
233 233
 	 * @param array $removed
234 234
 	 */
235
-	private function handleRenames( array &$newContent, array $removed ) : void {
235
+	private function handleRenames ( array &$newContent, array $removed ) : void {
236 236
 		$renameMap = $this->getRenamedUsers( array_keys( $removed ) );
237 237
 		foreach ( $removed as $oldName => $info ) {
238 238
 			if (
239 239
 				array_key_exists( $oldName, $renameMap ) &&
240
-				array_key_exists( $renameMap[$oldName], $newContent )
240
+				array_key_exists( $renameMap[ $oldName ], $newContent )
241 241
 			) {
242 242
 				// This user was renamed! Add this name as alias, if they're still listed
243 243
 				$newName = $renameMap[ $oldName ];
244 244
 				$this->getLogger()->info( "Found rename $oldName -> $newName" );
245
-				$aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) );
246
-				$newContent[ $newName ]['aliases'] = $aliases;
245
+				$aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) );
246
+				$newContent[ $newName ][ 'aliases' ] = $aliases;
247 247
 				// Transfer overrides to the new name.
248 248
 				$overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] );
249 249
 				$newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides );
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 	 * @param array[] $extra
258 258
 	 * @return string[] Removed users
259 259
 	 */
260
-	private function handleExtraAndMissing(
260
+	private function handleExtraAndMissing (
261 261
 		array &$newContent,
262 262
 		array $missing,
263 263
 		array $extra
264 264
 	) : array {
265
-		$removed = [];
265
+		$removed = [ ];
266 266
 		foreach ( $newContent as $user => $groups ) {
267 267
 			if ( isset( $missing[ $user ] ) ) {
268 268
 				$newContent[ $user ] = array_merge( $groups, $missing[ $user ] );
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) {
273 273
 					$newContent[ $user ] = $newGroups;
274 274
 				} else {
275
-					$removed[$user] = $newContent[$user];
275
+					$removed[ $user ] = $newContent[ $user ];
276 276
 					unset( $newContent[ $user ] );
277 277
 				}
278 278
 			}
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @param array[] $extra
290 290
 	 * @return array[]
291 291
 	 */
292
-	protected function getNewContent( array $missing, array $extra ) : array {
292
+	protected function getNewContent ( array $missing, array $extra ) : array {
293 293
 		$newContent = $this->botList;
294 294
 
295 295
 		$removed = $this->handleExtraAndMissing( $newContent, $missing, $extra );
@@ -309,12 +309,12 @@  discard block
 block discarded – undo
309 309
 	 *
310 310
 	 * @param array[] &$newContent
311 311
 	 */
312
-	protected function removeOverrides( array &$newContent ) : void {
313
-		$removed = [];
312
+	protected function removeOverrides ( array &$newContent ) : void {
313
+		$removed = [ ];
314 314
 		foreach ( $newContent as $user => $groups ) {
315 315
 			if ( PageBotList::isOverrideExpired( $groups ) ) {
316 316
 				unset( $newContent[ $user ][ 'override' ] );
317
-				$removed[] = $user;
317
+				$removed[ ] = $user;
318 318
 			}
319 319
 		}
320 320
 
Please login to merge, or discard this patch.
includes/TaskManager.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme;
4 4
 
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param MessageProvider $mp
63 63
 	 * @param PageBotList $pbl
64 64
 	 */
65
-	public function __construct(
65
+	public function __construct (
66 66
 		LoggerInterface $logger,
67 67
 		WikiGroup $wikiGroup,
68 68
 		MessageProvider $mp,
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
88 88
 	 * @return TaskResult
89 89
 	 */
90
-	public function run( string $mode, string $name = null ) : TaskResult {
90
+	public function run ( string $mode, string $name = null ) : TaskResult {
91 91
 		if ( $mode === self::MODE_COMPLETE ) {
92 92
 			return $this->runAllTasks();
93 93
 		} elseif ( $name === null ) {
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return TaskResult
104 104
 	 */
105
-	protected function runAllTasks() : TaskResult {
105
+	protected function runAllTasks () : TaskResult {
106 106
 		$orderedList = [
107 107
 			'update-list',
108 108
 			'start-new',
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @param string $name
125 125
 	 * @return TaskResult
126 126
 	 */
127
-	protected function runTask( string $name ) : TaskResult {
127
+	protected function runTask ( string $name ) : TaskResult {
128 128
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
129 129
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
130 130
 		}
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param string $name
139 139
 	 * @return TaskResult
140 140
 	 */
141
-	protected function runSubtask( string $name ) : TaskResult {
141
+	protected function runSubtask ( string $name ) : TaskResult {
142 142
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
143 143
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
144 144
 		}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param string $name
154 154
 	 * @return Task
155 155
 	 */
156
-	private function getTaskInstance( string $name ) : Task {
156
+	private function getTaskInstance ( string $name ) : Task {
157 157
 		$class = self::TASKS_MAP[ $name ];
158 158
 		/** @var Task $ret */
159 159
 		$ret = new $class(
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @param string $class
173 173
 	 * @return Subtask
174 174
 	 */
175
-	private function getSubtaskInstance( string $class ) : Subtask {
175
+	private function getSubtaskInstance ( string $class ) : Subtask {
176 176
 		/** @var Subtask $ret */
177 177
 		$ret = new $class(
178 178
 			$this->logger,
Please login to merge, or discard this patch.
includes/Request/RequestFactory.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
 namespace BotRiconferme\Request;
4 4
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * @param string $domain
11 11
 	 */
12
-	public function __construct( string $domain ) {
12
+	public function __construct ( string $domain ) {
13 13
 		$this->domain = $domain;
14 14
 	}
15 15
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 * @param array $params
18 18
 	 * @return RequestBase
19 19
 	 */
20
-	public function newFromParams( array $params ) : RequestBase {
20
+	public function newFromParams ( array $params ) : RequestBase {
21 21
 		if ( extension_loaded( 'curl' ) ) {
22 22
 			$ret = new CurlRequest( $params, $this->domain );
23 23
 		} else {
Please login to merge, or discard this patch.
includes/Request/RequestBase.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\Request;
4 4
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/** @var string */
33 33
 	protected $method = self::METHOD_GET;
34 34
 	/** @var string[] */
35
-	protected $newCookies = [];
35
+	protected $newCookies = [ ];
36 36
 
37 37
 	/**
38 38
 	 * @private Use RequestFactory
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param array $params
41 41
 	 * @param string $domain
42 42
 	 */
43
-	public function __construct( array $params, string $domain ) {
43
+	public function __construct ( array $params, string $domain ) {
44 44
 		$this->params = [ 'format' => 'json' ] + $params;
45 45
 		$this->url = $domain;
46 46
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return self For chaining
52 52
 	 */
53
-	public function setPost() : self {
53
+	public function setPost () : self {
54 54
 		$this->method = self::METHOD_POST;
55 55
 		return $this;
56 56
 	}
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 	 * @todo Return an iterable object which automatically continues the query only if the last
63 63
 	 *   entry available is reached.
64 64
 	 */
65
-	public function execute() : \stdClass {
65
+	public function execute () : \stdClass {
66 66
 		$curParams = $this->params;
67
-		$sets = [];
67
+		$sets = [ ];
68 68
 		do {
69 69
 			$res = $this->makeRequestInternal( $curParams );
70 70
 
71 71
 			$this->handleErrorAndWarnings( $res );
72
-			$sets[] = $res;
72
+			$sets[ ] = $res;
73 73
 
74 74
 			$finished = true;
75 75
 			if ( isset( $res->continue ) ) {
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 	 * @param array $params
88 88
 	 * @return \stdClass
89 89
 	 */
90
-	private function makeRequestInternal( array $params ) : \stdClass {
90
+	private function makeRequestInternal ( array $params ) : \stdClass {
91 91
 		if ( $this->method === self::METHOD_POST ) {
92
-			$params['maxlag'] = self::MAXLAG;
92
+			$params[ 'maxlag' ] = self::MAXLAG;
93 93
 		}
94 94
 		$query = http_build_query( $params );
95 95
 
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 	 * @param string $params
106 106
 	 * @return string
107 107
 	 */
108
-	abstract protected function reallyMakeRequest( string $params ) : string;
108
+	abstract protected function reallyMakeRequest ( string $params ) : string;
109 109
 
110 110
 	/**
111 111
 	 * After a request, set cookies for the next ones
112 112
 	 *
113 113
 	 * @param array $cookies
114 114
 	 */
115
-	protected function setCookies( array $cookies ) : void {
115
+	protected function setCookies ( array $cookies ) : void {
116 116
 		foreach ( $cookies as $cookie ) {
117 117
 			$bits = explode( ';', $cookie );
118
-			[ $name, $value ] = explode( '=', $bits[0] );
118
+			[ $name, $value ] = explode( '=', $bits[ 0 ] );
119 119
 			self::$cookiesToSet[ $name ] = $value;
120 120
 		}
121 121
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @param \stdClass $res
127 127
 	 * @return APIRequestException
128 128
 	 */
129
-	private function getException( \stdClass $res ) : APIRequestException {
129
+	private function getException ( \stdClass $res ) : APIRequestException {
130 130
 		switch ( $res->error->code ) {
131 131
 			case 'missingtitle':
132 132
 				$ex = new MissingPageException;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param \stdClass $res
150 150
 	 * @throws APIRequestException
151 151
 	 */
152
-	protected function handleErrorAndWarnings( \stdClass $res ) : void {
152
+	protected function handleErrorAndWarnings ( \stdClass $res ) : void {
153 153
 		if ( isset( $res->error ) ) {
154 154
 			throw $this->getException( $res );
155 155
 		} elseif ( isset( $res->warnings ) ) {
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param \stdClass[] $sets
166 166
 	 * @return \stdClass
167 167
 	 */
168
-	private function mergeSets( array $sets ) : \stdClass {
168
+	private function mergeSets ( array $sets ) : \stdClass {
169 169
 		// Use the first set as template
170 170
 		$ret = array_shift( $sets );
171 171
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @param array|\stdClass $second
183 183
 	 * @return array|\stdClass array
184 184
 	 */
185
-	private function recursiveMerge( $first, $second ) {
185
+	private function recursiveMerge ( $first, $second ) {
186 186
 		$ret = $first;
187 187
 		if ( is_array( $second ) ) {
188 188
 			$ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second;
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 	 *
201 201
 	 * @return array
202 202
 	 */
203
-	protected function getHeaders() :array {
203
+	protected function getHeaders () :array {
204 204
 		$ret = self::HEADERS;
205 205
 		if ( self::$cookiesToSet ) {
206
-			$cookies = [];
206
+			$cookies = [ ];
207 207
 			foreach ( self::$cookiesToSet as $cname => $cval ) {
208
-				$cookies[] = trim( "$cname=$cval" );
208
+				$cookies[ ] = trim( "$cname=$cval" );
209 209
 			}
210
-			$ret[] = 'Cookie: ' . implode( '; ', $cookies );
210
+			$ret[ ] = 'Cookie: ' . implode( '; ', $cookies );
211 211
 		}
212 212
 		return $ret;
213 213
 	}
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @param array $headers
219 219
 	 * @return string
220 220
 	 */
221
-	protected function buildHeadersString( array $headers ) : string {
221
+	protected function buildHeadersString ( array $headers ) : string {
222 222
 		$ret = '';
223 223
 		foreach ( $headers as $header ) {
224 224
 			$ret .= "$header\r\n";
Please login to merge, or discard this patch.
includes/ContextSource.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
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param MessageProvider $mp
37 37
 	 * @param PageBotList $pbl
38 38
 	 */
39
-	public function __construct(
39
+	public function __construct (
40 40
 		LoggerInterface $logger,
41 41
 		WikiGroup $wikiGroup,
42 42
 		MessageProvider $mp,
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @return LoggerInterface
54 54
 	 */
55
-	protected function getLogger() : LoggerInterface {
55
+	protected function getLogger () : LoggerInterface {
56 56
 		return $this->logger;
57 57
 	}
58 58
 
59 59
 	/**
60 60
 	 * @inheritDoc
61 61
 	 */
62
-	public function setLogger( LoggerInterface $logger ) : void {
62
+	public function setLogger ( LoggerInterface $logger ) : void {
63 63
 		$this->logger = $logger;
64 64
 	}
65 65
 
@@ -69,21 +69,21 @@  discard block
 block discarded – undo
69 69
 	 * @param string $optname
70 70
 	 * @return mixed
71 71
 	 */
72
-	protected function getOpt( string $optname ) {
72
+	protected function getOpt ( string $optname ) {
73 73
 		return $this->getConfig()->get( $optname );
74 74
 	}
75 75
 
76 76
 	/**
77 77
 	 * @return Config
78 78
 	 */
79
-	protected function getConfig() : Config {
79
+	protected function getConfig () : Config {
80 80
 		return $this->config;
81 81
 	}
82 82
 
83 83
 	/**
84 84
 	 * @param Config $cfg
85 85
 	 */
86
-	protected function setConfig( Config $cfg ) : void {
86
+	protected function setConfig ( Config $cfg ) : void {
87 87
 		$this->config = $cfg;
88 88
 	}
89 89
 
@@ -91,35 +91,35 @@  discard block
 block discarded – undo
91 91
 	 * Shorthand
92 92
 	 * @return Wiki
93 93
 	 */
94
-	protected function getWiki() : Wiki {
94
+	protected function getWiki () : Wiki {
95 95
 		return $this->getWikiGroup()->getMainWiki();
96 96
 	}
97 97
 
98 98
 	/**
99 99
 	 * @return WikiGroup
100 100
 	 */
101
-	protected function getWikiGroup() : WikiGroup {
101
+	protected function getWikiGroup () : WikiGroup {
102 102
 		return $this->wikiGroup;
103 103
 	}
104 104
 
105 105
 	/**
106 106
 	 * @param WikiGroup $wikiGroup
107 107
 	 */
108
-	protected function setWikiGroup( WikiGroup $wikiGroup ) : void {
108
+	protected function setWikiGroup ( WikiGroup $wikiGroup ) : void {
109 109
 		$this->wikiGroup = $wikiGroup;
110 110
 	}
111 111
 
112 112
 	/**
113 113
 	 * @return MessageProvider
114 114
 	 */
115
-	protected function getMessageProvider() : MessageProvider {
115
+	protected function getMessageProvider () : MessageProvider {
116 116
 		return $this->messageProvider;
117 117
 	}
118 118
 
119 119
 	/**
120 120
 	 * @param MessageProvider $mp
121 121
 	 */
122
-	protected function setMessageProvider( MessageProvider $mp ) : void {
122
+	protected function setMessageProvider ( MessageProvider $mp ) : void {
123 123
 		$this->messageProvider = $mp;
124 124
 	}
125 125
 
@@ -129,21 +129,21 @@  discard block
 block discarded – undo
129 129
 	 * @param string $key
130 130
 	 * @return Message
131 131
 	 */
132
-	protected function msg( string $key ) : Message {
132
+	protected function msg ( string $key ) : Message {
133 133
 		return $this->messageProvider->getMessage( $key );
134 134
 	}
135 135
 
136 136
 	/**
137 137
 	 * @return PageBotList
138 138
 	 */
139
-	public function getBotList() : PageBotList {
139
+	public function getBotList () : PageBotList {
140 140
 		return $this->pageBotList;
141 141
 	}
142 142
 
143 143
 	/**
144 144
 	 * @return RequestFactory
145 145
 	 */
146
-	public function getRequestFactory() : RequestFactory {
146
+	public function getRequestFactory () : RequestFactory {
147 147
 		return $this->getWiki()->getRequestFactory();
148 148
 	}
149 149
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param string $title
154 154
 	 * @return Page
155 155
 	 */
156
-	protected function getPage( string $title ) : Page {
156
+	protected function getPage ( string $title ) : Page {
157 157
 		return new Page( $title, $this->getWiki() );
158 158
 	}
159 159
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param string $name
164 164
 	 * @return User
165 165
 	 */
166
-	protected function getUser( string $name ) : User {
166
+	protected function getUser ( string $name ) : User {
167 167
 		$ui = $this->getBotList()->getUserInfo( $name );
168 168
 		return new User( $ui, $this->getWiki() );
169 169
 	}
Please login to merge, or discard this patch.
includes/Wiki/UserInfo.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Wiki;
4 4
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 * @param string $name
18 18
 	 * @param array $info
19 19
 	 */
20
-	public function __construct( string $name, array $info ) {
20
+	public function __construct ( string $name, array $info ) {
21 21
 		$this->name = $name;
22 22
 		$this->info = $info;
23 23
 	}
@@ -25,35 +25,35 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @return string
27 27
 	 */
28
-	public function getName() : string {
28
+	public function getName () : string {
29 29
 		return $this->name;
30 30
 	}
31 31
 
32 32
 	/**
33 33
 	 * @return array
34 34
 	 */
35
-	public function getInfo() : array {
35
+	public function getInfo () : array {
36 36
 		return $this->info;
37 37
 	}
38 38
 
39 39
 	/**
40 40
 	 * @return array
41 41
 	 */
42
-	public function extractGroups() : array {
42
+	public function extractGroups () : array {
43 43
 		return array_keys( $this->extractGroupsWithDates() );
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @return array
48 48
 	 */
49
-	public function extractGroupsWithDates() : array {
49
+	public function extractGroupsWithDates () : array {
50 50
 		return array_intersect_key( $this->getInfo(), array_fill_keys( self::GROUP_KEYS, 1 ) );
51 51
 	}
52 52
 
53 53
 	/**
54 54
 	 * @return array
55 55
 	 */
56
-	public function getAliases() : array {
57
-		return $this->getInfo()['aliases'] ?? [];
56
+	public function getAliases () : array {
57
+		return $this->getInfo()[ 'aliases' ] ?? [ ];
58 58
 	}
59 59
 }
Please login to merge, or discard this patch.
includes/Wiki/Page/PageRiconferma.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\Wiki\Page;
4 4
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	private $supportSection;
13 13
 	private $opposeSection;
14 14
 	/** @var array Counts of votes for each section */
15
-	private $sectionCounts = [];
15
+	private $sectionCounts = [ ];
16 16
 
17 17
 	// Possible outcomes of a vote
18 18
 	public const OUTCOME_OK = 0;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * because they can vary depending on whether the page is a vote, which is relatively
32 32
 	 * expensive to know since it requires parsing the content of the page.
33 33
 	 */
34
-	private function defineSections() : void {
34
+	private function defineSections () : void {
35 35
 		$this->supportSection = $this->isVote() ? 3 : 0;
36 36
 		$this->opposeSection = $this->isVote() ? 4 : 3;
37 37
 	}
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return string
43 43
 	 */
44
-	public function getUserName() : string {
45
-		return explode( '/', $this->title )[2];
44
+	public function getUserName () : string {
45
+		return explode( '/', $this->title )[ 2 ];
46 46
 	}
47 47
 
48 48
 	/**
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return int
52 52
 	 */
53
-	public function getNum() : int {
53
+	public function getNum () : int {
54 54
 		$bits = explode( '/', $this->getTitle() );
55 55
 		return (int)end( $bits );
56 56
 	}
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return string
62 62
 	 */
63
-	public function getUserNum() : string {
64
-		return explode( '/', $this->getTitle(), 3 )[2];
63
+	public function getUserNum () : string {
64
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
65 65
 	}
66 66
 
67 67
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return int
71 71
 	 */
72
-	public function getOpposingCount() : int {
72
+	public function getOpposingCount () : int {
73 73
 		$this->defineSections();
74 74
 		return $this->getCountForSection( $this->opposeSection );
75 75
 	}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @return int
81 81
 	 * @throws \BadMethodCallException
82 82
 	 */
83
-	public function getSupportCount() : int {
83
+	public function getSupportCount () : int {
84 84
 		if ( !$this->isVote() ) {
85 85
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
86 86
 		}
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 	 * @param int $secNum
95 95
 	 * @return int
96 96
 	 */
97
-	protected function getCountForSection( int $secNum ) : int {
97
+	protected function getCountForSection ( int $secNum ) : int {
98 98
 		if ( !isset( $this->sectionCounts[ $secNum ] ) ) {
99 99
 			$content = $this->wiki->getPageContent( $this->title, $secNum );
100 100
 			// Let's hope that this is good enough...
101
-			$this->sectionCounts[$secNum] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content );
101
+			$this->sectionCounts[ $secNum ] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content );
102 102
 		}
103
-		return $this->sectionCounts[$secNum];
103
+		return $this->sectionCounts[ $secNum ];
104 104
 	}
105 105
 
106 106
 	/**
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return int
110 110
 	 */
111
-	protected function getQuorum() : int {
111
+	protected function getQuorum () : int {
112 112
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
113
-		return (int)$this->getMatch( $reg )[1];
113
+		return (int)$this->getMatch( $reg )[ 1 ];
114 114
 	}
115 115
 
116 116
 	/**
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @return bool
120 120
 	 */
121
-	public function hasOpposition() : bool {
121
+	public function hasOpposition () : bool {
122 122
 		return $this->getOpposingCount() >= self::REQUIRED_OPPOSE;
123 123
 	}
124 124
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 *
128 128
 	 * @return int One of the OUTCOME_* constants
129 129
 	 */
130
-	public function getOutcome() : int {
130
+	public function getOutcome () : int {
131 131
 		if ( !$this->isVote() ) {
132 132
 			return self::OUTCOME_OK;
133 133
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @throws \BadMethodCallException
151 151
 	 * @throws \LogicException
152 152
 	 */
153
-	public function getOutcomeText() : string {
153
+	public function getOutcomeText () : string {
154 154
 		if ( !$this->isVote() ) {
155 155
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
156 156
 		}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @return bool
186 186
 	 */
187
-	public function isVote() : bool {
187
+	public function isVote () : bool {
188 188
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
189 189
 		return !$this->matches( $sectionReg );
190 190
 	}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 *
195 195
 	 * @return int
196 196
 	 */
197
-	public function getCreationTimestamp() : int {
197
+	public function getCreationTimestamp () : int {
198 198
 		return $this->wiki->getPageCreationTS( $this->title );
199 199
 	}
200 200
 
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @return int
205 205
 	 */
206
-	public function getEndTimestamp() : int {
206
+	public function getEndTimestamp () : int {
207 207
 		if ( $this->isVote() ) {
208 208
 			$reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!";
209 209
 			[ , $hours, $day ] = $this->getMatch( $reg );
Please login to merge, or discard this patch.