@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Request; |
| 4 | 4 | |
@@ -29,14 +29,14 @@ discard block |
||
| 29 | 29 | /** @var string */ |
| 30 | 30 | protected $method = 'GET'; |
| 31 | 31 | /** @var string[] */ |
| 32 | - protected $newCookies = []; |
|
| 32 | + protected $newCookies = [ ]; |
|
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * Use self::newFromParams, which will provide the right class to use |
| 36 | 36 | * |
| 37 | 37 | * @param array $params |
| 38 | 38 | */ |
| 39 | - protected function __construct( array $params ) { |
|
| 39 | + protected function __construct ( array $params ) { |
|
| 40 | 40 | $this->params = [ 'format' => 'json' ] + $params; |
| 41 | 41 | $this->url = DEFAULT_URL; |
| 42 | 42 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param array $params |
| 48 | 48 | * @return self |
| 49 | 49 | */ |
| 50 | - public static function newFromParams( array $params ) : self { |
|
| 50 | + public static function newFromParams ( array $params ) : self { |
|
| 51 | 51 | if ( extension_loaded( 'curl' ) ) { |
| 52 | 52 | $ret = new CurlRequest( $params ); |
| 53 | 53 | } else { |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return self For chaining |
| 63 | 63 | */ |
| 64 | - public function setPost() : self { |
|
| 64 | + public function setPost () : self { |
|
| 65 | 65 | $this->method = 'POST'; |
| 66 | 66 | return $this; |
| 67 | 67 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param string $url |
| 73 | 73 | * @return self for chaining |
| 74 | 74 | */ |
| 75 | - public function setUrl( string $url ) : self { |
|
| 75 | + public function setUrl ( string $url ) : self { |
|
| 76 | 76 | $this->url = $url; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
@@ -82,14 +82,14 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return \stdClass |
| 84 | 84 | */ |
| 85 | - public function execute() : \stdClass { |
|
| 85 | + public function execute () : \stdClass { |
|
| 86 | 86 | $curParams = $this->params; |
| 87 | - $sets = []; |
|
| 87 | + $sets = [ ]; |
|
| 88 | 88 | do { |
| 89 | 89 | $res = $this->makeRequestInternal( $curParams ); |
| 90 | 90 | |
| 91 | 91 | $this->handleErrorAndWarnings( $res ); |
| 92 | - $sets[] = $res; |
|
| 92 | + $sets[ ] = $res; |
|
| 93 | 93 | |
| 94 | 94 | $finished = true; |
| 95 | 95 | if ( isset( $res->continue ) ) { |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | * @param array $params |
| 108 | 108 | * @return \stdClass |
| 109 | 109 | */ |
| 110 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
| 110 | + private function makeRequestInternal ( array $params ) : \stdClass { |
|
| 111 | 111 | if ( $this->method === 'POST' ) { |
| 112 | - $params['maxlag'] = self::MAXLAG; |
|
| 112 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
| 113 | 113 | } |
| 114 | 114 | $params = http_build_query( $params ); |
| 115 | 115 | |
@@ -125,17 +125,17 @@ discard block |
||
| 125 | 125 | * @param string $params |
| 126 | 126 | * @return string |
| 127 | 127 | */ |
| 128 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
| 128 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
| 129 | 129 | |
| 130 | 130 | /** |
| 131 | 131 | * After a request, set cookies for the next ones |
| 132 | 132 | * |
| 133 | 133 | * @param array $cookies |
| 134 | 134 | */ |
| 135 | - protected function setCookies( array $cookies ) { |
|
| 135 | + protected function setCookies ( array $cookies ) { |
|
| 136 | 136 | foreach ( $cookies as $cookie ) { |
| 137 | 137 | $bits = explode( ';', $cookie ); |
| 138 | - list( $name, $value ) = explode( '=', $bits[0] ); |
|
| 138 | + list( $name, $value ) = explode( '=', $bits[ 0 ] ); |
|
| 139 | 139 | self::$cookiesToSet[ $name ] = $value; |
| 140 | 140 | } |
| 141 | 141 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param \stdClass $res |
| 147 | 147 | * @throws APIRequestException |
| 148 | 148 | */ |
| 149 | - protected function handleErrorAndWarnings( $res ) { |
|
| 149 | + protected function handleErrorAndWarnings ( $res ) { |
|
| 150 | 150 | if ( isset( $res->error ) ) { |
| 151 | 151 | switch ( $res->error->code ) { |
| 152 | 152 | case 'missingtitle': |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param \stdClass[] $sets |
| 173 | 173 | * @return \stdClass |
| 174 | 174 | */ |
| 175 | - private function mergeSets( array $sets ) : \stdClass { |
|
| 175 | + private function mergeSets ( array $sets ) : \stdClass { |
|
| 176 | 176 | // Use the first set as template |
| 177 | 177 | $ret = array_shift( $sets ); |
| 178 | 178 | |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param array|\stdClass $second |
| 190 | 190 | * @return array|\stdClass array |
| 191 | 191 | */ |
| 192 | - private function recursiveMerge( $first, $second ) { |
|
| 192 | + private function recursiveMerge ( $first, $second ) { |
|
| 193 | 193 | $ret = $first; |
| 194 | 194 | if ( is_array( $second ) ) { |
| 195 | 195 | $ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second; |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return array |
| 209 | 209 | */ |
| 210 | - protected function getHeaders() :array { |
|
| 210 | + protected function getHeaders () :array { |
|
| 211 | 211 | $ret = self::HEADERS; |
| 212 | 212 | if ( self::$cookiesToSet ) { |
| 213 | - $cookies = []; |
|
| 213 | + $cookies = [ ]; |
|
| 214 | 214 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
| 215 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 215 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
| 216 | 216 | } |
| 217 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 217 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 218 | 218 | } |
| 219 | 219 | return $ret; |
| 220 | 220 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param array $headers |
| 226 | 226 | * @return string |
| 227 | 227 | */ |
| 228 | - protected function buildHeadersString( array $headers ) : string { |
|
| 228 | + protected function buildHeadersString ( array $headers ) : string { |
|
| 229 | 229 | $ret = ''; |
| 230 | 230 | foreach ( $headers as $header ) { |
| 231 | 231 | $ret .= "$header\r\n"; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Request; |
| 4 | 4 | |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | /** |
| 10 | 10 | * @inheritDoc |
| 11 | 11 | */ |
| 12 | - protected function reallyMakeRequest( string $params ) : string { |
|
| 12 | + protected function reallyMakeRequest ( string $params ) : string { |
|
| 13 | 13 | $context = [ |
| 14 | 14 | 'http' => [ |
| 15 | 15 | 'method' => $this->method, |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | ]; |
| 19 | 19 | $url = $this->url; |
| 20 | 20 | if ( $this->method === 'POST' ) { |
| 21 | - $context['http']['content'] = $params; |
|
| 21 | + $context[ 'http' ][ 'content' ] = $params; |
|
| 22 | 22 | } else { |
| 23 | 23 | $url = "$url?$params"; |
| 24 | 24 | } |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | foreach ( $http_response_header as $header ) { |
| 29 | 29 | $bits = explode( ':', $header, 2 ); |
| 30 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 31 | - $this->newCookies[] = $bits[1]; |
|
| 30 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 31 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -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 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param string $title |
| 18 | 18 | * @param string $domain The site where the page lives, if different from default |
| 19 | 19 | */ |
| 20 | - public function __construct( string $title, string $domain = DEFAULT_URL ) { |
|
| 20 | + public function __construct ( string $title, string $domain = DEFAULT_URL ) { |
|
| 21 | 21 | $this->title = $title; |
| 22 | 22 | $this->controller = new WikiController( $domain ); |
| 23 | 23 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - public function getTitle() : string { |
|
| 28 | + public function getTitle () : string { |
|
| 29 | 29 | return $this->title; |
| 30 | 30 | } |
| 31 | 31 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param int|null $section A section number to retrieve the content of that section |
| 36 | 36 | * @return string |
| 37 | 37 | */ |
| 38 | - public function getContent( int $section = null ) : string { |
|
| 38 | + public function getContent ( int $section = null ) : string { |
|
| 39 | 39 | if ( $this->content === null ) { |
| 40 | 40 | $this->content = $this->controller->getPageContent( $this->title, $section ); |
| 41 | 41 | } |
@@ -47,16 +47,16 @@ discard block |
||
| 47 | 47 | * |
| 48 | 48 | * @param array $params |
| 49 | 49 | */ |
| 50 | - public function edit( array $params ) { |
|
| 50 | + public function edit ( array $params ) { |
|
| 51 | 51 | $params = [ |
| 52 | 52 | 'title' => $this->getTitle() |
| 53 | 53 | ] + $params; |
| 54 | 54 | |
| 55 | 55 | $this->controller->editPage( $params ); |
| 56 | - if ( isset( $params['text'] ) ) { |
|
| 57 | - $this->content = $params['text']; |
|
| 58 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 59 | - $this->content .= $params['appendtext']; |
|
| 56 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 57 | + $this->content = $params[ 'text' ]; |
|
| 58 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 59 | + $this->content .= $params[ 'appendtext' ]; |
|
| 60 | 60 | } else { |
| 61 | 61 | // Clear the cache anyway |
| 62 | 62 | ( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) ); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string |
| 71 | 71 | */ |
| 72 | - public function __toString() { |
|
| 72 | + public function __toString () { |
|
| 73 | 73 | return $this->getTitle(); |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -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 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @param string $domain The URL of the wiki, if different from default |
| 26 | 26 | */ |
| 27 | - public function __construct( string $domain = DEFAULT_URL ) { |
|
| 27 | + public function __construct ( string $domain = DEFAULT_URL ) { |
|
| 28 | 28 | $this->logger = new Logger; |
| 29 | 29 | $this->domain = $domain; |
| 30 | 30 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return string |
| 38 | 38 | * @throws MissingPageException |
| 39 | 39 | */ |
| 40 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 40 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 41 | 41 | $this->logger->debug( "Retrieving page $title" ); |
| 42 | 42 | $params = [ |
| 43 | 43 | 'action' => 'query', |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ]; |
| 49 | 49 | |
| 50 | 50 | if ( $section !== null ) { |
| 51 | - $params['rvsection'] = $section; |
|
| 51 | + $params[ 'rvsection' ] = $section; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | throw new MissingPageException( $title ); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - return $page->revisions[0]->slots->main->{ '*' }; |
|
| 61 | + return $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param array $params |
| 68 | 68 | * @throws EditException |
| 69 | 69 | */ |
| 70 | - public function editPage( array $params ) { |
|
| 70 | + public function editPage ( array $params ) { |
|
| 71 | 71 | $this->login(); |
| 72 | 72 | |
| 73 | 73 | $params = [ |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @return string |
| 93 | 93 | * @fixme Not the right place for this |
| 94 | 94 | */ |
| 95 | - public static function getTimeWithArticle( int $timestamp ) : string { |
|
| 95 | + public static function getTimeWithArticle ( int $timestamp ) : string { |
|
| 96 | 96 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 97 | 97 | $timeString = strftime( '%e %B alle %R', $timestamp ); |
| 98 | 98 | // Remove the left space if day has a single digit |
@@ -111,16 +111,16 @@ discard block |
||
| 111 | 111 | * @fixme Not the right place for this |
| 112 | 112 | * @todo Is there a better way? |
| 113 | 113 | */ |
| 114 | - public static function getTimestampFromLocalTime( string $timeString ) : int { |
|
| 114 | + public static function getTimestampFromLocalTime ( string $timeString ) : int { |
|
| 115 | 115 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 116 | 116 | $bits = strptime( $timeString, '%e %m %Y alle %H:%M' ); |
| 117 | 117 | $timestamp = mktime( |
| 118 | - $bits['tm_hour'], |
|
| 119 | - $bits['tm_min'], |
|
| 118 | + $bits[ 'tm_hour' ], |
|
| 119 | + $bits[ 'tm_min' ], |
|
| 120 | 120 | 0, |
| 121 | - $bits['tm_mon'] + 1, |
|
| 122 | - $bits['tm_mday'], |
|
| 123 | - $bits['tm_year'] + 1900 |
|
| 121 | + $bits[ 'tm_mon' ] + 1, |
|
| 122 | + $bits[ 'tm_mday' ], |
|
| 123 | + $bits[ 'tm_year' ] + 1900 |
|
| 124 | 124 | ); |
| 125 | 125 | setlocale( LC_TIME, $oldLoc ); |
| 126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 131 | 131 | * @throws LoginException |
| 132 | 132 | */ |
| 133 | - public function login() { |
|
| 133 | + public function login () { |
|
| 134 | 134 | if ( self::$loggedIn ) { |
| 135 | 135 | $this->logger->debug( 'Already logged in' ); |
| 136 | 136 | return; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | self::$loggedIn = true; |
| 159 | 159 | // Clear tokens cache |
| 160 | - $this->tokens = []; |
|
| 160 | + $this->tokens = [ ]; |
|
| 161 | 161 | $this->logger->info( 'Login succeeded' ); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param string $type |
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | - public function getToken( string $type ) : string { |
|
| 170 | + public function getToken ( string $type ) : string { |
|
| 171 | 171 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 172 | 172 | $params = [ |
| 173 | 173 | 'action' => 'query', |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * @param string $title |
| 191 | 191 | * @return int |
| 192 | 192 | */ |
| 193 | - public function getPageCreationTS( string $title ) : int { |
|
| 193 | + public function getPageCreationTS ( string $title ) : int { |
|
| 194 | 194 | $params = [ |
| 195 | 195 | 'action' => 'query', |
| 196 | 196 | 'prop' => 'revisions', |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
| 205 | 205 | $data = $res->query->pages; |
| 206 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 206 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param string $title |
| 213 | 213 | * @param string $reason |
| 214 | 214 | */ |
| 215 | - public function protectPage( string $title, string $reason ) { |
|
| 215 | + public function protectPage ( string $title, string $reason ) { |
|
| 216 | 216 | $this->logger->info( "Protecting page $title" ); |
| 217 | 217 | $this->login(); |
| 218 | 218 | |
@@ -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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @inheritDoc |
| 20 | 20 | */ |
| 21 | - public function run() : TaskResult { |
|
| 21 | + public function run () : TaskResult { |
|
| 22 | 22 | $this->getLogger()->info( 'Starting task UpdateList' ); |
| 23 | 23 | $this->actualList = $this->getActualAdmins(); |
| 24 | 24 | $this->botList = $this->getDataProvider()->getUsersList(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - protected function getActualAdmins() : array { |
|
| 56 | + protected function getActualAdmins () : array { |
|
| 57 | 57 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 58 | 58 | $params = [ |
| 59 | 59 | 'action' => 'query', |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * @param \stdClass $data |
| 72 | 72 | * @return array |
| 73 | 73 | */ |
| 74 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 75 | - $ret = []; |
|
| 74 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 75 | + $ret = [ ]; |
|
| 76 | 76 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 77 | 77 | foreach ( $data->query->allusers as $u ) { |
| 78 | 78 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -89,22 +89,22 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return array[] |
| 91 | 91 | */ |
| 92 | - protected function getMissingGroups() : array { |
|
| 93 | - $missing = []; |
|
| 92 | + protected function getMissingGroups () : array { |
|
| 93 | + $missing = [ ]; |
|
| 94 | 94 | foreach ( $this->actualList as $adm => $groups ) { |
| 95 | - $groupsList = []; |
|
| 95 | + $groupsList = [ ]; |
|
| 96 | 96 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 97 | 97 | $groupsList = $groups; |
| 98 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 98 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 99 | 99 | // Only some groups are missing |
| 100 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 100 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | foreach ( $groupsList as $group ) { |
| 104 | 104 | try { |
| 105 | 105 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 106 | 106 | } catch ( TaskException $e ) { |
| 107 | - $this->errors[] = $e->getMessage(); |
|
| 107 | + $this->errors[ ] = $e->getMessage(); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @return string |
| 120 | 120 | * @throws TaskException |
| 121 | 121 | */ |
| 122 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 122 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 123 | 123 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 124 | 124 | |
| 125 | 125 | $url = DEFAULT_URL; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string $group |
| 155 | 155 | * @return string|null |
| 156 | 156 | */ |
| 157 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 157 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 158 | 158 | $ts = null; |
| 159 | 159 | foreach ( $data->query->logevents as $entry ) { |
| 160 | 160 | if ( !isset( $entry->params ) ) { |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return array[] |
| 178 | 178 | */ |
| 179 | - protected function getExtraGroups() : array { |
|
| 180 | - $extra = []; |
|
| 179 | + protected function getExtraGroups () : array { |
|
| 180 | + $extra = [ ]; |
|
| 181 | 181 | foreach ( $this->botList as $name => $groups ) { |
| 182 | 182 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 183 | 183 | $extra[ $name ] = $groups; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @param array $newContent |
| 195 | 195 | */ |
| 196 | - protected function doUpdateList( array $newContent ) { |
|
| 196 | + protected function doUpdateList ( array $newContent ) { |
|
| 197 | 197 | $this->getLogger()->info( 'Updating admin list' ); |
| 198 | 198 | |
| 199 | 199 | $params = [ |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param array[] $extra |
| 213 | 213 | * @return array[] |
| 214 | 214 | */ |
| 215 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 215 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 216 | 216 | $newContent = $this->botList; |
| 217 | 217 | foreach ( $newContent as $user => $groups ) { |
| 218 | 218 | if ( isset( $missing[ $user ] ) ) { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | /** |
| 3 | 3 | * Entry point for the bot, called by CLI |
| 4 | 4 | */ |
@@ -38,9 +38,8 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | /* URL (for debugging purpose) */ |
| 40 | 40 | $urlParam = getopt( '', [ 'force-url:' ] ); |
| 41 | -$url = isset( $urlParam['force-url'] ) ? |
|
| 42 | - $urlParam['force-url'] : |
|
| 43 | - 'https://it.wikipedia.org/w/api.php'; |
|
| 41 | +$url = isset( $urlParam[ 'force-url' ] ) ? |
|
| 42 | + $urlParam[ 'force-url' ] : 'https://it.wikipedia.org/w/api.php'; |
|
| 44 | 43 | |
| 45 | 44 | define( 'DEFAULT_URL', $url ); |
| 46 | 45 | |