Passed
Push — master ( a1ef81...93b1f3 )
by Daimona
02:13
created
includes/Bot.php 1 patch
Spacing   +12 added lines, -13 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
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @param CLI $cli
36 36
 	 */
37
-	public function __construct( CLI $cli ) {
37
+	public function __construct ( CLI $cli ) {
38 38
 		$this->cli = $cli;
39 39
 		$this->initialize();
40 40
 	}
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	/**
43 43
 	 * Initialize all members.
44 44
 	 */
45
-	private function initialize() : void {
45
+	private function initialize () : void {
46 46
 		$simpleLogger = new SimpleLogger();
47 47
 		$this->createWikiGroup( $simpleLogger );
48 48
 		$this->messageProvider = new MessageProvider(
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	/**
57 57
 	 * Main entry point
58 58
 	 */
59
-	public function run() : void {
59
+	public function run () : void {
60 60
 		$taskOpt = $this->cli->getTaskOpt();
61 61
 		$type = current( array_keys( $taskOpt ) );
62 62
 		try {
63 63
 			if ( $type === 'tasks' ) {
64
-				$this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt['tasks'] ) );
64
+				$this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt[ 'tasks' ] ) );
65 65
 			} elseif ( $type === 'subtasks' ) {
66
-				$this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt['subtasks'] ) );
66
+				$this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt[ 'subtasks' ] ) );
67 67
 			} else {
68 68
 				$this->runInternal();
69 69
 			}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	/**
78 78
 	 * @param LoggerInterface $baseLogger
79 79
 	 */
