Passed
Push — master ( 8368ac...8fed13 )
by Daimona
01:55
created
src/TaskManager.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param MessageProvider $mp
73 73
 	 * @param PageBotList $pbl
74 74
 	 */
75
-	public function __construct(
75
+	public function __construct (
76 76
 		LoggerInterface $logger,
77 77
 		WikiGroup $wikiGroup,
78 78
 		MessageProvider $mp,
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param string[] $tasks Only used in MODE_TASK and MODE_SUBTASK
98 98
 	 * @return TaskResult
99 99
 	 */
100
-	public function run( string $mode, array $tasks = [] ): TaskResult {
100
+	public function run ( string $mode, array $tasks = [ ] ): TaskResult {
101 101
 		if ( $mode === self::MODE_COMPLETE ) {
102 102
 			return $this->runTasks( self::FULL_RUN_ORDERED );
103 103
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @param string[] $tasks
114 114
 	 * @return TaskResult
115 115
 	 */
116
-	private function runTasks( array $tasks ): TaskResult {
116
+	private function runTasks ( array $tasks ): TaskResult {
117 117
 		$res = new TaskResult( TaskResult::STATUS_GOOD );
118 118
 		do {
119 119
 			$res->merge( $this->runTask( current( $tasks ) ) );
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $name
129 129
 	 * @return TaskResult
130 130
 	 */
131
-	protected function runTask( string $name ): TaskResult {
131
+	protected function runTask ( string $name ): TaskResult {
132 132
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
133 133
 			throw new InvalidArgumentException( "'$name' is not a valid task." );
134 134
 		}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param string[] $subtasks
143 143
 	 * @return TaskResult
144 144
 	 */
145
-	private function runSubtasks( array $subtasks ): TaskResult {
145
+	private function runSubtasks ( array $subtasks ): TaskResult {
146 146
 		$res = new TaskResult( TaskResult::STATUS_GOOD );
147 147
 		do {
148 148
 			$res->merge( $this->runSubtask( current( $subtasks ) ) );
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @param string $name
158 158
 	 * @return TaskResult
159 159
 	 */
160
-	protected function runSubtask( string $name ): TaskResult {
160
+	protected function runSubtask ( string $name ): TaskResult {
161 161
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
162 162
 			throw new InvalidArgumentException( "'$name' is not a valid subtask." );
163 163
 		}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @param string $name
173 173
 	 * @return Task
174 174
 	 */
175
-	private function getTaskInstance( string $name ): Task {
175
+	private function getTaskInstance ( string $name ): Task {
176 176
 		$class = self::TASKS_MAP[ $name ];
177 177
 		return new $class(
178 178
 			$this->logger,
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param string $class
190 190
 	 * @return Subtask
191 191
 	 */
192
-	private function getSubtaskInstance( string $class ): Subtask {
192
+	private function getSubtaskInstance ( string $class ): Subtask {
193 193
 		return new $class(
194 194
 			$this->logger,
195 195
 			$this->wikiGroup,
Please login to merge, or discard this patch.
src/MessageProvider.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
 namespace BotRiconferme;
4 4
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param Wiki $wiki
22 22
 	 * @param string $msgTitle
23 23
 	 */
24
-	public function __construct( Wiki $wiki, string $msgTitle ) {
24
+	public function __construct ( Wiki $wiki, string $msgTitle ) {
25 25
 		$this->wiki = $wiki;
26 26
 		$this->msgTitle = $msgTitle;
27 27
 	}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @throws MessagesPageDoesNotExistException
31 31
 	 */
32
-	private function grabWikiMessages(): void {
32
+	private function grabWikiMessages (): void {
33 33
 		if ( self::$messages !== null ) {
34 34
 			return;
35 35
 		}
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 	 * @return Message
47 47
 	 * @throws MessageNotFoundException
48 48
 	 */
49
-	public function getMessage( string $key ): Message {
49
+	public function getMessage ( string $key ): Message {
50 50
 		$this->grabWikiMessages();
51 51
 		if ( !isset( self::$messages[ $key ] ) ) {
52 52
 			throw new MessageNotFoundException( "Message '$key' does not exist." );
53 53
 		}
54 54
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
55
-		return new Message( self::$messages[$key] );
55
+		return new Message( self::$messages[ $key ] );
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.
src/TaskHelper/TaskDataProvider.php 1 patch
Spacing   +15 added lines, -15 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\TaskHelper;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/** @var User[]|null */
16 16
 	private $processUsers;
17 17
 	/** @var PageRiconferma[] */
18
-	private $createdPages = [];
18
+	private $createdPages = [ ];
19 19
 	/** @var PageRiconferma[]|null */
20 20
 	private $openPages;
21 21
 	/** @var PageRiconferma[]|null */
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return User[]
28 28
 	 */
29
-	public function getUsersToProcess(): array {
29
+	public function getUsersToProcess (): array {
30 30
 		if ( $this->processUsers === null ) {
31
-			$this->processUsers = [];
31
+			$this->processUsers = [ ];
32 32
 			foreach ( $this->getBotList()->getAdminsList() as $name => $userInfo ) {
33 33
 				if ( $this->shouldAddUser( $userInfo ) ) {
34 34
 					$this->processUsers[ $name ] = new User( $userInfo, $this->getWiki() );
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param UserInfo $ui
46 46
 	 * @return bool
47 47
 	 */
48
-	private function shouldAddUser( UserInfo $ui ): bool {
48
+	private function shouldAddUser ( UserInfo $ui ): bool {
49 49
 		$timestamp = $this->getBotList()->getOverrideTimestamp( $ui );
50 50
 		$override = $timestamp !== null;
51 51
 
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return PageRiconferma[]
65 65
 	 */
66
-	public function getOpenPages(): array {
66
+	public function getOpenPages (): array {
67 67
 		if ( $this->openPages === null ) {
68
-			$this->openPages = [];
68
+			$this->openPages = [ ];
69 69
 			$mainTitle = $this->getOpt( 'main-page-title' );
70 70
 			$params = [
71 71
 				'action' => 'query',
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			$pages = $this->getRequestFactory()->newFromParams( $params )->executeAsQuery();
80 80
 			foreach ( $pages->current()->templates as $page ) {
81 81
 				if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) {
82
-					$this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() );
82
+					$this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() );
83 83
 				}
84 84
 			}
85 85
 		}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return PageRiconferma[]
94 94
 	 */
95
-	public function getPagesToClose(): array {
95
+	public function getPagesToClose (): array {
96 96
 		if ( $this->pagesToClose === null ) {
97
-			$this->pagesToClose = [];
97
+			$this->pagesToClose = [ ];
98 98
 			foreach ( $this->getOpenPages() as $page ) {
99 99
 				if ( time() > $page->getEndTimestamp() ) {
100
-					$this->pagesToClose[] = $page;
100
+					$this->pagesToClose[ ] = $page;
101 101
 				}
102 102
 			}
103 103
 		}
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @param string $name
111 111
 	 */
112
-	public function removeUser( string $name ): void {
112
+	public function removeUser ( string $name ): void {
113 113
 		unset( $this->processUsers[ $name ] );
114 114
 	}
115 115
 
116 116
 	/**
117 117
 	 * @return PageRiconferma[]
118 118
 	 */
119
-	public function getCreatedPages(): array {
119
+	public function getCreatedPages (): array {
120 120
 		return $this->createdPages;
121 121
 	}
122 122
 
123 123
 	/**
124 124
 	 * @param PageRiconferma $page
125 125
 	 */
126
-	public function addCreatedPage( PageRiconferma $page ): void {
127
-		$this->createdPages[] = $page;
126
+	public function addCreatedPage ( PageRiconferma $page ): void {
127
+		$this->createdPages[ ] = $page;
128 128
 	}
129 129
 }
Please login to merge, or discard this patch.
src/TaskHelper/TaskResult.php 1 patch
Spacing   +9 added lines, -9 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\TaskHelper;
4 4
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param int $status One of the Task::STATUS_* constants
22 22
 	 * @param string[] $errors
23 23
 	 */
24
-	public function __construct( int $status, array $errors = [] ) {
24
+	public function __construct ( int $status, array $errors = [ ] ) {
25 25
 		$this->status = $status;
26 26
 		$this->errors = $errors;
27 27
 	}
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @return int
31 31
 	 */
32
-	public function getStatus(): int {
32
+	public function getStatus (): int {
33 33
 		return $this->status;
34 34
 	}
35 35
 
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 	 * @return string[]
38 38
 	 * @suppress PhanUnreferencedPublicMethod
39 39
 	 */
40
-	public function getErrors(): array {
40
+	public function getErrors (): array {
41 41
 		return $this->errors;
42 42
 	}
43 43
 
44 44
 	/**
45 45
 	 * @param TaskResult $that
46 46
 	 */
47
-	public function merge( TaskResult $that ): void {
47
+	public function merge ( TaskResult $that ): void {
48 48
 		$this->status |= $that->status;
49 49
 		$this->errors = array_merge( $this->errors, $that->errors );
50 50
 	}
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @return string
54 54
 	 */
55
-	public function __toString(): string {
55
+	public function __toString (): string {
56 56
 		if ( $this->isOK() ) {
57 57
 			$stat = 'OK';
58 58
 			$errs = "\tNo errors.";
59 59
 		} else {
60 60
 			$stat = 'ERROR';
61
-			$formattedErrs = [];
61
+			$formattedErrs = [ ];
62 62
 			foreach ( $this->errors as $err ) {
63
-				$formattedErrs[] = "\t - $err";
63
+				$formattedErrs[ ] = "\t - $err";
64 64
 			}
65 65
 			$errs = implode( "\n", $formattedErrs );
66 66
 		}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return bool
74 74
 	 */
75
-	public function isOK(): bool {
75
+	public function isOK (): bool {
76 76
 		return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD;
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
src/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
 
@@ -11,12 +11,12 @@  discard block
 block discarded – undo
11 11
 	/** @var self */
12 12
 	private static $instance;
13 13
 	/** @var string[] */
14
-	private $opts = [];
14
+	private $opts = [ ];
15 15
 
16 16
 	/**
17 17
 	 * Use self::init() and self::getInstance()
18 18
 	 */
19
-	private function __construct() {
19
+	private function __construct () {
20 20
 	}
21 21
 
22 22
 	/**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param string[] $confValues
26 26
 	 * @throws ConfigException
27 27
 	 */
28
-	public static function init( array $confValues ): void {
28
+	public static function init ( array $confValues ): void {
29 29
 		if ( self::$instance ) {
30 30
 			throw new ConfigException( 'Config was already initialized' );
31 31
 		}
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param string $key
45 45
 	 * @param mixed $value
46 46
 	 */
47
-	protected function set( string $key, $value ): void {
47
+	protected function set ( string $key, $value ): void {
48 48
 		$this->opts[ $key ] = $value;
49 49
 	}
50 50
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @return self
55 55
 	 * @throws ConfigException
56 56
 	 */
57
-	public static function getInstance(): self {
57
+	public static function getInstance (): self {
58 58
 		if ( !self::$instance ) {
59 59
 			throw new ConfigException( 'Config not yet initialized' );
60 60
 		}
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return mixed
69 69
 	 * @throws ConfigException
70 70
 	 */
71
-	public function get( string $opt ) {
71
+	public function get ( string $opt ) {
72 72
 		if ( !isset( $this->opts[ $opt ] ) ) {
73 73
 			throw new ConfigException( "Config option '$opt' not set." );
74 74
 		}
Please login to merge, or discard this patch.
src/Logger/IFlushingAwareLogger.php 1 patch
Spacing   +2 added lines, -2 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
 
@@ -11,5 +11,5 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * Flush the buffer
13 13
 	 */
14
-	public function flush(): void;
14
+	public function flush (): void;
15 15
 }
Please login to merge, or discard this patch.
src/Logger/LoggerTrait.php 1 patch
Spacing   +3 added lines, -3 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	 * @param string $level
12 12
 	 * @return int
13 13
 	 */
14
-	protected function levelToInt( string $level ): int {
14
+	protected function levelToInt ( string $level ): int {
15 15
 		// Order matters
16 16
 		$mapping = [
17 17
 			LogLevel::DEBUG,
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param string $message
32 32
 	 * @return string
33 33
 	 */
34
-	protected function getFormattedMessage( string $level, string $message ): string {
34
+	protected function getFormattedMessage ( string $level, string $message ): string {
35 35
 		return sprintf( '%s [%s] - %s', date( 'd M H:i:s' ), $level, $message );
36 36
 	}
37 37
 }
Please login to merge, or discard this patch.
src/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.
src/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.