@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - protected function reallyMakeRequest( string $params ) : string { |
|
| 14 | + protected function reallyMakeRequest ( string $params ) : string { |
|
| 15 | 15 | $curl = curl_init(); |
| 16 | 16 | if ( $curl === false ) { |
| 17 | 17 | throw new APIRequestException( 'Cannot open cURL handler.' ); |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | * @return int |
| 54 | 54 | * @internal Only used as CB for cURL |
| 55 | 55 | */ |
| 56 | - public function headersHandler( $ch, string $header ) : int { |
|
| 56 | + public function headersHandler ( $ch, string $header ) : int { |
|
| 57 | 57 | $bits = explode( ':', $header, 2 ); |
| 58 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 59 | - $this->newCookies[] = $bits[1]; |
|
| 58 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 59 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 60 | 60 | } |
| 61 | 61 | // @phan-suppress-next-line PhanTypeMismatchReturn WTF? Why does phan thinks this is a string? |
| 62 | 62 | return strlen( $header ); |
@@ -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,7 +29,7 @@ discard block |
||
| 29 | 29 | /** @var string */ |
| 30 | 30 | protected $method; |
| 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 |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param array $params |
| 38 | 38 | * @param bool $isPOST |
| 39 | 39 | */ |
| 40 | - protected function __construct( array $params, bool $isPOST = false ) { |
|
| 40 | + protected function __construct ( array $params, bool $isPOST = false ) { |
|
| 41 | 41 | $this->params = [ 'format' => 'json' ] + $params; |
| 42 | 42 | $this->method = $isPOST ? 'POST' : 'GET'; |
| 43 | 43 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param bool $isPOST |
| 50 | 50 | * @return self |
| 51 | 51 | */ |
| 52 | - public static function newFromParams( array $params, bool $isPOST = false ) : self { |
|
| 52 | + public static function newFromParams ( array $params, bool $isPOST = false ) : self { |
|
| 53 | 53 | if ( extension_loaded( 'curl' ) ) { |
| 54 | 54 | $ret = new CurlRequest( $params, $isPOST ); |
| 55 | 55 | } else { |
@@ -63,14 +63,14 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return \stdClass |
| 65 | 65 | */ |
| 66 | - public function execute() : \stdClass { |
|
| 66 | + public function execute () : \stdClass { |
|
| 67 | 67 | $curParams = $this->params; |
| 68 | - $sets = []; |
|
| 68 | + $sets = [ ]; |
|
| 69 | 69 | do { |
| 70 | 70 | $res = $this->makeRequestInternal( $curParams ); |
| 71 | 71 | |
| 72 | 72 | $this->handleErrorAndWarnings( $res ); |
| 73 | - $sets[] = $res; |
|
| 73 | + $sets[ ] = $res; |
|
| 74 | 74 | |
| 75 | 75 | $finished = true; |
| 76 | 76 | if ( isset( $res->continue ) ) { |
@@ -88,9 +88,9 @@ discard block |
||
| 88 | 88 | * @param array $params |
| 89 | 89 | * @return \stdClass |
| 90 | 90 | */ |
| 91 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
| 91 | + private function makeRequestInternal ( array $params ) : \stdClass { |
|
| 92 | 92 | if ( $this->method === 'POST' ) { |
| 93 | - $params['maxlag'] = self::MAXLAG; |
|
| 93 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
| 94 | 94 | } |
| 95 | 95 | $params = http_build_query( $params ); |
| 96 | 96 | |
@@ -106,17 +106,17 @@ discard block |
||
| 106 | 106 | * @param string $params |
| 107 | 107 | * @return string |
| 108 | 108 | */ |
| 109 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
| 109 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * After a request, set cookies for the next ones |
| 113 | 113 | * |
| 114 | 114 | * @param array $cookies |
| 115 | 115 | */ |
| 116 | - protected function setCookies( array $cookies ) { |
|
| 116 | + protected function setCookies ( array $cookies ) { |
|
| 117 | 117 | foreach ( $cookies as $cookie ) { |
| 118 | 118 | $bits = explode( ';', $cookie ); |
| 119 | - list( $name, $value ) = explode( '=', $bits[0] ); |
|
| 119 | + list( $name, $value ) = explode( '=', $bits[ 0 ] ); |
|
| 120 | 120 | self::$cookiesToSet[ $name ] = $value; |
| 121 | 121 | } |
| 122 | 122 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param \stdClass $res |
| 128 | 128 | * @throws APIRequestException |
| 129 | 129 | */ |
| 130 | - protected function handleErrorAndWarnings( $res ) { |
|
| 130 | + protected function handleErrorAndWarnings ( $res ) { |
|
| 131 | 131 | if ( isset( $res->error ) ) { |
| 132 | 132 | switch ( $res->error->code ) { |
| 133 | 133 | case 'missingtitle': |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param \stdClass[] $sets |
| 154 | 154 | * @return \stdClass |
| 155 | 155 | */ |
| 156 | - private function mergeSets( array $sets ) : \stdClass { |
|
| 156 | + private function mergeSets ( array $sets ) : \stdClass { |
|
| 157 | 157 | // Use the first set as template |
| 158 | 158 | $ret = array_shift( $sets ); |
| 159 | 159 | |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param array|\stdClass $second |
| 171 | 171 | * @return array|\stdClass array |
| 172 | 172 | */ |
| 173 | - private function recursiveMerge( $first, $second ) { |
|
| 173 | + private function recursiveMerge ( $first, $second ) { |
|
| 174 | 174 | $ret = $first; |
| 175 | 175 | if ( is_array( $second ) ) { |
| 176 | 176 | $ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second; |
@@ -193,14 +193,14 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @return array |
| 195 | 195 | */ |
| 196 | - protected function getHeaders() :array { |
|
| 196 | + protected function getHeaders () :array { |
|
| 197 | 197 | $ret = self::HEADERS; |
| 198 | 198 | if ( self::$cookiesToSet ) { |
| 199 | - $cookies = []; |
|
| 199 | + $cookies = [ ]; |
|
| 200 | 200 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
| 201 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 201 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
| 202 | 202 | } |
| 203 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 203 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 204 | 204 | } |
| 205 | 205 | return $ret; |
| 206 | 206 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @param array $headers |
| 212 | 212 | * @return string |
| 213 | 213 | */ |
| 214 | - protected function buildHeadersString( array $headers ) : string { |
|
| 214 | + protected function buildHeadersString ( array $headers ) : string { |
|
| 215 | 215 | $ret = ''; |
| 216 | 216 | foreach ( $headers as $header ) { |
| 217 | 217 | $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 = self::$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 | |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | const VERSION = 1.0; |
| 13 | 13 | |
| 14 | - public function __construct() { |
|
| 14 | + public function __construct () { |
|
| 15 | 15 | $this->logger = new Logger; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Entry point for the whole process |
| 20 | 20 | */ |
| 21 | - public function run() { |
|
| 21 | + public function run () { |
|
| 22 | 22 | $this->logger->info( 'Starting full process.' ); |
| 23 | 23 | $manager = new TaskManager; |
| 24 | 24 | $res = $manager->run( TaskManager::MODE_COMPLETE ); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param string $task |
| 37 | 37 | */ |
| 38 | - public function runSingle( string $task ) { |
|
| 38 | + public function runSingle ( string $task ) { |
|
| 39 | 39 | $this->logger->info( "Starting single task $task." ); |
| 40 | 40 | $manager = new TaskManager; |
| 41 | 41 | $res = $manager->run( TaskManager::MODE_SINGLE, $task ); |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | const STATUS_OK = 0; |
| 15 | 15 | const STATUS_ERROR = 1; |
| 16 | 16 | /** @var string[] */ |
| 17 | - protected $errors = []; |
|
| 17 | + protected $errors = [ ]; |
|
| 18 | 18 | /** @var TaskDataProvider */ |
| 19 | 19 | private $dataProvider; |
| 20 | 20 | |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @param TaskDataProvider $dataProvider |
| 25 | 25 | */ |
| 26 | - final public function __construct( TaskDataProvider $dataProvider ) { |
|
| 26 | + final public function __construct ( TaskDataProvider $dataProvider ) { |
|
| 27 | 27 | set_exception_handler( [ $this, 'handleException' ] ); |
| 28 | 28 | set_error_handler( [ $this, 'handleError' ] ); |
| 29 | 29 | parent::__construct(); |
| 30 | 30 | $this->dataProvider = $dataProvider; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function __destruct() { |
|
| 33 | + public function __destruct () { |
|
| 34 | 34 | restore_error_handler(); |
| 35 | 35 | restore_exception_handler(); |
| 36 | 36 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return TaskResult |
| 42 | 42 | */ |
| 43 | - abstract public function run() : TaskResult; |
|
| 43 | + abstract public function run () : TaskResult; |
|
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * Exception handler. |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param \Throwable $ex |
| 49 | 49 | * @protected |
| 50 | 50 | */ |
| 51 | - public function handleException( \Throwable $ex ) { |
|
| 51 | + public function handleException ( \Throwable $ex ) { |
|
| 52 | 52 | $this->getLogger()->error( |
| 53 | 53 | get_class( $ex ) . ': ' . |
| 54 | 54 | $ex->getMessage() . "\nTrace:\n" . |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | * @param int $errline |
| 66 | 66 | * @protected |
| 67 | 67 | */ |
| 68 | - public function handleError( $errno, $errstr, $errfile, $errline ) { |
|
| 68 | + public function handleError ( $errno, $errstr, $errfile, $errline ) { |
|
| 69 | 69 | throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline ); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * @return TaskDataProvider |
| 74 | 74 | */ |
| 75 | - protected function getDataProvider() : TaskDataProvider { |
|
| 75 | + protected function getDataProvider () : TaskDataProvider { |
|
| 76 | 76 | return $this->dataProvider; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -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(); |
@@ -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 ) ) { |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | /** |
| 88 | 88 | * @return array |
| 89 | 89 | */ |
| 90 | - protected function getList() : array { |
|
| 90 | + protected function getList () : array { |
|
| 91 | 91 | $this->getLogger()->debug( 'Retrieving admins - JSON list' ); |
| 92 | 92 | $content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) ); |
| 93 | 93 | |
@@ -99,22 +99,22 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @return array[] |
| 101 | 101 | */ |
| 102 | - protected function getMissingGroups() : array { |
|
| 103 | - $missing = []; |
|
| 102 | + protected function getMissingGroups () : array { |
|
| 103 | + $missing = [ ]; |
|
| 104 | 104 | foreach ( $this->actualList as $adm => $groups ) { |
| 105 | - $groupsList = []; |
|
| 105 | + $groupsList = [ ]; |
|
| 106 | 106 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 107 | 107 | $groupsList = $groups; |
| 108 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 108 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 109 | 109 | // Only some groups are missing |
| 110 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 110 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | foreach ( $groupsList as $group ) { |
| 114 | 114 | try { |
| 115 | 115 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 116 | 116 | } catch ( TaskException $e ) { |
| 117 | - $this->errors[] = $e->getMessage(); |
|
| 117 | + $this->errors[ ] = $e->getMessage(); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @return string |
| 130 | 130 | * @throws TaskException |
| 131 | 131 | */ |
| 132 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 132 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 133 | 133 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 134 | 134 | |
| 135 | 135 | if ( $group === 'checkuser' ) { |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $group |
| 170 | 170 | * @return string|null |
| 171 | 171 | */ |
| 172 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 172 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 173 | 173 | $ts = null; |
| 174 | 174 | foreach ( $data->query->logevents as $entry ) { |
| 175 | 175 | if ( !isset( $entry->params ) ) { |
@@ -191,8 +191,8 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return array[] |
| 193 | 193 | */ |
| 194 | - protected function getExtraGroups() : array { |
|
| 195 | - $extra = []; |
|
| 194 | + protected function getExtraGroups () : array { |
|
| 195 | + $extra = [ ]; |
|
| 196 | 196 | foreach ( $this->botList as $name => $groups ) { |
| 197 | 197 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 198 | 198 | $extra[ $name ] = $groups; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @param array $newContent |
| 210 | 210 | */ |
| 211 | - protected function doUpdateList( array $newContent ) { |
|
| 211 | + protected function doUpdateList ( array $newContent ) { |
|
| 212 | 212 | $this->getLogger()->info( 'Updating admin list' ); |
| 213 | 213 | |
| 214 | 214 | $params = [ |
@@ -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 ] ) ) { |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function run() : TaskResult { |
|
| 16 | + public function run () : TaskResult { |
|
| 17 | 17 | $this->getLogger()->info( 'Starting task CreatePages' ); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param string $user |
| 36 | 36 | * @param array $groups |
| 37 | 37 | */ |
| 38 | - protected function processUser( string $user, array $groups ) { |
|
| 38 | + protected function processUser ( string $user, array $groups ) { |
|
| 39 | 39 | try { |
| 40 | 40 | $num = $this->getLastPageNum( $user ) + 1; |
| 41 | 41 | } catch ( TaskException $e ) { |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @return int |
| 66 | 66 | * @throws TaskException |
| 67 | 67 | */ |
| 68 | - protected function getLastPageNum( string $user ) : int { |
|
| 68 | + protected function getLastPageNum ( string $user ) : int { |
|
| 69 | 69 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 70 | - $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1]; |
|
| 70 | + $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ]; |
|
| 71 | 71 | $params = [ |
| 72 | 72 | 'action' => 'query', |
| 73 | 73 | 'list' => 'allpages', |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | * @param string $user |
| 103 | 103 | * @param array $groups |
| 104 | 104 | */ |
| 105 | - protected function createPage( string $title, string $user, array $groups ) { |
|
| 105 | + protected function createPage ( string $title, string $user, array $groups ) { |
|
| 106 | 106 | $this->getLogger()->info( "Creating page $title" ); |
| 107 | 107 | $text = $this->getConfig()->get( 'ric-page-text' ); |
| 108 | 108 | $textParams = [ |
| 109 | 109 | '$user' => $user, |
| 110 | - '$date' => $groups['sysop'], |
|
| 111 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 112 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 110 | + '$date' => $groups[ 'sysop' ], |
|
| 111 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 112 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 113 | 113 | ]; |
| 114 | 114 | $text = strtr( $text, $textParams ); |
| 115 | 115 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $title |
| 129 | 129 | * @param string $newText |
| 130 | 130 | */ |
| 131 | - protected function createBasePage( string $title, string $newText ) { |
|
| 131 | + protected function createBasePage ( string $title, string $newText ) { |
|
| 132 | 132 | $this->getLogger()->info( "Creating base page $title" ); |
| 133 | 133 | |
| 134 | 134 | $params = [ |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $title |
| 146 | 146 | * @param string $newText |
| 147 | 147 | */ |
| 148 | - protected function updateBasePage( string $title, string $newText ) { |
|
| 148 | + protected function updateBasePage ( string $title, string $newText ) { |
|
| 149 | 149 | $this->getLogger()->info( "Updating base page $title" ); |
| 150 | 150 | |
| 151 | 151 | $params = [ |
@@ -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 | |
@@ -12,20 +12,20 @@ discard block |
||
| 12 | 12 | private $users; |
| 13 | 13 | |
| 14 | 14 | /** @var PageRiconferma[] */ |
| 15 | - private $createdPages = []; |
|
| 15 | + private $createdPages = [ ]; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Get a list of users to execute tasks on. |
| 19 | 19 | * |
| 20 | 20 | * @return array[] |
| 21 | 21 | */ |
| 22 | - public function getUsersToProcess() : array { |
|
| 22 | + public function getUsersToProcess () : array { |
|
| 23 | 23 | if ( $this->users === null ) { |
| 24 | 24 | $this->getLogger()->debug( 'Retrieving users list' ); |
| 25 | 25 | $content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) ); |
| 26 | 26 | $listUsers = json_decode( $content, true ); |
| 27 | 27 | |
| 28 | - $this->users = []; |
|
| 28 | + $this->users = [ ]; |
|
| 29 | 29 | foreach ( $listUsers as $user => $groups ) { |
| 30 | 30 | $timestamp = $this->getValidTimestamp( $groups ); |
| 31 | 31 | |
@@ -47,13 +47,11 @@ discard block |
||
| 47 | 47 | * @param array $groups |
| 48 | 48 | * @return int |
| 49 | 49 | */ |
| 50 | - private function getValidTimestamp( array $groups ) : int { |
|
| 50 | + private function getValidTimestamp ( array $groups ) : int { |
|
| 51 | 51 | $checkuser = isset( $groups[ 'checkuser' ] ) ? |
| 52 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : |
|
| 53 | - 0; |
|
| 52 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 54 | 53 | $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
| 55 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : |
|
| 56 | - 0; |
|
| 54 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 57 | 55 | |
| 58 | 56 | $timestamp = max( $bureaucrat, $checkuser ); |
| 59 | 57 | if ( $timestamp === 0 ) { |
@@ -67,7 +65,7 @@ discard block |
||
| 67 | 65 | * |
| 68 | 66 | * @return PageRiconferma[] |
| 69 | 67 | */ |
| 70 | - public function getOpenPages() : array { |
|
| 68 | + public function getOpenPages () : array { |
|
| 71 | 69 | $baseTitle = $this->getConfig()->get( 'ric-main-page' ); |
| 72 | 70 | $params = [ |
| 73 | 71 | 'action' => 'query', |
@@ -79,10 +77,10 @@ discard block |
||
| 79 | 77 | |
| 80 | 78 | $res = RequestBase::newFromParams( $params )->execute(); |
| 81 | 79 | $pages = $res->query->pages; |
| 82 | - $ret = []; |
|
| 80 | + $ret = [ ]; |
|
| 83 | 81 | foreach ( reset( $pages )->templates as $page ) { |
| 84 | 82 | if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) { |
| 85 | - $ret[] = new PageRiconferma( $page->title, $this->getController() ); |
|
| 83 | + $ret[ ] = new PageRiconferma( $page->title, $this->getController() ); |
|
| 86 | 84 | } |
| 87 | 85 | } |
| 88 | 86 | return $ret; |
@@ -93,21 +91,21 @@ discard block |
||
| 93 | 91 | * |
| 94 | 92 | * @param string $name |
| 95 | 93 | */ |
| 96 | - public function removeUser( string $name ) { |
|
| 94 | + public function removeUser ( string $name ) { |
|
| 97 | 95 | unset( $this->users[ $name ] ); |
| 98 | 96 | } |
| 99 | 97 | |
| 100 | 98 | /** |
| 101 | 99 | * @return PageRiconferma[] |
| 102 | 100 | */ |
| 103 | - public function getCreatedPages() : array { |
|
| 101 | + public function getCreatedPages () : array { |
|
| 104 | 102 | return $this->createdPages; |
| 105 | 103 | } |
| 106 | 104 | |
| 107 | 105 | /** |
| 108 | 106 | * @param PageRiconferma $page |
| 109 | 107 | */ |
| 110 | - public function addCreatedPages( PageRiconferma $page ) { |
|
| 111 | - $this->createdPages[] = $page; |
|
| 108 | + public function addCreatedPages ( PageRiconferma $page ) { |
|
| 109 | + $this->createdPages[ ] = $page; |
|
| 112 | 110 | } |
| 113 | 111 | } |