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