@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @param string $minlevel |
| 17 | 17 | */ |
| 18 | - public function __construct( $minlevel = LogLevel::INFO ) { |
|
| 18 | + public function __construct ( $minlevel = LogLevel::INFO ) { |
|
| 19 | 19 | $this->minLevel = $this->levelToInt( $minlevel ); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param string $level |
| 26 | 26 | * @return int |
| 27 | 27 | */ |
| 28 | - private function levelToInt( string $level ) : int { |
|
| 28 | + private function levelToInt ( string $level ) : int { |
|
| 29 | 29 | // Order matters |
| 30 | 30 | $mapping = [ |
| 31 | 31 | LogLevel::DEBUG, |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @inheritDoc |
| 45 | 45 | * @suppress PhanUnusedPublicMethodParameter |
| 46 | 46 | */ |
| 47 | - public function log( $level, $message, array $context = [] ) { |
|
| 47 | + public function log ( $level, $message, array $context = [ ] ) { |
|
| 48 | 48 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
| 49 | 49 | printf( "%s [%s] - %s\n", date( 'd M H:i:s' ), $level, $message ); |
| 50 | 50 | } |
@@ -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 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * @param string $domain |
| 38 | 38 | */ |
| 39 | - public function setDomain( string $domain ) { |
|
| 39 | + public function setDomain ( string $domain ) { |
|
| 40 | 40 | $this->domain = $domain; |
| 41 | 41 | } |
| 42 | 42 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @throws MissingPageException |
| 50 | 50 | * @throws MissingSectionException |
| 51 | 51 | */ |
| 52 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 52 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 53 | 53 | $msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' ); |
| 54 | 54 | $this->logger->debug( $msg ); |
| 55 | 55 | $params = [ |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | ]; |
| 62 | 62 | |
| 63 | 63 | if ( $section !== null ) { |
| 64 | - $params['rvsection'] = $section; |
|
| 64 | + $params[ 'rvsection' ] = $section; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | throw new MissingPageException( $title ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 74 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 75 | 75 | |
| 76 | 76 | // @phan-suppress-next-line PhanImpossibleTypeComparison $section can be null |
| 77 | 77 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @param array $params |
| 87 | 87 | * @throws EditException |
| 88 | 88 | */ |
| 89 | - public function editPage( array $params ) { |
|
| 89 | + public function editPage ( array $params ) { |
|
| 90 | 90 | $this->login(); |
| 91 | 91 | |
| 92 | 92 | $params = [ |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | ] + $params; |
| 96 | 96 | |
| 97 | 97 | if ( Config::getInstance()->get( 'bot-edits' ) ) { |
| 98 | - $params['bot'] = 1; |
|
| 98 | + $params[ 'bot' ] = 1; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $res = RequestBase::newFromParams( $params ) |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 117 | 117 | * @throws LoginException |
| 118 | 118 | */ |
| 119 | - public function login() { |
|
| 119 | + public function login () { |
|
| 120 | 120 | if ( self::$loggedIn ) { |
| 121 | 121 | return; |
| 122 | 122 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | |
| 144 | 144 | self::$loggedIn = true; |
| 145 | 145 | // Clear tokens cache |
| 146 | - $this->tokens = []; |
|
| 146 | + $this->tokens = [ ]; |
|
| 147 | 147 | $this->logger->info( 'Login succeeded' ); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $type |
| 154 | 154 | * @return string |
| 155 | 155 | */ |
| 156 | - public function getToken( string $type ) : string { |
|
| 156 | + public function getToken ( string $type ) : string { |
|
| 157 | 157 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 158 | 158 | $params = [ |
| 159 | 159 | 'action' => 'query', |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | * @param string $title |
| 177 | 177 | * @return int |
| 178 | 178 | */ |
| 179 | - public function getPageCreationTS( string $title ) : int { |
|
| 179 | + public function getPageCreationTS ( string $title ) : int { |
|
| 180 | 180 | $params = [ |
| 181 | 181 | 'action' => 'query', |
| 182 | 182 | 'prop' => 'revisions', |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | |
| 190 | 190 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
| 191 | 191 | $data = $res->query->pages; |
| 192 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 192 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @param string $title |
| 199 | 199 | * @param string $reason |
| 200 | 200 | */ |
| 201 | - public function protectPage( string $title, string $reason ) { |
|
| 201 | + public function protectPage ( string $title, string $reason ) { |
|
| 202 | 202 | $this->logger->info( "Protecting page $title" ); |
| 203 | 203 | $this->login(); |
| 204 | 204 | |