80
-	private function createWikiGroup( LoggerInterface $baseLogger ) : void {
80
+	private function createWikiGroup ( LoggerInterface $baseLogger ) : void {
81 81
 		// FIXME Hardcoded
82 82
 		$url = $this->cli->getURL() ?? 'https://it.wikipedia.org/w/api.php';
83 83
 		$localUserIdentifier = '@itwiki';
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @param IFlushingAwareLogger $baseLogger
117 117
 	 */
118
-	private function createMainLogger( IFlushingAwareLogger $baseLogger ) : void {
118
+	private function createMainLogger ( IFlushingAwareLogger $baseLogger ) : void {
119 119
 		$mainWiki = $this->wikiGroup->getMainWiki();
120 120
 		$mp = $this->messageProvider;
121 121
 		$errTitle = $this->cli->getOpt( 'error-title' );
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	/**
143 143
 	 * Create the Config
144 144
 	 */
145
-	private function initConfig() : void {
145
+	private function initConfig () : void {
146 146
 		$wiki = $this->wikiGroup->getMainWiki();
147 147
 		try {
148 148
 			$confValues = json_decode( $wiki->getPageContent( $this->cli->getSetOpt( 'config-title' ) ), true );
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 * @param string $mode
160 160
 	 * @param string[] $taskNames
161 161
 	 */
162
-	private function runInternal(
162
+	private function runInternal (
163 163
 		string $mode = TaskManager::MODE_COMPLETE,
164
-		array $taskNames = []
164
+		array $taskNames = [ ]
165 165
 	) : void {
166 166
 		$activity = $mode === TaskManager::MODE_COMPLETE
167 167
 			? 'full process'
@@ -181,8 +181,7 @@  discard block
 block discarded – undo
181 181
 		$base = "Execution of $activity";
182 182
 		if ( $res->isOK() ) {
183 183
 			$msg = $res->getStatus() === TaskResult::STATUS_NOTHING ?
184
-				': nothing to do' :
185
-				' completed successfully';
184
+				': nothing to do' : ' completed successfully';
186 185
 			$this->mainLogger->info( $base . $msg );
187 186
 		} else {
188 187
 			$this->mainLogger->error( "$base failed.\n$res" );
Please login to merge, or discard this patch.
includes/CLI.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;
4 4
 
@@ -66,14 +66,14 @@  discard block
 block discarded – undo
66 66
 	/**
67 67
 	 * @return bool
68 68
 	 */
69
-	public static function isCLI() : bool {
69
+	public static function isCLI () : bool {
70 70
 		return PHP_SAPI === 'cli';
71 71
 	}
72 72
 
73 73
 	/**
74 74
 	 * Populate options and check for required ones
75 75
 	 */
76
-	public function __construct() {
76
+	public function __construct () {
77 77
 		/** @var string[] $opts */
78 78
 		$opts = getopt( self::SHORT_OPTS, self::LONG_OPTS );
79 79
 		$this->checkRequiredOpts( $opts );
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	/**
86 86
 	 * @param string[] $opts
87 87
 	 */
88
-	private function checkRequiredOpts( array $opts ) : void {
88
+	private function checkRequiredOpts ( array $opts ) : void {
89 89
 		$missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) );
90 90
 		if ( $missingOpts ) {
91 91
 			$this->fatal( 'Required options missing: ' . implode( ', ', $missingOpts ) );
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	/**
108 108
 	 * @param string[] $opts
109 109
 	 */
110
-	private function checkConflictingOpts( array $opts ) : void {
110
+	private function checkConflictingOpts ( array $opts ) : void {
111 111
 		$this->checkNotBothSet( $opts, 'password', 'use-password-file' );
112 112
 		if ( array_key_exists( 'use-password-file', $opts ) && !file_exists( self::PASSWORD_FILE ) ) {
113 113
 			$this->fatal( 'Please create the password file (' . self::PASSWORD_FILE . ')' );
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $first
129 129
 	 * @param string $second
130 130
 	 */
131
-	private function checkNotBothSet( array $opts, string $first, string $second ) : void {
131
+	private function checkNotBothSet ( array $opts, string $first, string $second ) : void {
132 132
 		if ( array_key_exists( $first, $opts ) && array_key_exists( $second, $opts ) ) {
133 133
 			$this->fatal( "Can only use one of '$first' and '$second'" );
134 134
 		}
@@ -137,23 +137,23 @@  discard block
 block discarded – undo
137 137
 	/**
138 138
 	 * @param string[] &$opts
139 139
 	 */
140
-	private function canonicalize( array &$opts ) : void {
140
+	private function canonicalize ( array &$opts ) : void {
141 141
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
142 142
 			$pw = trim( file_get_contents( self::PASSWORD_FILE ) );
143
-			$opts['password'] = $pw;
144
-			unset( $opts['use-password-file'] );
143
+			$opts[ 'password' ] = $pw;
144
+			unset( $opts[ 'use-password-file' ] );
145 145
 		}
146 146
 		if ( array_key_exists( 'use-private-password-file', $opts ) ) {
147 147
 			$pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) );
148
-			$opts['private-password'] = $pw;
149
-			unset( $opts['use-private-password-file'] );
148
+			$opts[ 'private-password' ] = $pw;
149
+			unset( $opts[ 'use-private-password-file' ] );
150 150
 		}
151 151
 	}
152 152
 
153 153
 	/**
154 154
 	 * @param string $msg
155 155
 	 */
156
-	private function fatal( string $msg ) : void {
156
+	private function fatal ( string $msg ) : void {
157 157
 		exit( $msg . "\n" );
158 158
 	}
159 159
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 * @param string $opt
163 163
 	 * @return string
164 164
 	 */
165
-	public function getSetOpt( string $opt ) : string {
166
-		return $this->opts[$opt];
165
+	public function getSetOpt ( string $opt ) : string {
166
+		return $this->opts[ $opt ];
167 167
 	}
168 168
 
169 169
 	/**
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 	 * @param string|null $default
172 172
 	 * @return string|null
173 173
 	 */
174
-	public function getOpt( string $opt, string $default = null ) : ?string {
175
-		return $this->opts[$opt] ?? $default;
174
+	public function getOpt ( string $opt, string $default = null ) : ?string {
175
+		return $this->opts[ $opt ] ?? $default;
176 176
 	}
177 177
 
178 178
 	/**
179 179
 	 * @return string[] Either [ 'tasks' => name1,... ] or [ 'subtasks' => name1,... ]
180 180
 	 */
181
-	public function getTaskOpt() : array {
181
+	public function getTaskOpt () : array {
182 182
 		return array_intersect_key(
183 183
 			$this->opts,
184 184
 			[ 'tasks' => true, 'subtasks' => true ]
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	/**
189 189
 	 * @return string|null
190 190
 	 */
191
-	public function getURL() : ?string {
191
+	public function getURL () : ?string {
192 192
 		return $this->getOpt( 'force-url' );
193 193
 	}
194 194
 }
Please login to merge, or discard this patch.