@@ -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 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @param string $domain The URL of the wiki, if different from default |
29 | 29 | */ |
30 | - public function __construct( string $domain = DEFAULT_URL ) { |
|
30 | + public function __construct ( string $domain = DEFAULT_URL ) { |
|
31 | 31 | $this->logger = new Logger; |
32 | 32 | $this->domain = $domain; |
33 | 33 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @throws MissingPageException |
42 | 42 | * @throws MissingSectionException |
43 | 43 | */ |
44 | - public function getPageContent( string $title, int $section = null ) : string { |
|
44 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
45 | 45 | $msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' ); |
46 | 46 | $this->logger->debug( $msg ); |
47 | 47 | $params = [ |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | ]; |
54 | 54 | |
55 | 55 | if ( $section !== null ) { |
56 | - $params['rvsection'] = $section; |
|
56 | + $params[ 'rvsection' ] = $section; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | throw new MissingPageException( $title ); |
64 | 64 | } |
65 | 65 | |
66 | - $mainSlot = $page->revisions[0]->slots->main; |
|
66 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
67 | 67 | |
68 | 68 | // @phan-suppress-next-line PhanImpossibleTypeComparison $section can be null |
69 | 69 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param array $params |
79 | 79 | * @throws EditException |
80 | 80 | */ |
81 | - public function editPage( array $params ) { |
|
81 | + public function editPage ( array $params ) { |
|
82 | 82 | $this->login(); |
83 | 83 | |
84 | 84 | $params = [ |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ] + $params; |
88 | 88 | |
89 | 89 | if ( Config::getInstance()->get( 'bot-edits' ) ) { |
90 | - $params['bot'] = 1; |
|
90 | + $params[ 'bot' ] = 1; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | $res = RequestBase::newFromParams( $params ) |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
109 | 109 | * @throws LoginException |
110 | 110 | */ |
111 | - public function login() { |
|
111 | + public function login () { |
|
112 | 112 | if ( self::$loggedIn ) { |
113 | 113 | return; |
114 | 114 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | self::$loggedIn = true; |
137 | 137 | // Clear tokens cache |
138 | - $this->tokens = []; |
|
138 | + $this->tokens = [ ]; |
|
139 | 139 | $this->logger->info( 'Login succeeded' ); |
140 | 140 | } |
141 | 141 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @param string $type |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function getToken( string $type ) : string { |
|
148 | + public function getToken ( string $type ) : string { |
|
149 | 149 | if ( !isset( $this->tokens[ $type ] ) ) { |
150 | 150 | $params = [ |
151 | 151 | 'action' => 'query', |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @param string $title |
169 | 169 | * @return int |
170 | 170 | */ |
171 | - public function getPageCreationTS( string $title ) : int { |
|
171 | + public function getPageCreationTS ( string $title ) : int { |
|
172 | 172 | $params = [ |
173 | 173 | 'action' => 'query', |
174 | 174 | 'prop' => 'revisions', |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
183 | 183 | $data = $res->query->pages; |
184 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
184 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $title |
191 | 191 | * @param string $reason |
192 | 192 | */ |
193 | - public function protectPage( string $title, string $reason ) { |
|
193 | + public function protectPage ( string $title, string $reason ) { |
|
194 | 194 | $this->logger->info( "Protecting page $title" ); |
195 | 195 | $this->login(); |
196 | 196 |