@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Task; |
4 | 4 | |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @return string[] |
16 | 16 | */ |
17 | - abstract protected function getSubtasksMap() : array; |
|
17 | + abstract protected function getSubtasksMap () : array; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @param string $subtask Defined in self::SUBTASKS_MAP |
21 | 21 | * @return TaskResult |
22 | 22 | */ |
23 | - protected function runSubtask( string $subtask ) : TaskResult { |
|
23 | + protected function runSubtask ( string $subtask ) : TaskResult { |
|
24 | 24 | $map = $this->getSubtasksMap(); |
25 | 25 | if ( !isset( $map[ $subtask ] ) ) { |
26 | 26 | throw new \InvalidArgumentException( "'$subtask' is not a valid task." ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @inheritDoc |
35 | 35 | */ |
36 | - final public function getOperationName(): string { |
|
36 | + final public function getOperationName (): string { |
|
37 | 37 | return 'task'; |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $class |
44 | 44 | * @return Subtask |
45 | 45 | */ |
46 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
46 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
47 | 47 | /** @var Subtask $ret */ |
48 | 48 | $ret = new $class( |
49 | 49 | $this->getLogger(), |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Task; |
4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | abstract class TaskBase extends ContextSource { |
16 | 16 | /** @var string[] */ |
17 | - protected $errors = []; |
|
17 | + protected $errors = [ ]; |
|
18 | 18 | /** @var TaskDataProvider */ |
19 | 19 | protected $dataProvider; |
20 | 20 | |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param TaskDataProvider $dataProvider |
27 | 27 | * @param MessageProvider $mp |
28 | 28 | */ |
29 | - final public function __construct( |
|
29 | + final public function __construct ( |
|
30 | 30 | LoggerInterface $logger, |
31 | 31 | Wiki $wiki, |
32 | 32 | TaskDataProvider $dataProvider, |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return TaskResult |
43 | 43 | */ |
44 | - final public function run() : TaskResult { |
|
44 | + final public function run () : TaskResult { |
|
45 | 45 | $class = ( new \ReflectionClass( $this ) )->getShortName(); |
46 | 46 | $opName = $this->getOperationName(); |
47 | 47 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -72,19 +72,19 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @return int One of the STATUS_* constants |
74 | 74 | */ |
75 | - abstract protected function runInternal() : int; |
|
75 | + abstract protected function runInternal () : int; |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * How this operation should be called in logs |
79 | 79 | * |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - abstract public function getOperationName() : string; |
|
82 | + abstract public function getOperationName () : string; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @return TaskDataProvider |
86 | 86 | */ |
87 | - protected function getDataProvider() : TaskDataProvider { |
|
87 | + protected function getDataProvider () : TaskDataProvider { |
|
88 | 88 | return $this->dataProvider; |
89 | 89 | } |
90 | 90 | } |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Exception; |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Exception; |
4 | 4 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Exception; |
4 | 4 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types = 1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme; |
4 | 4 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param Wiki $wiki |
21 | 21 | * @param string $msgTitle |
22 | 22 | */ |
23 | - public function __construct( Wiki $wiki, string $msgTitle ) { |
|
23 | + public function __construct ( Wiki $wiki, string $msgTitle ) { |
|
24 | 24 | $this->wiki = $wiki; |
25 | 25 | $this->msgTitle = $msgTitle; |
26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @throws MessagesPageDoesNotExistException |
30 | 30 | */ |
31 | - private function grabWikiMessages() : void { |
|
31 | + private function grabWikiMessages () : void { |
|
32 | 32 | if ( self::$messages !== null ) { |
33 | 33 | return; |
34 | 34 | } |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @return Message |
46 | 46 | * @throws MessageNotFoundException |
47 | 47 | */ |
48 | - public function getMessage( string $key ) : Message { |
|
48 | + public function getMessage ( string $key ) : Message { |
|
49 | 49 | $this->grabWikiMessages(); |
50 | 50 | if ( !isset( self::$messages[ $key ] ) ) { |
51 | 51 | throw new MessageNotFoundException( "Message '$key' does not exist." ); |
52 | 52 | } |
53 | 53 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
54 | - return new Message( self::$messages[$key] ); |
|
54 | + return new Message( self::$messages[ $key ] ); |
|
55 | 55 | } |
56 | 56 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Wiki; |
4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param string $username |
16 | 16 | * @param string $password |
17 | 17 | */ |
18 | - public function __construct( string $username, string $password ) { |
|
18 | + public function __construct ( string $username, string $password ) { |
|
19 | 19 | $this->username = $username; |
20 | 20 | $this->password = $password; |
21 | 21 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @return string |
25 | 25 | */ |
26 | - public function getUsername() : string { |
|
26 | + public function getUsername () : string { |
|
27 | 27 | return $this->username; |
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public function getPassword() : string { |
|
33 | + public function getPassword () : string { |
|
34 | 34 | return $this->password; |
35 | 35 | } |
36 | 36 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Wiki; |
4 | 4 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param LoggerInterface $logger |
33 | 33 | * @param string $domain The URL of the wiki, if different from default |
34 | 34 | */ |
35 | - public function __construct( LoggerInterface $logger, string $domain = DEFAULT_URL ) { |
|
35 | + public function __construct ( LoggerInterface $logger, string $domain = DEFAULT_URL ) { |
|
36 | 36 | $this->logger = $logger; |
37 | 37 | $this->domain = $domain; |
38 | 38 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @param LoginInfo $li |
42 | 42 | */ |
43 | - public function setLoginInfo( LoginInfo $li ) : void { |
|
43 | + public function setLoginInfo ( LoginInfo $li ) : void { |
|
44 | 44 | // FIXME This should be in the constructor, and it should not depend on config |
45 | 45 | $this->loginInfo = $li; |
46 | 46 | } |
@@ -48,14 +48,14 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @return LoginInfo |
50 | 50 | */ |
51 | - public function getLoginInfo() : LoginInfo { |
|
51 | + public function getLoginInfo () : LoginInfo { |
|
52 | 52 | return $this->loginInfo; |
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @param bool $bot |
57 | 57 | */ |
58 | - public function setEditsAsBot( bool $bot ) : void { |
|
58 | + public function setEditsAsBot ( bool $bot ) : void { |
|
59 | 59 | // FIXME same as setLoginInfo |
60 | 60 | $this->botEdits = $bot; |
61 | 61 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @return bool |
65 | 65 | */ |
66 | - public function getEditsAsBot() : bool { |
|
66 | + public function getEditsAsBot () : bool { |
|
67 | 67 | return $this->botEdits; |
68 | 68 | } |
69 | 69 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @throws MissingPageException |
77 | 77 | * @throws MissingSectionException |
78 | 78 | */ |
79 | - public function getPageContent( string $title, int $section = null ) : string { |
|
79 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
80 | 80 | $msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' ); |
81 | 81 | $this->logger->debug( $msg ); |
82 | 82 | $params = [ |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ]; |
89 | 89 | |
90 | 90 | if ( $section !== null ) { |
91 | - $params['rvsection'] = $section; |
|
91 | + $params[ 'rvsection' ] = $section; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | $req = $this->buildRequest( $params ); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | throw new MissingPageException( $title ); |
99 | 99 | } |
100 | 100 | |
101 | - $mainSlot = $page->revisions[0]->slots->main; |
|
101 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
102 | 102 | |
103 | 103 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
104 | 104 | throw new MissingSectionException( $title, $section ); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param array $params |
113 | 113 | * @throws EditException |
114 | 114 | */ |
115 | - public function editPage( array $params ) : void { |
|
115 | + public function editPage ( array $params ) : void { |
|
116 | 116 | $this->login(); |
117 | 117 | |
118 | 118 | $params = [ |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | ] + $params; |
122 | 122 | |
123 | 123 | if ( $this->getEditsAsBot() ) { |
124 | - $params['bot'] = 1; |
|
124 | + $params[ 'bot' ] = 1; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $res = $this->buildRequest( $params )->setPost()->execute(); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
140 | 140 | * @throws LoginException |
141 | 141 | */ |
142 | - public function login() : void { |
|
142 | + public function login () : void { |
|
143 | 143 | if ( $this->loginInfo === null ) { |
144 | 144 | throw new CannotLoginException( 'Missing login data' ); |
145 | 145 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | self::$loggedIn = true; |
171 | 171 | // Clear tokens cache |
172 | - $this->tokens = []; |
|
172 | + $this->tokens = [ ]; |
|
173 | 173 | $this->logger->info( 'Login succeeded' ); |
174 | 174 | } |
175 | 175 | |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param string $type |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - public function getToken( string $type ) : string { |
|
182 | + public function getToken ( string $type ) : string { |
|
183 | 183 | if ( !isset( $this->tokens[ $type ] ) ) { |
184 | 184 | $params = [ |
185 | 185 | 'action' => 'query', |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $title |
203 | 203 | * @return int |
204 | 204 | */ |
205 | - public function getPageCreationTS( string $title ) : int { |
|
205 | + public function getPageCreationTS ( string $title ) : int { |
|
206 | 206 | $params = [ |
207 | 207 | 'action' => 'query', |
208 | 208 | 'prop' => 'revisions', |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | $res = $this->buildRequest( $params )->execute(); |
217 | 217 | $data = $res->query->pages; |
218 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
218 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param string $title |
225 | 225 | * @param string $reason |
226 | 226 | */ |
227 | - public function protectPage( string $title, string $reason ) : void { |
|
227 | + public function protectPage ( string $title, string $reason ) : void { |
|
228 | 228 | $this->logger->info( "Protecting page $title" ); |
229 | 229 | $this->login(); |
230 | 230 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @param array $params |
246 | 246 | * @return RequestBase |
247 | 247 | */ |
248 | - private function buildRequest( array $params ) : RequestBase { |
|
248 | + private function buildRequest ( array $params ) : RequestBase { |
|
249 | 249 | return RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
250 | 250 | } |
251 | 251 | } |
@@ -1,4 +1,4 @@ discard block |
||
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 |
||
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; |
@@ -39,16 +39,16 @@ discard block |
||
39 | 39 | * @inheritDoc |
40 | 40 | * @suppress PhanUnusedPublicMethodParameter |
41 | 41 | */ |
42 | - public function log( $level, $message, array $context = [] ) :void { |
|
42 | + public function log ( $level, $message, array $context = [ ] ) :void { |
|
43 | 43 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
44 | - $this->buffer[] = $this->getFormattedMessage( $level, $message ); |
|
44 | + $this->buffer[ ] = $this->getFormattedMessage( $level, $message ); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | 49 | * @return string |
50 | 50 | */ |
51 | - protected function getOutput() : string { |
|
51 | + protected function getOutput () : string { |
|
52 | 52 | $line = str_repeat( '-', 80 ); |
53 | 53 | return "\n\n" . implode( "\n", $this->buffer ) . "\n$line\n\n"; |
54 | 54 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * @inheritDoc |
58 | 58 | */ |
59 | - public function flush() : void { |
|
59 | + public function flush () : void { |
|
60 | 60 | if ( $this->buffer ) { |
61 | 61 | $this->logPage->edit( [ |
62 | 62 | 'appendtext' => $this->getOutput(), |