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