@@ -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 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param LoggerInterface $logger |
29 | 29 | * @param string $domain The URL of the wiki, if different from default |
30 | 30 | */ |
31 | - public function __construct( LoggerInterface $logger, string $domain = DEFAULT_URL ) { |
|
31 | + public function __construct ( LoggerInterface $logger, string $domain = DEFAULT_URL ) { |
|
32 | 32 | $this->logger = $logger; |
33 | 33 | $this->setDomain( $domain ); |
34 | 34 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string $domain |
38 | 38 | * @return Wiki |
39 | 39 | */ |
40 | - public function cloneWithDomain( string $domain ) { |
|
40 | + public function cloneWithDomain ( string $domain ) { |
|
41 | 41 | $ret = clone $this; |
42 | 42 | $ret->setDomain( $domain ); |
43 | 43 | return $ret; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * @param string $domain |
48 | 48 | */ |
49 | - public function setDomain( string $domain ) { |
|
49 | + public function setDomain ( string $domain ) { |
|
50 | 50 | $this->domain = $domain; |
51 | 51 | } |
52 | 52 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @throws MissingPageException |
60 | 60 | * @throws MissingSectionException |
61 | 61 | */ |
62 | - public function getPageContent( string $title, int $section = null ) : string { |
|
62 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
63 | 63 | $msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' ); |
64 | 64 | $this->logger->debug( $msg ); |
65 | 65 | $params = [ |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ]; |
72 | 72 | |
73 | 73 | if ( $section !== null ) { |
74 | - $params['rvsection'] = $section; |
|
74 | + $params[ 'rvsection' ] = $section; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | throw new MissingPageException( $title ); |
82 | 82 | } |
83 | 83 | |
84 | - $mainSlot = $page->revisions[0]->slots->main; |
|
84 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
85 | 85 | |
86 | 86 | // @phan-suppress-next-line PhanImpossibleTypeComparison $section can be null |
87 | 87 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param array $params |
97 | 97 | * @throws EditException |
98 | 98 | */ |
99 | - public function editPage( array $params ) { |
|
99 | + public function editPage ( array $params ) { |
|
100 | 100 | $this->login(); |
101 | 101 | |
102 | 102 | $params = [ |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | ] + $params; |
106 | 106 | |
107 | 107 | if ( Config::getInstance()->get( 'bot-edits' ) ) { |
108 | - $params['bot'] = 1; |
|
108 | + $params[ 'bot' ] = 1; |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $res = RequestBase::newFromParams( $params ) |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
127 | 127 | * @throws LoginException |
128 | 128 | */ |
129 | - public function login() { |
|
129 | + public function login () { |
|
130 | 130 | if ( self::$loggedIn ) { |
131 | 131 | return; |
132 | 132 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | self::$loggedIn = true; |
155 | 155 | // Clear tokens cache |
156 | - $this->tokens = []; |
|
156 | + $this->tokens = [ ]; |
|
157 | 157 | $this->logger->info( 'Login succeeded' ); |
158 | 158 | } |
159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param string $type |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function getToken( string $type ) : string { |
|
166 | + public function getToken ( string $type ) : string { |
|
167 | 167 | if ( !isset( $this->tokens[ $type ] ) ) { |
168 | 168 | $params = [ |
169 | 169 | 'action' => 'query', |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param string $title |
187 | 187 | * @return int |
188 | 188 | */ |
189 | - public function getPageCreationTS( string $title ) : int { |
|
189 | + public function getPageCreationTS ( string $title ) : int { |
|
190 | 190 | $params = [ |
191 | 191 | 'action' => 'query', |
192 | 192 | 'prop' => 'revisions', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
201 | 201 | $data = $res->query->pages; |
202 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
202 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param string $title |
209 | 209 | * @param string $reason |
210 | 210 | */ |
211 | - public function protectPage( string $title, string $reason ) { |
|
211 | + public function protectPage ( string $title, string $reason ) { |
|
212 | 212 | $this->logger->info( "Protecting page $title" ); |
213 | 213 | $this->login(); |
214 | 214 |