Passed
Push — master ( db90a8...2e33cb )
by Daimona
13:14 queued 11:27
created
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;
@@ -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.
includes/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.
includes/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.
includes/Wiki/User.php 1 patch
Spacing   +13 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\Wiki;
4 4
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param UserInfo $ui
24 24
 	 * @param Wiki $wiki
25 25
 	 */
26
-	public function __construct( UserInfo $ui, Wiki $wiki ) {
26
+	public function __construct ( UserInfo $ui, Wiki $wiki ) {
27 27
 		$this->wiki = $wiki;
28 28
 		$this->name = $ui->getName();
29 29
 		$this->ui = $ui;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @return string
34 34
 	 */
35
-	public function getName() : string {
35
+	public function getName () : string {
36 36
 		return $this->name;
37 37
 	}
38 38
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return string[]
43 43
 	 */
44
-	public function getGroups() : array {
44
+	public function getGroups () : array {
45 45
 		return $this->ui->extractGroups();
46 46
 	}
47 47
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @return string[] [ group => date ]
52 52
 	 */
53
-	public function getGroupsWithDates() : array {
53
+	public function getGroupsWithDates () : array {
54 54
 		return $this->ui->extractGroupsWithDates();
55 55
 	}
56 56
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 * @param string $groupName
61 61
 	 * @return bool
62 62
 	 */
63
-	public function inGroup( string $groupName ) : bool {
63
+	public function inGroup ( string $groupName ) : bool {
64 64
 		return in_array( $groupName, $this->getGroups(), true );
65 65
 	}
66 66
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @inheritDoc
71 71
 	 */
72
-	public function getRegex( string $delimiter = '/' ) : string {
72
+	public function getRegex ( string $delimiter = '/' ) : string {
73 73
 		$bits = $this->getAliases();
74
-		$bits[] = $this->name;
74
+		$bits[ ] = $this->name;
75 75
 		$regexify = static function ( string $el ) use ( $delimiter ) : string {
76 76
 			return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) );
77 77
 		};
@@ -83,14 +83,14 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return string[]
85 85
 	 */
86
-	public function getAliases() : array {
86
+	public function getAliases () : array {
87 87
 		return $this->ui->getAliases();
88 88
 	}
89 89
 
90 90
 	/**
91 91
 	 * @return Page
92 92
 	 */
93
-	public function getTalkPage() : Page {
93
+	public function getTalkPage () : Page {
94 94
 		return new Page( "User talk:{$this->name}", $this->wiki );
95 95
 	}
96 96
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * Get the default base page, e.g. WP:A/Riconferma annuale/XXX
99 99
 	 * @return Page
100 100
 	 */
101
-	public function getBasePage() : Page {
101
+	public function getBasePage () : Page {
102 102
 		$prefix = Config::getInstance()->get( 'main-page-title' );
103 103
 		return new Page( "$prefix/$this", $this->wiki );
104 104
 	}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @throws MissingPageException
111 111
 	 * @return Page
112 112
 	 */
113
-	public function getExistingBasePage() : Page {
113
+	public function getExistingBasePage () : Page {
114 114
 		$basePage = $this->getBasePage();
115 115
 		if ( !$basePage->exists() ) {
116 116
 			$basePage = null;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	/**
135 135
 	 * @return string
136 136
 	 */
137
-	public function __toString() : string {
137
+	public function __toString () : string {
138 138
 		return $this->name;
139 139
 	}
140 140
 }
Please login to merge, or discard this patch.
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.
includes/TaskManager.php 1 patch
Spacing   +10 added lines, -10 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
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 * @param MessageProvider $mp
65 65
 	 * @param PageBotList $pbl
66 66
 	 */
67
-	public function __construct(
67
+	public function __construct (
68 68
 		LoggerInterface $logger,
69 69
 		WikiGroup $wikiGroup,
70 70
 		MessageProvider $mp,
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @param string[] $tasks Only used in MODE_TASK and MODE_SUBTASK
90 90
 	 * @return TaskResult
91 91
 	 */
92
-	public function run( string $mode, array $tasks = [] ) : TaskResult {
92
+	public function run ( string $mode, array $tasks = [ ] ) : TaskResult {
93 93
 		if ( $mode === self::MODE_COMPLETE ) {
94 94
 			return $this->runAllTasks();
95 95
 		}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return TaskResult
106 106
 	 */
107
-	protected function runAllTasks() : TaskResult {
107
+	protected function runAllTasks () : TaskResult {
108 108
 		$orderedList = [
109 109
 			'update-list',
110 110
 			'start-new',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @param string[] $tasks
122 122
 	 * @return TaskResult
123 123
 	 */
124
-	private function runTasks( array $tasks ) : TaskResult {
124
+	private function runTasks ( array $tasks ) : TaskResult {
125 125
 		$res = new TaskResult( TaskResult::STATUS_GOOD );
126 126
 		do {
127 127
 			$res->merge( $this->runTask( current( $tasks ) ) );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @param string $name
137 137
 	 * @return TaskResult
138 138
 	 */
139
-	protected function runTask( string $name ) : TaskResult {
139
+	protected function runTask ( string $name ) : TaskResult {
140 140
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
141 141
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
142 142
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	 * @param string[] $subtasks
151 151
 	 * @return TaskResult
152 152
 	 */
153
-	private function runSubtasks( array $subtasks ) : TaskResult {
153
+	private function runSubtasks ( array $subtasks ) : TaskResult {
154 154
 		$res = new TaskResult( TaskResult::STATUS_GOOD );
155 155
 		do {
156 156
 			$res->merge( $this->runSubtask( current( $subtasks ) ) );
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @param string $name
166 166
 	 * @return TaskResult
167 167
 	 */
168
-	protected function runSubtask( string $name ) : TaskResult {
168
+	protected function runSubtask ( string $name ) : TaskResult {
169 169
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
170 170
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
171 171
 		}
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * @param string $name
181 181
 	 * @return Task
182 182
 	 */
183
-	private function getTaskInstance( string $name ) : Task {
183
+	private function getTaskInstance ( string $name ) : Task {
184 184
 		$class = self::TASKS_MAP[ $name ];
185 185
 		/** @var Task $ret */
186 186
 		$ret = new $class(
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @param string $class
200 200
 	 * @return Subtask
201 201
 	 */
202
-	private function getSubtaskInstance( string $class ) : Subtask {
202
+	private function getSubtaskInstance ( string $class ) : Subtask {
203 203
 		/** @var Subtask $ret */
204 204
 		$ret = new $class(
205 205
 			$this->logger,
Please login to merge, or discard this patch.