@@ -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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** @var string[] */ |
| 19 | 19 | private $tokens; |
| 20 | 20 | |
| 21 | - public function __construct() { |
|
| 21 | + public function __construct () { |
|
| 22 | 22 | $this->logger = new Logger; |
| 23 | 23 | } |
| 24 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @return string |
| 30 | 30 | * @throws MissingPageException |
| 31 | 31 | */ |
| 32 | - public function getPageContent( string $title ) : string { |
|
| 32 | + public function getPageContent ( string $title ) : string { |
|
| 33 | 33 | $this->logger->debug( "Retrieving page $title" ); |
| 34 | 34 | $params = [ |
| 35 | 35 | 'action' => 'query', |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | throw new MissingPageException( $title ); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return $page->revisions[0]->slots->main->{ '*' }; |
|
| 50 | + return $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param array $params |
| 57 | 57 | * @throws APIRequestException |
| 58 | 58 | */ |
| 59 | - public function editPage( array $params ) { |
|
| 59 | + public function editPage ( array $params ) { |
|
| 60 | 60 | $this->login(); |
| 61 | 61 | |
| 62 | 62 | $params = [ |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 76 | 76 | * @throws LoginException |
| 77 | 77 | */ |
| 78 | - public function login() { |
|
| 78 | + public function login () { |
|
| 79 | 79 | if ( self::$loggedIn ) { |
| 80 | 80 | $this->logger->debug( 'Already logged in' ); |
| 81 | 81 | return; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | self::$loggedIn = true; |
| 104 | 104 | // Clear tokens cache |
| 105 | - $this->tokens = []; |
|
| 105 | + $this->tokens = [ ]; |
|
| 106 | 106 | $this->logger->info( 'Login succeeded' ); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param string $type |
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | - public function getToken( string $type ) : string { |
|
| 115 | + public function getToken ( string $type ) : string { |
|
| 116 | 116 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 117 | 117 | $params = [ |
| 118 | 118 | 'action' => 'query', |
@@ -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->getList(); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | - protected function getActualAdmins() : array { |
|
| 49 | + protected function getActualAdmins () : array { |
|
| 50 | 50 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 51 | 51 | $params = [ |
| 52 | 52 | 'action' => 'query', |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | * @param \stdClass $data |
| 65 | 65 | * @return array |
| 66 | 66 | */ |
| 67 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 68 | - $ret = []; |
|
| 67 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 68 | + $ret = [ ]; |
|
| 69 | 69 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 70 | 70 | foreach ( $data->query->allusers as $u ) { |
| 71 | 71 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | /** |
| 81 | 81 | * @return array |
| 82 | 82 | */ |
| 83 | - protected function getList() : array { |
|
| 83 | + protected function getList () : array { |
|
| 84 | 84 | $this->getLogger()->debug( 'Retrieving admins - JSON list' ); |
| 85 | 85 | $content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) ); |
| 86 | 86 | |
@@ -92,22 +92,22 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return array[] |
| 94 | 94 | */ |
| 95 | - protected function getMissingGroups() : array { |
|
| 96 | - $missing = []; |
|
| 95 | + protected function getMissingGroups () : array { |
|
| 96 | + $missing = [ ]; |
|
| 97 | 97 | foreach ( $this->actualList as $adm => $groups ) { |
| 98 | - $groupsList = []; |
|
| 98 | + $groupsList = [ ]; |
|
| 99 | 99 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 100 | 100 | $groupsList = $groups; |
| 101 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 101 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 102 | 102 | // Only some groups are missing |
| 103 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 103 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | foreach ( $groupsList as $group ) { |
| 107 | 107 | try { |
| 108 | 108 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 109 | 109 | } catch ( TaskException $e ) { |
| 110 | - $this->errors[] = $e->getMessage(); |
|
| 110 | + $this->errors[ ] = $e->getMessage(); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @return string |
| 123 | 123 | * @throws TaskException |
| 124 | 124 | */ |
| 125 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 125 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 126 | 126 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 127 | 127 | |
| 128 | 128 | if ( $group === 'checkuser' ) { |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param string $group |
| 163 | 163 | * @return string|null |
| 164 | 164 | */ |
| 165 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 165 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 166 | 166 | $ts = null; |
| 167 | 167 | foreach ( $data->query->logevents as $entry ) { |
| 168 | 168 | if ( !isset( $entry->params ) ) { |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @return array[] |
| 186 | 186 | */ |
| 187 | - protected function getExtraGroups() : array { |
|
| 188 | - $extra = []; |
|
| 187 | + protected function getExtraGroups () : array { |
|
| 188 | + $extra = [ ]; |
|
| 189 | 189 | foreach ( $this->botList as $name => $groups ) { |
| 190 | 190 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 191 | 191 | $extra[ $name ] = $groups; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @param array $newContent |
| 203 | 203 | */ |
| 204 | - protected function doUpdateList( array $newContent ) { |
|
| 204 | + protected function doUpdateList ( array $newContent ) { |
|
| 205 | 205 | ksort( $newContent ); |
| 206 | 206 | |
| 207 | 207 | if ( $newContent === $this->botList ) { |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @param array[] $extra |
| 228 | 228 | * @return array[] |
| 229 | 229 | */ |
| 230 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 230 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 231 | 231 | $newContent = $this->botList; |
| 232 | 232 | foreach ( $newContent as $user => $groups ) { |
| 233 | 233 | if ( isset( $missing[ $user ] ) ) { |