Passed
Push — master ( aecdf6...dbd8ef )
by Daimona
19:47 queued 17:09
created
src/Wiki/Wiki.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;
4 4
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param LoggerInterface $logger
37 37
 	 * @param RequestFactory $requestFactory
38 38
 	 */
39
-	public function __construct(
39
+	public function __construct (
40 40
 		LoginInfo $li,
41 41
 		LoggerInterface $logger,
42 42
 		RequestFactory $requestFactory
@@ -49,35 +49,35 @@  discard block
 block discarded – undo
49 49
 	/**
50 50
 	 * @return LoginInfo
51 51
 	 */
52
-	public function getLoginInfo() : LoginInfo {
52
+	public function getLoginInfo () : LoginInfo {
53 53
 		return $this->loginInfo;
54 54
 	}
55 55
 
56 56
 	/**
57 57
 	 * @return RequestFactory
58 58
 	 */
59
-	public function getRequestFactory() : RequestFactory {
59
+	public function getRequestFactory () : RequestFactory {
60 60
 		return $this->requestFactory;
61 61
 	}
62 62
 
63 63
 	/**
64 64
 	 * @param string $prefix
65 65
 	 */
66
-	public function setPagePrefix( string $prefix ) : void {
66
+	public function setPagePrefix ( string $prefix ) : void {
67 67
 		$this->pagePrefix = $prefix;
68 68
 	}
69 69
 
70 70
 	/**
71 71
 	 * @param string $ident
72 72
 	 */
73
-	public function setLocalUserIdentifier( string $ident ) : void {
73
+	public function setLocalUserIdentifier ( string $ident ) : void {
74 74
 		$this->localUserIdentifier = $ident;
75 75
 	}
76 76
 
77 77
 	/**
78 78
 	 * @return string
79 79
 	 */
80
-	public function getLocalUserIdentifier() : string {
80
+	public function getLocalUserIdentifier () : string {
81 81
 		return $this->localUserIdentifier;
82 82
 	}
83 83
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 * @param string $title
86 86
 	 * @param int|null $section
87 87
 	 */
88
-	private function logRead( string $title, int $section = null ) : void {
88
+	private function logRead ( string $title, int $section = null ) : void {
89 89
 		$fullTitle = $this->pagePrefix . $title;
90 90
 		$msg = "Retrieving content of $fullTitle" . ( $section !== null ? ", section $section" : '' );
91 91
 		$this->logger->info( $msg );
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @throws MissingPageException
101 101
 	 * @throws MissingSectionException
102 102
 	 */
103
-	public function getPageContent( string $title, int $section = null ) : string {
103
+	public function getPageContent ( string $title, int $section = null ) : string {
104 104
 		$this->logRead( $title, $section );
105 105
 		$params = [
106 106
 			'action' => 'query',
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 		];
112 112
 
113 113
 		if ( $section !== null ) {
114
-			$params['rvsection'] = $section;
114
+			$params[ 'rvsection' ] = $section;
115 115
 		}
116 116
 
117 117
 		$req = $this->buildRequest( $params );
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 			throw new MissingPageException( $title );
121 121
 		}
122 122
 
123
-		$mainSlot = $page->revisions[0]->slots->main;
123
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
124 124
 
125 125
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
126 126
 			throw new MissingSectionException( $title, $section );
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @phan-param array<int|string|bool> $params
136 136
 	 * @throws EditException
137 137
 	 */
138
-	public function editPage( array $params ) : void {
138
+	public function editPage ( array $params ) : void {
139 139
 		$this->login();
140 140
 
141 141
 		$params = [
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		] + $params;
145 145
 
146 146
 		if ( BOT_EDITS === true ) {
147
-			$params['bot'] = 1;
147
+			$params[ 'bot' ] = 1;
148 148
 		}
149 149
 
150 150
 		$res = $this->buildRequest( $params )->setPost()->executeSingle();
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
163 163
 	 * @throws LoginException
164 164
 	 */
165
-	public function login() : void {
165
+	public function login () : void {
166 166
 		if ( $this->loginInfo === null ) {
167 167
 			throw new CannotLoginException( 'Missing login data' );
168 168
 		}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$this->loggedIn = true;
194 194
 		// Clear tokens cache
195
-		$this->tokens = [];
195
+		$this->tokens = [ ];
196 196
 		$this->logger->info( 'Login succeeded' );
197 197
 	}
198 198
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @param string $type
203 203
 	 * @return string
204 204
 	 */
205
-	public function getToken( string $type ) : string {
205
+	public function getToken ( string $type ) : string {
206 206
 		if ( !isset( $this->tokens[ $type ] ) ) {
207 207
 			$params = [
208 208
 				'action' => 'query',
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	 * @param string $title
223 223
 	 * @return int
224 224
 	 */
225
-	public function getPageCreationTS( string $title ) : int {
225
+	public function getPageCreationTS ( string $title ) : int {
226 226
 		$params = [
227 227
 			'action' => 'query',
228 228
 			'prop' => 'revisions',
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		];
235 235
 
236 236
 		$page = $this->buildRequest( $params )->executeAsQuery()->current();
237
-		return strtotime( $page->revisions[0]->timestamp );
237
+		return strtotime( $page->revisions[ 0 ]->timestamp );
238 238
 	}
239 239
 
240 240
 	/**
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @param string $title
244 244
 	 * @param string $reason
245 245
 	 */
246
-	public function protectPage( string $title, string $reason ) : void {
246
+	public function protectPage ( string $title, string $reason ) : void {
247 247
 		$fullTitle = $this->pagePrefix . $title;
248 248
 		$this->logger->info( "Protecting page $fullTitle" );
249 249
 		$this->login();
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param string $username
267 267
 	 * @param string $reason
268 268
 	 */
269
-	public function blockUser( string $username, string $reason ) : void {
269
+	public function blockUser ( string $username, string $reason ) : void {
270 270
 		$this->logger->info( "Blocking user $username" );
271 271
 		$this->login();
272 272
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	 * @phan-param array<int|string|bool> $params
294 294
 	 * @return RequestBase
295 295
 	 */
296
-	private function buildRequest( array $params ) : RequestBase {
296
+	private function buildRequest ( array $params ) : RequestBase {
297 297
 		return $this->requestFactory->newFromParams( $params );
298 298
 	}
299 299
 }
Please login to merge, or discard this patch.
src/Logger/WikiLogger.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Logger;
4 4
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param string $summary
30 30
 	 * @param string $minlevel
31 31
 	 */
32
-	public function __construct( Page $logPage, string $summary, $minlevel = LogLevel::INFO ) {
32
+	public function __construct ( Page $logPage, string $summary, $minlevel = LogLevel::INFO ) {
33 33
 		$this->minLevel = $this->levelToInt( $minlevel );
34 34
 		$this->logPage = $logPage;
35 35
 		$this->summary = $summary;
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 	 * @param mixed[] $context
41 41
 	 * @suppress PhanUnusedPublicMethodParameter
42 42
 	 */
43
-	public function log( $level, $message, array $context = [] ) :void {
43
+	public function log ( $level, $message, array $context = [ ] ) :void {
44 44
 		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
45
-			$this->buffer[] = $this->getFormattedMessage( $level, $message );
45
+			$this->buffer[ ] = $this->getFormattedMessage( $level, $message );
46 46
 		}
47 47
 	}
48 48
 
49 49
 	/**
50 50
 	 * @return string
51 51
 	 */
52
-	protected function getOutput() : string {
52
+	protected function getOutput () : string {
53 53
 		$line = str_repeat( '-', 80 );
54 54
 		return "\n\n" . implode( "\n", $this->buffer ) . "\n$line\n\n";
55 55
 	}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	/**
58 58
 	 * @inheritDoc
59 59
 	 */
60
-	public function flush() : void {
60
+	public function flush () : void {
61 61
 		if ( $this->buffer ) {
62 62
 			$this->logPage->edit( [
63 63
 				'appendtext' => $this->getOutput(),
Please login to merge, or discard this patch.
src/Logger/LoggerTrait.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\Logger;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	 * @param string $level
12 12
 	 * @return int
13 13
 	 */
14
-	protected function levelToInt( string $level ) : int {
14
+	protected function levelToInt ( string $level ) : int {
15 15
 		// Order matters
16 16
 		$mapping = [
17 17
 			LogLevel::DEBUG,
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $message
32 32
 	 * @return string
33 33
 	 */
34
-	protected function getFormattedMessage( string $level, string $message ) : string {
34
+	protected function getFormattedMessage ( string $level, string $message ) : string {
35 35
 		return sprintf( '%s [%s] - %s', date( 'd M H:i:s' ), $level, $message );
36 36
 	}
37 37
 }
Please login to merge, or discard this patch.
src/Logger/MultiLogger.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
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @param IFlushingAwareLogger ...$loggers
16 16
 	 */
17
-	public function __construct( IFlushingAwareLogger ...$loggers ) {
17
+	public function __construct ( IFlushingAwareLogger ...$loggers ) {
18 18
 		$this->loggers = $loggers;
19 19
 	}
20 20
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param mixed[] $context
24 24
 	 * @suppress PhanUnusedPublicMethodParameter
25 25
 	 */
26
-	public function log( $level, $message, array $context = [] ) :void {
26
+	public function log ( $level, $message, array $context = [ ] ) :void {
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.
src/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
 
@@ -11,5 +11,5 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * Flush the buffer
13 13
 	 */
14
-	public function flush() : void;
14
+	public function flush () : void;
15 15
 }
Please login to merge, or discard this patch.
src/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
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param mixed[] $context
27 27
 	 * @suppress PhanUnusedPublicMethodParameter
28 28
 	 */
29
-	public function log( $level, $message, array $context = [] ) : void {
29
+	public function log ( $level, $message, array $context = [ ] ) : void {
30 30
 		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
31 31
 			echo $this->getFormattedMessage( $level, $message ) . "\n";
32 32
 		}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @inheritDoc
37 37
 	 */
38
-	public function flush() : void {
38
+	public function flush () : void {
39 39
 		// Everything else is printed immediately
40 40
 		echo "\n" . str_repeat( '-', 80 ) . "\n\n";
41 41
 	}
Please login to merge, or discard this patch.
src/TaskHelper/TaskResult.php 1 patch
Spacing   +9 added lines, -9 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\TaskHelper;
4 4
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param int $status One of the Task::STATUS_* constants
22 22
 	 * @param string[] $errors
23 23
 	 */
24
-	public function __construct( int $status, array $errors = [] ) {
24
+	public function __construct ( int $status, array $errors = [ ] ) {
25 25
 		$this->status = $status;
26 26
 		$this->errors = $errors;
27 27
 	}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @return int
31 31
 	 */
32
-	public function getStatus() : int {
32
+	public function getStatus () : int {
33 33
 		return $this->status;
34 34
 	}
35 35
 
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 	 * @return string[]
38 38
 	 * @suppress PhanUnreferencedPublicMethod
39 39
 	 */
40
-	public function getErrors() : array {
40
+	public function getErrors () : array {
41 41
 		return $this->errors;
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @param TaskResult $that
46 46
 	 */
47
-	public function merge( TaskResult $that ) : void {
47
+	public function merge ( TaskResult $that ) : void {
48 48
 		$this->status |= $that->status;
49 49
 		$this->errors = array_merge( $this->errors, $that->errors );
50 50
 	}
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @return string
54 54
 	 */
55
-	public function __toString() : string {
55
+	public function __toString () : string {
56 56
 		if ( $this->isOK() ) {
57 57
 			$stat = 'OK';
58 58
 			$errs = "\tNo errors.";
59 59
 		} else {
60 60
 			$stat = 'ERROR';
61
-			$formattedErrs = [];
61
+			$formattedErrs = [ ];
62 62
 			foreach ( $this->errors as $err ) {
63
-				$formattedErrs[] = "\t - $err";
63
+				$formattedErrs[ ] = "\t - $err";
64 64
 			}
65 65
 			$errs = implode( "\n", $formattedErrs );
66 66
 		}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return bool
74 74
 	 */
75
-	public function isOK() : bool {
75
+	public function isOK () : bool {
76 76
 		return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD;
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
src/TaskHelper/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\TaskHelper;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/** @var User[]|null */
16 16
 	private $processUsers;
17 17
 	/** @var PageRiconferma[] */
18
-	private $createdPages = [];
18
+	private $createdPages = [ ];
19 19
 	/** @var PageRiconferma[]|null */
20 20
 	private $openPages;
21 21
 	/** @var PageRiconferma[]|null */
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return User[]
28 28
 	 */
29
-	public function getUsersToProcess() : array {
29
+	public function getUsersToProcess () : array {
30 30
 		if ( $this->processUsers === null ) {
31
-			$this->processUsers = [];
31
+			$this->processUsers = [ ];
32 32
 			foreach ( $this->getBotList()->getAdminsList() as $name => $userInfo ) {
33 33
 				if ( $this->shouldAddUser( $userInfo ) ) {
34 34
 					$this->processUsers[ $name ] = new User( $userInfo, $this->getWiki() );
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param UserInfo $ui
46 46
 	 * @return bool
47 47
 	 */
48
-	private function shouldAddUser( UserInfo $ui ) : bool {
48
+	private function shouldAddUser ( UserInfo $ui ) : bool {
49 49
 		$timestamp = $this->getBotList()->getOverrideTimestamp( $ui );
50 50
 		$override = $timestamp !== null;
51 51
 
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return PageRiconferma[]
65 65
 	 */
66
-	public function getOpenPages() : array {
66
+	public function getOpenPages () : array {
67 67
 		if ( $this->openPages === null ) {
68
-			$this->openPages = [];
68
+			$this->openPages = [ ];
69 69
 			$mainTitle = $this->getOpt( 'main-page-title' );
70 70
 			$params = [
71 71
 				'action' => 'query',
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			$pages = $this->getRequestFactory()->newFromParams( $params )->executeAsQuery();
80 80
 			foreach ( $pages->current()->templates as $page ) {
81 81
 				if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) {
82
-					$this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() );
82
+					$this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() );
83 83
 				}
84 84
 			}
85 85
 		}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return PageRiconferma[]
94 94
 	 */
95
-	public function getPagesToClose() : array {
95
+	public function getPagesToClose () : array {
96 96
 		if ( $this->pagesToClose === null ) {
97
-			$this->pagesToClose = [];
97
+			$this->pagesToClose = [ ];
98 98
 			foreach ( $this->getOpenPages() as $page ) {
99 99
 				if ( time() > $page->getEndTimestamp() ) {
100
-					$this->pagesToClose[] = $page;
100
+					$this->pagesToClose[ ] = $page;
101 101
 				}
102 102
 			}
103 103
 		}
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @param string $name
111 111
 	 */
112
-	public function removeUser( string $name ) : void {
112
+	public function removeUser ( string $name ) : void {
113 113
 		unset( $this->processUsers[ $name ] );
114 114
 	}
115 115
 
116 116
 	/**
117 117
 	 * @return PageRiconferma[]
118 118
 	 */
119
-	public function getCreatedPages() : array {
119
+	public function getCreatedPages () : array {
120 120
 		return $this->createdPages;
121 121
 	}
122 122
 
123 123
 	/**
124 124
 	 * @param PageRiconferma $page
125 125
 	 */
126
-	public function addCreatedPage( PageRiconferma $page ) : void {
127
-		$this->createdPages[] = $page;
126
+	public function addCreatedPage ( PageRiconferma $page ) : void {
127
+		$this->createdPages[ ] = $page;
128 128
 	}
129 129
 }
Please login to merge, or discard this patch.