Passed
Push — master ( c739e9...bbcd54 )
by Daimona
02:10
created
includes/Task/UpdateList.php 1 patch
Spacing   +22 added lines, -22 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\Task;
4 4
 
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 	/**
20 20
 	 * @inheritDoc
21 21
 	 */
22
-	protected function getSubtasksMap(): array {
22
+	protected function getSubtasksMap (): array {
23 23
 		// Everything is done here.
24
-		return [];
24
+		return [ ];
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * @inheritDoc
29 29
 	 */
30
-	public function runInternal() : int {
30
+	public function runInternal () : int {
31 31
 		$this->actualList = $this->getActualAdmins();
32 32
 		$pageBotList = PageBotList::get( $this->getWiki() );
33 33
 		$this->botList = $pageBotList->getAdminsList();
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		$extra = $this->getExtraGroups();
37 37
 
38 38
 		$newContent = $this->getNewContent( $missing, $extra );
39
-throw new \Exception('foo');
39
+throw new \Exception( 'foo' );
40 40
 		if ( $newContent === $this->botList ) {
41 41
 			return TaskResult::STATUS_NOTHING;
42 42
 		}
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * @return array
56 56
 	 */
57
-	protected function getActualAdmins() : array {
57
+	protected function getActualAdmins () : array {
58 58
 		$params = [
59 59
 			'action' => 'query',
60 60
 			'list' => 'allusers',
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param \stdClass $data
72 72
 	 * @return array
73 73
 	 */
74
-	protected function extractAdmins( \stdClass $data ) : array {
75
-		$ret = [];
74
+	protected function extractAdmins ( \stdClass $data ) : array {
75
+		$ret = [ ];
76 76
 		$blacklist = $this->getOpt( 'exclude-admins' );
77 77
 		foreach ( $data->query->allusers as $u ) {
78 78
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return array[]
91 91
 	 */
92
-	protected function getMissingGroups() : array {
93
-		$missing = [];
92
+	protected function getMissingGroups () : array {
93
+		$missing = [ ];
94 94
 		foreach ( $this->actualList as $adm => $groups ) {
95
-			$curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) );
95
+			$curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) );
96 96
 
97 97
 			foreach ( $curMissing as $group ) {
98 98
 				try {
99 99
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
100 100
 				} catch ( TaskException $e ) {
101
-					$this->errors[] = $e->getMessage();
101
+					$this->errors[ ] = $e->getMessage();
102 102
 				}
103 103
 			}
104 104
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @return string
114 114
 	 * @throws TaskException
115 115
 	 */
116
-	protected function getFlagDate( string $admin, string $group ) : string {
116
+	protected function getFlagDate ( string $admin, string $group ) : string {
117 117
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
118 118
 
119 119
 		$url = DEFAULT_URL;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param string $group
150 150
 	 * @return string|null
151 151
 	 */
152
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
152
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
153 153
 		$ts = null;
154 154
 		foreach ( $data->query->logevents as $entry ) {
155 155
 			if ( isset( $entry->params ) ) {
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return array[]
170 170
 	 */
171
-	protected function getExtraGroups() : array {
172
-		$extra = [];
171
+	protected function getExtraGroups () : array {
172
+		$extra = [ ];
173 173
 		foreach ( $this->botList as $name => $groups ) {
174 174
 			// These are not groups
175 175
 			unset( $groups[ 'override' ], $groups[ 'override-perm' ] );
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param array[] $extra
190 190
 	 * @return array[]
191 191
 	 */
192
-	protected function getNewContent( array $missing, array $extra ) : array {
192
+	protected function getNewContent ( array $missing, array $extra ) : array {
193 193
 		$newContent = $this->botList;
194 194
 		foreach ( $newContent as $user => $groups ) {
195 195
 			if ( isset( $missing[ $user ] ) ) {
@@ -213,21 +213,21 @@  discard block
 block discarded – undo
213 213
 	 * @param array[] $newContent
214 214
 	 * @return array[]
215 215
 	 */
216
-	protected function removeOverrides( array $newContent ) : array {
217
-		$removed = [];
216
+	protected function removeOverrides ( array $newContent ) : array {
217
+		$removed = [ ];
218 218
 		foreach ( $newContent as $user => $groups ) {
219
-			if ( !isset( $groups['override'] ) ) {
219
+			if ( !isset( $groups[ 'override' ] ) ) {
220 220
 				continue;
221 221
 			}
222 222
 
223 223
 			$flagTS = PageBotList::getValidFlagTimestamp( $groups );
224 224
 			$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
225
-			$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
225
+			$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
226 226
 			$delay = 60 * 60 * 24 * 3;
227 227
 
228 228
 			if ( time() > $usualTS + $delay && time() > $overrideTS + $delay ) {
229 229
 				unset( $newContent[ $user ][ 'override' ] );
230
-				$removed[] = $user;
230
+				$removed[ ] = $user;
231 231
 			}
232 232
 		}
233 233
 
Please login to merge, or discard this patch.
includes/Task/TaskBase.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\Task;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class TaskBase extends ContextSource {
15 15
 	/** @var string[] */
16
-	protected $errors = [];
16
+	protected $errors = [ ];
17 17
 	/** @var TaskDataProvider */
18 18
 	protected $dataProvider;
19 19
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 * @param Wiki $wiki
25 25
 	 * @param TaskDataProvider $dataProvider
26 26
 	 */
27
-	final public function __construct(
27
+	final public function __construct (
28 28
 		LoggerInterface $logger,
29 29
 		Wiki $wiki,
30 30
 		TaskDataProvider $dataProvider
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		$this->dataProvider = $dataProvider;
36 36
 	}
37 37
 
38
-	public function __destruct() {
38
+	public function __destruct () {
39 39
 		restore_error_handler();
40 40
 		restore_exception_handler();
41 41
 	}
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return TaskResult
47 47
 	 */
48
-	final public function run() : TaskResult {
48
+	final public function run () : TaskResult {
49 49
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
50 50
 		$opName = $this->getOperationName();
51 51
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -76,14 +76,14 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return int One of the STATUS_* constants
78 78
 	 */
79
-	abstract protected function runInternal() : int;
79
+	abstract protected function runInternal () : int;
80 80
 
81 81
 	/**
82 82
 	 * How this operation should be called in logs
83 83
 	 *
84 84
 	 * @return string
85 85
 	 */
86
-	abstract public function getOperationName() : string;
86
+	abstract public function getOperationName () : string;
87 87
 
88 88
 	/**
89 89
 	 * Exception handler.
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @param \Throwable $ex
92 92
 	 * @protected
93 93
 	 */
94
-	public function handleException( \Throwable $ex ) {
94
+	public function handleException ( \Throwable $ex ) {
95 95
 		$this->getLogger()->error( "$ex" );
96 96
 	}
97 97
 
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 * @throws \ErrorException
106 106
 	 * @protected
107 107
 	 */
108
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
108
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
109 109
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
110 110
 	}
111 111
 
112 112
 	/**
113 113
 	 * @return TaskDataProvider
114 114
 	 */
115
-	protected function getDataProvider() : TaskDataProvider {
115
+	protected function getDataProvider () : TaskDataProvider {
116 116
 		return $this->dataProvider;
117 117
 	}
118 118
 }
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
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param Page $logPage
27 27
 	 * @param string $minlevel
28 28
 	 */
29
-	public function __construct( Page $logPage, $minlevel = LogLevel::INFO ) {
29
+	public function __construct ( Page $logPage, $minlevel = LogLevel::INFO ) {
30 30
 		$this->logPage = $logPage;
31 31
 		$this->minLevel = $this->levelToInt( $minlevel );
32 32
 	}
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
35 35
 	 * @inheritDoc
36 36
 	 * @suppress PhanUnusedPublicMethodParameter
37 37
 	 */
38
-	public function log( $level, $message, array $context = [] ) {
38
+	public function log ( $level, $message, array $context = [ ] ) {
39 39
 		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
40
-			$this->buffer[] = $this->getFormattedMessage( $level, $message );
40
+			$this->buffer[ ] = $this->getFormattedMessage( $level, $message );
41 41
 		}
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * Actually writes data to the wiki
46 46
 	 */
47
-	public function doOutput() {
47
+	public function doOutput () {
48 48
 		if ( $this->buffer ) {
49 49
 			$this->logPage->edit( [
50 50
 				// @todo Print a line à la Bot.php
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	/**
58 58
 	 * @todo Can we move this?
59 59
 	 */
60
-	public function __destruct() {
60
+	public function __destruct () {
61 61
 		$this->doOutput();
62 62
 	}
63 63
 }
Please login to merge, or discard this patch.
run.php 1 patch
Spacing   +5 added lines, -5 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
  * Entry point for the bot, called by CLI
4 4
  */
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 /* URL (for debugging purpose) */
41 41
 $urlParam = getopt( '', [ 'force-url:' ] );
42
-$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php';
42
+$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php';
43 43
 
44 44
 define( 'DEFAULT_URL', $url );
45 45
 define( 'META_URL', 'https://meta.wikimedia.org/w/api.php' );
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 /* START */
77 77
 
78 78
 $errParam = getopt( '', [ 'error-title::' ] );
79
-$errTitle = $errParam['error-title'] ?? null;
79
+$errTitle = $errParam[ 'error-title' ] ?? null;
80 80
 
81 81
 $simpleLogger = new \BotRiconferme\Logger\SimpleLogger();
82 82
 // @fixme
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 
106 106
 if ( count( $taskOpts ) === 2 ) {
107 107
 	throw new InvalidArgumentException( 'Cannot specify both task and subtask.' );
108
-} elseif ( isset( $taskOpts['task'] ) ) {
108
+} elseif ( isset( $taskOpts[ 'task' ] ) ) {
109 109
 	$bot->runTask( $taskOpts[ 'task' ] );
110
-} elseif ( isset( $taskOpts['subtask'] ) ) {
110
+} elseif ( isset( $taskOpts[ 'subtask' ] ) ) {
111 111
 	$bot->runSubtask( $taskOpts[ 'subtask' ] );
112 112
 } else {
113 113
 	$bot->runAll();
Please login to merge, or discard this patch.