Passed
Push — master ( 4b4859...1d252d )
by Daimona
02:04
created
includes/Wiki/LoginInfo.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\Wiki;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @param string $username
16 16
 	 * @param string $password
17 17
 	 */
18
-	public function __construct( string $username, string $password ) {
18
+	public function __construct ( string $username, string $password ) {
19 19
 		$this->username = $username;
20 20
 		$this->password = $password;
21 21
 	}
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @return string
25 25
 	 */
26
-	public function getUsername() : string {
26
+	public function getUsername () : string {
27 27
 		return $this->username;
28 28
 	}
29 29
 
30 30
 	/**
31 31
 	 * @return string
32 32
 	 */
33
-	public function getPassword() : string {
33
+	public function getPassword () : string {
34 34
 		return $this->password;
35 35
 	}
36 36
 }
Please login to merge, or discard this patch.
includes/Wiki/Wiki.php 1 patch
Spacing   +18 added lines, -18 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
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @param LoggerInterface $logger
33 33
 	 * @param string $domain The URL of the wiki, if different from default
34 34
 	 */
35
-	public function __construct( LoggerInterface $logger, string $domain = DEFAULT_URL ) {
35
+	public function __construct ( LoggerInterface $logger, string $domain = DEFAULT_URL ) {
36 36
 		$this->logger = $logger;
37 37
 		$this->domain = $domain;
38 38
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	/**
41 41
 	 * @param LoginInfo $li
42 42
 	 */
43
-	public function setLoginInfo( LoginInfo $li ) : void {
43
+	public function setLoginInfo ( LoginInfo $li ) : void {
44 44
 		// FIXME This should be in the constructor, and it should not depend on config
45 45
 		$this->loginInfo = $li;
46 46
 	}
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 	/**
49 49
 	 * @return LoginInfo
50 50
 	 */
51
-	public function getLoginInfo() : LoginInfo {
51
+	public function getLoginInfo () : LoginInfo {
52 52
 		return $this->loginInfo;
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * @param bool $bot
57 57
 	 */
58
-	public function setEditsAsBot( bool $bot ) : void {
58
+	public function setEditsAsBot ( bool $bot ) : void {
59 59
 		// FIXME same as setLoginInfo
60 60
 		$this->botEdits = $bot;
61 61
 	}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	/**
64 64
 	 * @return bool
65 65
 	 */
66
-	public function getEditsAsBot() : bool {
66
+	public function getEditsAsBot () : bool {
67 67
 		return $this->botEdits;
68 68
 	}
69 69
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @throws MissingPageException
77 77
 	 * @throws MissingSectionException
78 78
 	 */
79
-	public function getPageContent( string $title, int $section = null ) : string {
79
+	public function getPageContent ( string $title, int $section = null ) : string {
80 80
 		$msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' );
81 81
 		$this->logger->debug( $msg );
82 82
 		$params = [
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		];
89 89
 
90 90
 		if ( $section !== null ) {
91
-			$params['rvsection'] = $section;
91
+			$params[ 'rvsection' ] = $section;
92 92
 		}
93 93
 
94 94
 		$req = $this->buildRequest( $params );
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 			throw new MissingPageException( $title );
99 99
 		}
100 100
 
101
-		$mainSlot = $page->revisions[0]->slots->main;
101
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
102 102
 
103 103
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
104 104
 			throw new MissingSectionException( $title, $section );
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @param array $params
113 113
 	 * @throws EditException
114 114
 	 */
115
-	public function editPage( array $params ) : void {
115
+	public function editPage ( array $params ) : void {
116 116
 		$this->login();
117 117
 
118 118
 		$params = [
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		] + $params;
122 122
 
123 123
 		if ( $this->getEditsAsBot() ) {
124
-			$params['bot'] = 1;
124
+			$params[ 'bot' ] = 1;
125 125
 		}
126 126
 
127 127
 		$res = $this->buildRequest( $params )->setPost()->execute();
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
140 140
 	 * @throws LoginException
141 141
 	 */
142
-	public function login() : void {
142
+	public function login () : void {
143 143
 		if ( $this->loginInfo === null ) {
144 144
 			throw new CannotLoginException( 'Missing login data' );
145 145
 		}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 
170 170
 		self::$loggedIn = true;
171 171
 		// Clear tokens cache
172
-		$this->tokens = [];
172
+		$this->tokens = [ ];
173 173
 		$this->logger->info( 'Login succeeded' );
174 174
 	}
175 175
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param string $type
180 180
 	 * @return string
181 181
 	 */
182
-	public function getToken( string $type ) : string {
182
+	public function getToken ( string $type ) : string {
183 183
 		if ( !isset( $this->tokens[ $type ] ) ) {
184 184
 			$params = [
185 185
 				'action' => 'query',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 	 * @param string $title
203 203
 	 * @return int
204 204
 	 */
205
-	public function getPageCreationTS( string $title ) : int {
205
+	public function getPageCreationTS ( string $title ) : int {
206 206
 		$params = [
207 207
 			'action' => 'query',
208 208
 			'prop' => 'revisions',
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
 		$res = $this->buildRequest( $params )->execute();
217 217
 		$data = $res->query->pages;
218
-		return strtotime( reset( $data )->revisions[0]->timestamp );
218
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
219 219
 	}
220 220
 
221 221
 	/**
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @param string $title
225 225
 	 * @param string $reason
226 226
 	 */
227
-	public function protectPage( string $title, string $reason ) : void {
227
+	public function protectPage ( string $title, string $reason ) : void {
228 228
 		$this->logger->info( "Protecting page $title" );
229 229
 		$this->login();
230 230
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @param array $params
246 246
 	 * @return RequestBase
247 247
 	 */
248
-	private function buildRequest( array $params ) : RequestBase {
248
+	private function buildRequest ( array $params ) : RequestBase {
249 249
 		return RequestBase::newFromParams( $params )->setUrl( $this->domain );
250 250
 	}
251 251
 }
Please login to merge, or discard this patch.
includes/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;
@@ -39,16 +39,16 @@  discard block
 block discarded – undo
39 39
 	 * @inheritDoc
40 40
 	 * @suppress PhanUnusedPublicMethodParameter
41 41
 	 */
42
-	public function log( $level, $message, array $context = [] ) :void {
42
+	public function log ( $level, $message, array $context = [ ] ) :void {
43 43
 		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
44
-			$this->buffer[] = $this->getFormattedMessage( $level, $message );
44
+			$this->buffer[ ] = $this->getFormattedMessage( $level, $message );
45 45
 		}
46 46
 	}
47 47
 
48 48
 	/**
49 49
 	 * @return string
50 50
 	 */
51
-	protected function getOutput() : string {
51
+	protected function getOutput () : string {
52 52
 		$line = str_repeat( '-', 80 );
53 53
 		return "\n\n" . implode( "\n", $this->buffer ) . "\n$line\n\n";
54 54
 	}
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	/**
57 57
 	 * @inheritDoc
58 58
 	 */
59
-	public function flush() : void {
59
+	public function flush () : void {
60 60
 		if ( $this->buffer ) {
61 61
 			$this->logPage->edit( [
62 62
 				'appendtext' => $this->getOutput(),
Please login to merge, or discard this patch.
includes/ContextSource.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;
4 4
 
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @param Wiki $wiki
30 30
 	 * @param MessageProvider $mp
31 31
 	 */
32
-	public function __construct( LoggerInterface $logger, Wiki $wiki, MessageProvider $mp ) {
32
+	public function __construct ( LoggerInterface $logger, Wiki $wiki, MessageProvider $mp ) {
33 33
 		$this->setLogger( $logger );
34 34
 		$this->setConfig( Config::getInstance() );
35 35
 		$this->setWiki( $wiki );
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @return LoggerInterface
41 41
 	 */
42
-	protected function getLogger() : LoggerInterface {
42
+	protected function getLogger () : LoggerInterface {
43 43
 		return $this->logger;
44 44
 	}
45 45
 
46 46
 	/**
47 47
 	 * @inheritDoc
48 48
 	 */
49
-	public function setLogger( LoggerInterface $logger ) : void {
49
+	public function setLogger ( LoggerInterface $logger ) : void {
50 50
 		$this->logger = $logger;
51 51
 	}
52 52
 
@@ -56,49 +56,49 @@  discard block
 block discarded – undo
56 56
 	 * @param string $optname
57 57
 	 * @return mixed
58 58
 	 */
59
-	protected function getOpt( string $optname ) {
59
+	protected function getOpt ( string $optname ) {
60 60
 		return $this->getConfig()->get( $optname );
61 61
 	}
62 62
 
63 63
 	/**
64 64
 	 * @return Config
65 65
 	 */
66
-	protected function getConfig() : Config {
66
+	protected function getConfig () : Config {
67 67
 		return $this->config;
68 68
 	}
69 69
 
70 70
 	/**
71 71
 	 * @param Config $cfg
72 72
 	 */
73
-	protected function setConfig( Config $cfg ) : void {
73
+	protected function setConfig ( Config $cfg ) : void {
74 74
 		$this->config = $cfg;
75 75
 	}
76 76
 
77 77
 	/**
78 78
 	 * @return Wiki
79 79
 	 */
80
-	protected function getWiki() : Wiki {
80
+	protected function getWiki () : Wiki {
81 81
 		return $this->wiki;
82 82
 	}
83 83
 
84 84
 	/**
85 85
 	 * @param Wiki $wiki
86 86
 	 */
87
-	protected function setWiki( Wiki $wiki ) : void {
87
+	protected function setWiki ( Wiki $wiki ) : void {
88 88
 		$this->wiki = $wiki;
89 89
 	}
90 90
 
91 91
 	/**
92 92
 	 * @return MessageProvider
93 93
 	 */
94
-	protected function getMessageProvider() : MessageProvider {
94
+	protected function getMessageProvider () : MessageProvider {
95 95
 		return $this->messageProvider;
96 96
 	}
97 97
 
98 98
 	/**
99 99
 	 * @param MessageProvider $mp
100 100
 	 */
101
-	protected function setMessageProvider( MessageProvider $mp ) : void {
101
+	protected function setMessageProvider ( MessageProvider $mp ) : void {
102 102
 		$this->messageProvider = $mp;
103 103
 	}
104 104
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @param string $key
109 109
 	 * @return Message
110 110
 	 */
111
-	protected function msg( string $key ) : Message {
111
+	protected function msg ( string $key ) : Message {
112 112
 		return $this->messageProvider->getMessage( $key );
113 113
 	}
114 114
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @param string $title
119 119
 	 * @return Page
120 120
 	 */
121
-	protected function getPage( string $title ) : Page {
121
+	protected function getPage ( string $title ) : Page {
122 122
 		return new Page( $title, $this->getWiki() );
123 123
 	}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $name
129 129
 	 * @return User
130 130
 	 */
131
-	protected function getUser( string $name ) : User {
131
+	protected function getUser ( string $name ) : User {
132 132
 		return new User( $name, $this->getWiki() );
133 133
 	}
134 134
 }
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
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @param Wiki $wiki
59 59
 	 * @param MessageProvider $mp
60 60
 	 */
61
-	public function __construct( LoggerInterface $logger, Wiki $wiki, MessageProvider $mp ) {
61
+	public function __construct ( LoggerInterface $logger, Wiki $wiki, MessageProvider $mp ) {
62 62
 		$this->logger = $logger;
63 63
 		$this->wiki = $wiki;
64 64
 		$this->messageProvider = $mp;
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
73 73
 	 * @return TaskResult
74 74
 	 */
75
-	public function run( string $mode, string $name = null ) : TaskResult {
75
+	public function run ( string $mode, string $name = null ) : TaskResult {
76 76
 		if ( $mode === self::MODE_COMPLETE ) {
77 77
 			return $this->runAllTasks();
78 78
 		} elseif ( $name === null ) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 *
88 88
 	 * @return TaskResult
89 89
 	 */
90
-	protected function runAllTasks() : TaskResult {
90
+	protected function runAllTasks () : TaskResult {
91 91
 		$orderedList = [
92 92
 			'update-list',
93 93
 			'start-new',
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @param string $name
110 110
 	 * @return TaskResult
111 111
 	 */
112
-	protected function runTask( string $name ) : TaskResult {
112
+	protected function runTask ( string $name ) : TaskResult {
113 113
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
114 114
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
115 115
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @param string $name
124 124
 	 * @return TaskResult
125 125
 	 */
126
-	protected function runSubtask( string $name ) : TaskResult {
126
+	protected function runSubtask ( string $name ) : TaskResult {
127 127
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
128 128
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
129 129
 		}
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param string $name
139 139
 	 * @return Task
140 140
 	 */
141
-	private function getTaskInstance( string $name ) : Task {
141
+	private function getTaskInstance ( string $name ) : Task {
142 142
 		$class = self::TASKS_MAP[ $name ];
143 143
 		/** @var Task $ret */
144 144
 		$ret = new $class( $this->logger, $this->wiki, $this->provider, $this->messageProvider );
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @param string $class
152 152
 	 * @return Subtask
153 153
 	 */
154
-	private function getSubtaskInstance( string $class ) : Subtask {
154
+	private function getSubtaskInstance ( string $class ) : Subtask {
155 155
 		/** @var Subtask $ret */
156 156
 		$ret = new $class( $this->logger, $this->wiki, $this->provider, $this->messageProvider );
157 157
 		return $ret;
Please login to merge, or discard this patch.
includes/Bot.php 1 patch
Spacing   +7 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param Wiki $wiki
22 22
 	 * @param MessageProvider $mp
23 23
 	 */
24
-	public function __construct( LoggerInterface $logger, Wiki $wiki, MessageProvider $mp ) {
24
+	public function __construct ( LoggerInterface $logger, Wiki $wiki, MessageProvider $mp ) {
25 25
 		$this->logger = $logger;
26 26
 		$this->wiki = $wiki;
27 27
 		$this->messageProvider = $mp;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param string $mode
34 34
 	 * @param string|null $name
35 35
 	 */
36
-	private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) : void {
36
+	private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) : void {
37 37
 		$activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name";
38 38
 		$this->logger->info( "Running $activity" );
39 39
 		$manager = new TaskManager( $this->logger, $this->wiki, $this->messageProvider );
@@ -41,8 +41,7 @@  discard block
 block discarded – undo
41 41
 		$base = "Execution of $activity";
42 42
 		if ( $res->isOK() ) {
43 43
 			$msg = $res->getStatus() === TaskResult::STATUS_NOTHING ?
44
-				': nothing to do' :
45
-				' completed successfully';
44
+				': nothing to do' : ' completed successfully';
46 45
 			$this->logger->info( $base . $msg );
47 46
 		} else {
48 47
 			$this->logger->error( "$base failed.\n$res" );
@@ -52,7 +51,7 @@  discard block
 block discarded – undo
52 51
 	/**
53 52
 	 * Entry point for the whole process
54 53
 	 */
55
-	public function runAll() : void {
54
+	public function runAll () : void {
56 55
 		$this->run();
57 56
 	}
58 57
 
@@ -61,7 +60,7 @@  discard block
 block discarded – undo
61 60
 	 *
62 61
 	 * @param string $task
63 62
 	 */
64
-	public function runTask( string $task ) : void {
63
+	public function runTask ( string $task ) : void {
65 64
 		$this->run( TaskManager::MODE_TASK, $task );
66 65
 	}
67 66
 
@@ -70,7 +69,7 @@  discard block
 block discarded – undo
70 69
 	 *
71 70
 	 * @param string $subtask
72 71
 	 */
73
-	public function runSubtask( string $subtask ) : void {
72
+	public function runSubtask ( string $subtask ) : void {
74 73
 		$this->run( TaskManager::MODE_SUBTASK, $subtask );
75 74
 	}
76 75
 }
Please login to merge, or discard this patch.
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
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/** @var self */
14 14
 	private static $instance;
15 15
 	/** @var array */
16
-	private $opts = [];
16
+	private $opts = [ ];
17 17
 	/** @var Wiki */
18 18
 	private $wiki;
19 19
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param Wiki $wiki
24 24
 	 */
25
-	private function __construct( Wiki $wiki ) {
25
+	private function __construct ( Wiki $wiki ) {
26 26
 		$this->wiki = $wiki;
27 27
 	}
28 28
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param Wiki $wiki
34 34
 	 * @throws ConfigException
35 35
 	 */
36
-	public static function init( string $configTitle, Wiki $wiki ) : void {
36
+	public static function init ( string $configTitle, Wiki $wiki ) : void {
37 37
 		if ( self::$instance ) {
38 38
 			throw new ConfigException( 'Config was already initialized' );
39 39
 		}
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * @param string $key
60 60
 	 * @param mixed $value
61 61
 	 */
62
-	protected function set( string $key, $value ) : void {
62
+	protected function set ( string $key, $value ) : void {
63 63
 		$this->opts[ $key ] = $value;
64 64
 	}
65 65
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @return self
70 70
 	 * @throws ConfigException
71 71
 	 */
72
-	public static function getInstance() : self {
72
+	public static function getInstance () : self {
73 73
 		if ( !self::$instance ) {
74 74
 			throw new ConfigException( 'Config not yet initialized' );
75 75
 		}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return mixed
84 84
 	 * @throws ConfigException
85 85
 	 */
86
-	public function get( string $opt ) {
86
+	public function get ( string $opt ) {
87 87
 		if ( !isset( $this->opts[ $opt ] ) ) {
88 88
 			throw new ConfigException( "Config option '$opt' not set." );
89 89
 		}
Please login to merge, or discard this patch.
includes/Wiki/Page/PageBotList.php 1 patch
Spacing   +18 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Wiki\Page;
4 4
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @private Use self::get()
19 19
 	 * @param Wiki $wiki
20 20
 	 */
21
-	public function __construct( Wiki $wiki ) {
21
+	public function __construct ( Wiki $wiki ) {
22 22
 		// phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix
23 23
 		global $globalListTitle;
24 24
 		parent::__construct( $globalListTitle, $wiki );
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 * @param Wiki $wiki
31 31
 	 * @return self
32 32
 	 */
33
-	public static function get( Wiki $wiki ) : self {
33
+	public static function get ( Wiki $wiki ) : self {
34 34
 		static $instance = null;
35 35
 		if ( $instance === null ) {
36 36
 			$instance = new self( $wiki );
@@ -42,16 +42,16 @@  discard block
 block discarded – undo
42 42
 	 * @param string[] $groups
43 43
 	 * @return int|null
44 44
 	 */
45
-	public static function getOverrideTimestamp( array $groups ) : ?int {
45
+	public static function getOverrideTimestamp ( array $groups ) : ?int {
46 46
 		if ( !array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) {
47 47
 			return null;
48 48
 		}
49 49
 
50 50
 		// A one-time override takes precedence
51 51
 		if ( array_key_exists( 'override', $groups ) ) {
52
-			$date = $groups['override'];
52
+			$date = $groups[ 'override' ];
53 53
 		} else {
54
-			$date = $groups['override-prem'] . '/' . date( 'Y' );
54
+			$date = $groups[ 'override-prem' ] . '/' . date( 'Y' );
55 55
 		}
56 56
 		return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp();
57 57
 	}
@@ -62,17 +62,15 @@  discard block
 block discarded – undo
62 62
 	 * @param array $groups
63 63
 	 * @return int
64 64
 	 */
65
-	public static function getValidFlagTimestamp( array $groups ): int {
66
-		$checkuser = isset( $groups['checkuser'] ) ?
67
-			\DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() :
68
-			0;
69
-		$bureaucrat = isset( $groups['bureaucrat'] ) ?
70
-			\DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() :
71
-			0;
65
+	public static function getValidFlagTimestamp ( array $groups ): int {
66
+		$checkuser = isset( $groups[ 'checkuser' ] ) ?
67
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
68
+		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
69
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
72 70
 
73 71
 		$timestamp = max( $bureaucrat, $checkuser );
74 72
 		if ( $timestamp === 0 ) {
75
-			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp();
73
+			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp();
76 74
 		}
77 75
 		return $timestamp;
78 76
 	}
@@ -81,14 +79,14 @@  discard block
 block discarded – undo
81 79
 	 * @param array $groups
82 80
 	 * @return bool
83 81
 	 */
84
-	public static function isOverrideExpired( array $groups ) : bool {
85
-		if ( !isset( $groups['override'] ) ) {
82
+	public static function isOverrideExpired ( array $groups ) : bool {
83
+		if ( !isset( $groups[ 'override' ] ) ) {
86 84
 			return false;
87 85
 		}
88 86
 
89 87
 		$flagTS = self::getValidFlagTimestamp( $groups );
90 88
 		$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
91
-		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
89
+		$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
92 90
 		$delay = 60 * 60 * 24 * 3;
93 91
 
94 92
 		return time() > $usualTS + $delay && time() > $overrideTS + $delay;
@@ -99,9 +97,9 @@  discard block
 block discarded – undo
99 97
 	 *
100 98
 	 * @return User[]
101 99
 	 */
102
-	public function getAdminsList() : array {
100
+	public function getAdminsList () : array {
103 101
 		if ( $this->adminsList === null ) {
104
-			$this->adminsList = [];
102
+			$this->adminsList = [ ];
105 103
 			foreach ( $this->getDecodedContent() as $user => $info ) {
106 104
 				$userObj = new User( $user, $this->wiki );
107 105
 				$userObj->setInfo( $info );
@@ -116,7 +114,7 @@  discard block
 block discarded – undo
116 114
 	 *
117 115
 	 * @return array[]
118 116
 	 */
119
-	public function getDecodedContent() : array {
117
+	public function getDecodedContent () : array {
120 118
 		return json_decode( $this->getContent(), true );
121 119
 	}
122 120
 }
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->checkRequiredOpts( $opts );
70 70
 		$this->checkConflictingOpts( $opts );
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * @param array $opts
77 77
 	 */
78
-	private function checkRequiredOpts( array $opts ) : void {
78
+	private function checkRequiredOpts ( array $opts ) : void {
79 79
 		$missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) );
80 80
 		if ( $missingOpts ) {
81 81
 			exit( 'Required options missing: ' . implode( ', ', $missingOpts ) );
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	/**
92 92
 	 * @param array $opts
93 93
 	 */
94
-	private function checkConflictingOpts( array $opts ) : void {
94
+	private function checkConflictingOpts ( array $opts ) : void {
95 95
 		$hasPw = array_key_exists( 'password', $opts );
96 96
 		$hasPwFile = array_key_exists( 'use-password-file', $opts );
97 97
 		if ( $hasPw && $hasPwFile ) {
@@ -108,11 +108,11 @@  discard block
 block discarded – undo
108 108
 	/**
109 109
 	 * @param array &$opts
110 110
 	 */
111
-	private function canonicalize( array &$opts ) : void {
111
+	private function canonicalize ( array &$opts ) : void {
112 112
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
113 113
 			$pw = trim( file_get_contents( self::PASSWORD_FILE ) );
114
-			$opts['password'] = $pw;
115
-			unset( $opts['use-password-file'] );
114
+			$opts[ 'password' ] = $pw;
115
+			unset( $opts[ 'use-password-file' ] );
116 116
 		}
117 117
 	}
118 118
 
@@ -121,14 +121,14 @@  discard block
 block discarded – undo
121 121
 	 * @param mixed|null $default
122 122
 	 * @return mixed
123 123
 	 */
124
-	public function getOpt( string $opt, $default = null ) {
125
-		return $this->opts[$opt] ?? $default;
124
+	public function getOpt ( string $opt, $default = null ) {
125
+		return $this->opts[ $opt ] ?? $default;
126 126
 	}
127 127
 
128 128
 	/**
129 129
 	 * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ]
130 130
 	 */
131
-	public function getTaskOpt() : array {
131
+	public function getTaskOpt () : array {
132 132
 		return array_intersect_key(
133 133
 			$this->opts,
134 134
 			[ 'task' => true, 'subtask' => true ]
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	/**
139 139
 	 * @return string|null
140 140
 	 */
141
-	public function getURL() : ?string {
141
+	public function getURL () : ?string {
142 142
 		return $this->getOpt( 'force-url' );
143 143
 	}
144 144
 }
Please login to merge, or discard this patch.