@@ -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,15 +18,15 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @inheritDoc |
| 20 | 20 | */ |
| 21 | - protected function getSubtasksMap(): array { |
|
| 21 | + protected function getSubtasksMap (): array { |
|
| 22 | 22 | // Everything is done here. |
| 23 | - return []; |
|
| 23 | + return [ ]; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @inheritDoc |
| 28 | 28 | */ |
| 29 | - public function runInternal() : int { |
|
| 29 | + public function runInternal () : int { |
|
| 30 | 30 | $this->actualList = $this->getActualAdmins(); |
| 31 | 31 | $pageBotList = $this->getBotList(); |
| 32 | 32 | $this->botList = $pageBotList->getDecodedContent(); |
@@ -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 | $params = [ |
| 58 | 58 | 'action' => 'query', |
| 59 | 59 | 'list' => 'allusers', |
@@ -70,8 +70,8 @@ discard block |
||
| 70 | 70 | * @param \stdClass $data |
| 71 | 71 | * @return array |
| 72 | 72 | */ |
| 73 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 74 | - $ret = []; |
|
| 73 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 74 | + $ret = [ ]; |
|
| 75 | 75 | $blacklist = $this->getOpt( 'exclude-admins' ); |
| 76 | 76 | foreach ( $data->query->allusers as $u ) { |
| 77 | 77 | if ( in_array( $u->name, $blacklist, true ) ) { |
@@ -88,16 +88,16 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return array[] |
| 90 | 90 | */ |
| 91 | - protected function getMissingGroups() : array { |
|
| 92 | - $missing = []; |
|
| 91 | + protected function getMissingGroups () : array { |
|
| 92 | + $missing = [ ]; |
|
| 93 | 93 | foreach ( $this->actualList as $adm => $groups ) { |
| 94 | - $curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) ); |
|
| 94 | + $curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) ); |
|
| 95 | 95 | |
| 96 | 96 | foreach ( $curMissing as $group ) { |
| 97 | 97 | try { |
| 98 | 98 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 99 | 99 | } catch ( TaskException $e ) { |
| 100 | - $this->errors[] = $e->getMessage(); |
|
| 100 | + $this->errors[ ] = $e->getMessage(); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @return string |
| 113 | 113 | * @throws TaskException |
| 114 | 114 | */ |
| 115 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 115 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 116 | 116 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 117 | 117 | |
| 118 | 118 | $wiki = $this->getWiki(); |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @param string $group |
| 148 | 148 | * @return string|null |
| 149 | 149 | */ |
| 150 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 150 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 151 | 151 | $ts = null; |
| 152 | 152 | foreach ( $data->query->logevents as $entry ) { |
| 153 | 153 | if ( |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return array[] |
| 168 | 168 | */ |
| 169 | - protected function getExtraGroups() : array { |
|
| 170 | - $extra = []; |
|
| 169 | + protected function getExtraGroups () : array { |
|
| 170 | + $extra = [ ]; |
|
| 171 | 171 | foreach ( $this->botList as $name => $groups ) { |
| 172 | 172 | $groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ); |
| 173 | 173 | if ( !isset( $this->actualList[ $name ] ) ) { |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param string[] $names |
| 184 | 184 | * @return \stdClass |
| 185 | 185 | */ |
| 186 | - private function getRenameEntries( array $names ) : \stdClass { |
|
| 186 | + private function getRenameEntries ( array $names ) : \stdClass { |
|
| 187 | 187 | $titles = array_map( static function ( $x ) { |
| 188 | 188 | return "Utente:$x"; |
| 189 | 189 | }, $names ); |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | * @param string[] $names |
| 208 | 208 | * @return string[] [ old_name => new_name ] |
| 209 | 209 | */ |
| 210 | - protected function getRenamedUsers( array $names ) : array { |
|
| 210 | + protected function getRenamedUsers ( array $names ) : array { |
|
| 211 | 211 | if ( !$names ) { |
| 212 | - return []; |
|
| 212 | + return [ ]; |
|
| 213 | 213 | } |
| 214 | 214 | $this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) ); |
| 215 | 215 | |
| 216 | 216 | $data = $this->getRenameEntries( $names ); |
| 217 | - $ret = []; |
|
| 217 | + $ret = [ ]; |
|
| 218 | 218 | foreach ( $data->query->logevents as $entry ) { |
| 219 | 219 | // 1 month is arbitrary |
| 220 | 220 | if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) { |
@@ -232,18 +232,18 @@ discard block |
||
| 232 | 232 | * @param array &$newContent |
| 233 | 233 | * @param array $removed |
| 234 | 234 | */ |
| 235 | - private function handleRenames( array &$newContent, array $removed ) : void { |
|
| 235 | + private function handleRenames ( array &$newContent, array $removed ) : void { |
|
| 236 | 236 | $renameMap = $this->getRenamedUsers( array_keys( $removed ) ); |
| 237 | 237 | foreach ( $removed as $oldName => $info ) { |
| 238 | 238 | if ( |
| 239 | 239 | array_key_exists( $oldName, $renameMap ) && |
| 240 | - array_key_exists( $renameMap[$oldName], $newContent ) |
|
| 240 | + array_key_exists( $renameMap[ $oldName ], $newContent ) |
|
| 241 | 241 | ) { |
| 242 | 242 | // This user was renamed! Add this name as alias, if they're still listed |
| 243 | 243 | $newName = $renameMap[ $oldName ]; |
| 244 | 244 | $this->getLogger()->info( "Found rename $oldName -> $newName" ); |
| 245 | - $aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) ); |
|
| 246 | - $newContent[ $newName ]['aliases'] = $aliases; |
|
| 245 | + $aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) ); |
|
| 246 | + $newContent[ $newName ][ 'aliases' ] = $aliases; |
|
| 247 | 247 | // Transfer overrides to the new name. |
| 248 | 248 | $overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] ); |
| 249 | 249 | $newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides ); |
@@ -257,12 +257,12 @@ discard block |
||
| 257 | 257 | * @param array[] $extra |
| 258 | 258 | * @return string[] Removed users |
| 259 | 259 | */ |
| 260 | - private function handleExtraAndMissing( |
|
| 260 | + private function handleExtraAndMissing ( |
|
| 261 | 261 | array &$newContent, |
| 262 | 262 | array $missing, |
| 263 | 263 | array $extra |
| 264 | 264 | ) : array { |
| 265 | - $removed = []; |
|
| 265 | + $removed = [ ]; |
|
| 266 | 266 | foreach ( $newContent as $user => $groups ) { |
| 267 | 267 | if ( isset( $missing[ $user ] ) ) { |
| 268 | 268 | $newContent[ $user ] = array_merge( $groups, $missing[ $user ] ); |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) { |
| 273 | 273 | $newContent[ $user ] = $newGroups; |
| 274 | 274 | } else { |
| 275 | - $removed[$user] = $newContent[$user]; |
|
| 275 | + $removed[ $user ] = $newContent[ $user ]; |
|
| 276 | 276 | unset( $newContent[ $user ] ); |
| 277 | 277 | } |
| 278 | 278 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param array[] $extra |
| 290 | 290 | * @return array[] |
| 291 | 291 | */ |
| 292 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 292 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 293 | 293 | $newContent = $this->botList; |
| 294 | 294 | |
| 295 | 295 | $removed = $this->handleExtraAndMissing( $newContent, $missing, $extra ); |
@@ -309,12 +309,12 @@ discard block |
||
| 309 | 309 | * |
| 310 | 310 | * @param array[] &$newContent |
| 311 | 311 | */ |
| 312 | - protected function removeOverrides( array &$newContent ) : void { |
|
| 313 | - $removed = []; |
|
| 312 | + protected function removeOverrides ( array &$newContent ) : void { |
|
| 313 | + $removed = [ ]; |
|
| 314 | 314 | foreach ( $newContent as $user => $groups ) { |
| 315 | 315 | if ( PageBotList::isOverrideExpired( $groups ) ) { |
| 316 | 316 | unset( $newContent[ $user ][ 'override' ] ); |
| 317 | - $removed[] = $user; |
|
| 317 | + $removed[ ] = $user; |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | abstract class TaskBase extends ContextSource { |
| 17 | 17 | /** @var string[] */ |
| 18 | - protected $errors = []; |
|
| 18 | + protected $errors = [ ]; |
|
| 19 | 19 | /** @var TaskDataProvider */ |
| 20 | 20 | protected $dataProvider; |
| 21 | 21 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @param MessageProvider $mp |
| 29 | 29 | * @param PageBotList $pbl |
| 30 | 30 | */ |
| 31 | - final public function __construct( |
|
| 31 | + final public function __construct ( |
|
| 32 | 32 | LoggerInterface $logger, |
| 33 | 33 | WikiGroup $wikiGroup, |
| 34 | 34 | TaskDataProvider $dataProvider, |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return TaskResult |
| 46 | 46 | */ |
| 47 | - final public function run() : TaskResult { |
|
| 47 | + final public function run () : TaskResult { |
|
| 48 | 48 | $class = ( new \ReflectionClass( $this ) )->getShortName(); |
| 49 | 49 | $opName = $this->getOperationName(); |
| 50 | 50 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return int One of the STATUS_* constants |
| 77 | 77 | */ |
| 78 | - abstract protected function runInternal() : int; |
|
| 78 | + abstract protected function runInternal () : int; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * How this operation should be called in logs |
| 82 | 82 | * |
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | - abstract public function getOperationName() : string; |
|
| 85 | + abstract public function getOperationName () : string; |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * @return TaskDataProvider |
| 89 | 89 | */ |
| 90 | - protected function getDataProvider() : TaskDataProvider { |
|
| 90 | + protected function getDataProvider () : TaskDataProvider { |
|
| 91 | 91 | return $this->dataProvider; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -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 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | * @param MessageProvider $mp |
| 63 | 63 | * @param PageBotList $pbl |
| 64 | 64 | */ |
| 65 | - public function __construct( |
|
| 65 | + public function __construct ( |
|
| 66 | 66 | LoggerInterface $logger, |
| 67 | 67 | WikiGroup $wikiGroup, |
| 68 | 68 | MessageProvider $mp, |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK |
| 88 | 88 | * @return TaskResult |
| 89 | 89 | */ |
| 90 | - public function run( string $mode, string $name = null ) : TaskResult { |
|
| 90 | + public function run ( string $mode, string $name = null ) : TaskResult { |
|
| 91 | 91 | if ( $mode === self::MODE_COMPLETE ) { |
| 92 | 92 | return $this->runAllTasks(); |
| 93 | 93 | } elseif ( $name === null ) { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return TaskResult |
| 104 | 104 | */ |
| 105 | - protected function runAllTasks() : TaskResult { |
|
| 105 | + protected function runAllTasks () : TaskResult { |
|
| 106 | 106 | $orderedList = [ |
| 107 | 107 | 'update-list', |
| 108 | 108 | 'start-new', |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param string $name |
| 125 | 125 | * @return TaskResult |
| 126 | 126 | */ |
| 127 | - protected function runTask( string $name ) : TaskResult { |
|
| 127 | + protected function runTask ( string $name ) : TaskResult { |
|
| 128 | 128 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 129 | 129 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
| 130 | 130 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @param string $name |
| 139 | 139 | * @return TaskResult |
| 140 | 140 | */ |
| 141 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 141 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 142 | 142 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 143 | 143 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 144 | 144 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $name |
| 154 | 154 | * @return Task |
| 155 | 155 | */ |
| 156 | - private function getTaskInstance( string $name ) : Task { |
|
| 156 | + private function getTaskInstance ( string $name ) : Task { |
|
| 157 | 157 | $class = self::TASKS_MAP[ $name ]; |
| 158 | 158 | /** @var Task $ret */ |
| 159 | 159 | $ret = new $class( |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param string $class |
| 173 | 173 | * @return Subtask |
| 174 | 174 | */ |
| 175 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 175 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 176 | 176 | /** @var Subtask $ret */ |
| 177 | 177 | $ret = new $class( |
| 178 | 178 | $this->logger, |
@@ -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 | * @param string $domain |
| 11 | 11 | */ |
| 12 | - public function __construct( string $domain ) { |
|
| 12 | + public function __construct ( string $domain ) { |
|
| 13 | 13 | $this->domain = $domain; |
| 14 | 14 | } |
| 15 | 15 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param array $params |
| 18 | 18 | * @return RequestBase |
| 19 | 19 | */ |
| 20 | - public function newFromParams( array $params ) : RequestBase { |
|
| 20 | + public function newFromParams ( array $params ) : RequestBase { |
|
| 21 | 21 | if ( extension_loaded( 'curl' ) ) { |
| 22 | 22 | $ret = new CurlRequest( $params, $this->domain ); |
| 23 | 23 | } else { |
@@ -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 | |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** @var string */ |
| 33 | 33 | protected $method = self::METHOD_GET; |
| 34 | 34 | /** @var string[] */ |
| 35 | - protected $newCookies = []; |
|
| 35 | + protected $newCookies = [ ]; |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @private Use RequestFactory |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param array $params |
| 41 | 41 | * @param string $domain |
| 42 | 42 | */ |
| 43 | - public function __construct( array $params, string $domain ) { |
|
| 43 | + public function __construct ( array $params, string $domain ) { |
|
| 44 | 44 | $this->params = [ 'format' => 'json' ] + $params; |
| 45 | 45 | $this->url = $domain; |
| 46 | 46 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return self For chaining |
| 52 | 52 | */ |
| 53 | - public function setPost() : self { |
|
| 53 | + public function setPost () : self { |
|
| 54 | 54 | $this->method = self::METHOD_POST; |
| 55 | 55 | return $this; |
| 56 | 56 | } |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | * @todo Return an iterable object which automatically continues the query only if the last |
| 63 | 63 | * entry available is reached. |
| 64 | 64 | */ |
| 65 | - public function execute() : \stdClass { |
|
| 65 | + public function execute () : \stdClass { |
|
| 66 | 66 | $curParams = $this->params; |
| 67 | - $sets = []; |
|
| 67 | + $sets = [ ]; |
|
| 68 | 68 | do { |
| 69 | 69 | $res = $this->makeRequestInternal( $curParams ); |
| 70 | 70 | |
| 71 | 71 | $this->handleErrorAndWarnings( $res ); |
| 72 | - $sets[] = $res; |
|
| 72 | + $sets[ ] = $res; |
|
| 73 | 73 | |
| 74 | 74 | $finished = true; |
| 75 | 75 | if ( isset( $res->continue ) ) { |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | * @param array $params |
| 88 | 88 | * @return \stdClass |
| 89 | 89 | */ |
| 90 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
| 90 | + private function makeRequestInternal ( array $params ) : \stdClass { |
|
| 91 | 91 | if ( $this->method === self::METHOD_POST ) { |
| 92 | - $params['maxlag'] = self::MAXLAG; |
|
| 92 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
| 93 | 93 | } |
| 94 | 94 | $query = http_build_query( $params ); |
| 95 | 95 | |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | * @param string $params |
| 106 | 106 | * @return string |
| 107 | 107 | */ |
| 108 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
| 108 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
| 109 | 109 | |
| 110 | 110 | /** |
| 111 | 111 | * After a request, set cookies for the next ones |
| 112 | 112 | * |
| 113 | 113 | * @param array $cookies |
| 114 | 114 | */ |
| 115 | - protected function setCookies( array $cookies ) : void { |
|
| 115 | + protected function setCookies ( array $cookies ) : void { |
|
| 116 | 116 | foreach ( $cookies as $cookie ) { |
| 117 | 117 | $bits = explode( ';', $cookie ); |
| 118 | - [ $name, $value ] = explode( '=', $bits[0] ); |
|
| 118 | + [ $name, $value ] = explode( '=', $bits[ 0 ] ); |
|
| 119 | 119 | self::$cookiesToSet[ $name ] = $value; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param \stdClass $res |
| 127 | 127 | * @return APIRequestException |
| 128 | 128 | */ |
| 129 | - private function getException( \stdClass $res ) : APIRequestException { |
|
| 129 | + private function getException ( \stdClass $res ) : APIRequestException { |
|
| 130 | 130 | switch ( $res->error->code ) { |
| 131 | 131 | case 'missingtitle': |
| 132 | 132 | $ex = new MissingPageException; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param \stdClass $res |
| 150 | 150 | * @throws APIRequestException |
| 151 | 151 | */ |
| 152 | - protected function handleErrorAndWarnings( \stdClass $res ) : void { |
|
| 152 | + protected function handleErrorAndWarnings ( \stdClass $res ) : void { |
|
| 153 | 153 | if ( isset( $res->error ) ) { |
| 154 | 154 | throw $this->getException( $res ); |
| 155 | 155 | } elseif ( isset( $res->warnings ) ) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param \stdClass[] $sets |
| 166 | 166 | * @return \stdClass |
| 167 | 167 | */ |
| 168 | - private function mergeSets( array $sets ) : \stdClass { |
|
| 168 | + private function mergeSets ( array $sets ) : \stdClass { |
|
| 169 | 169 | // Use the first set as template |
| 170 | 170 | $ret = array_shift( $sets ); |
| 171 | 171 | |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param array|\stdClass $second |
| 183 | 183 | * @return array|\stdClass array |
| 184 | 184 | */ |
| 185 | - private function recursiveMerge( $first, $second ) { |
|
| 185 | + private function recursiveMerge ( $first, $second ) { |
|
| 186 | 186 | $ret = $first; |
| 187 | 187 | if ( is_array( $second ) ) { |
| 188 | 188 | $ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second; |
@@ -200,14 +200,14 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return array |
| 202 | 202 | */ |
| 203 | - protected function getHeaders() :array { |
|
| 203 | + protected function getHeaders () :array { |
|
| 204 | 204 | $ret = self::HEADERS; |
| 205 | 205 | if ( self::$cookiesToSet ) { |
| 206 | - $cookies = []; |
|
| 206 | + $cookies = [ ]; |
|
| 207 | 207 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
| 208 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 208 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
| 209 | 209 | } |
| 210 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 210 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 211 | 211 | } |
| 212 | 212 | return $ret; |
| 213 | 213 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param array $headers |
| 219 | 219 | * @return string |
| 220 | 220 | */ |
| 221 | - protected function buildHeadersString( array $headers ) : string { |
|
| 221 | + protected function buildHeadersString ( array $headers ) : string { |
|
| 222 | 222 | $ret = ''; |
| 223 | 223 | foreach ( $headers as $header ) { |
| 224 | 224 | $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; |
| 4 | 4 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param MessageProvider $mp |
| 26 | 26 | * @param PageBotList $pbl |
| 27 | 27 | */ |
| 28 | - public function __construct( |
|
| 28 | + public function __construct ( |
|
| 29 | 29 | LoggerInterface $logger, |
| 30 | 30 | WikiGroup $wikiGroup, |
| 31 | 31 | MessageProvider $mp, |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $mode |
| 44 | 44 | * @param string|null $name |
| 45 | 45 | */ |
| 46 | - private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) : void { |
|
| 46 | + private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) : void { |
|
| 47 | 47 | $activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name"; |
| 48 | 48 | $this->logger->info( "Running $activity" ); |
| 49 | 49 | $manager = new TaskManager( |
@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | $base = "Execution of $activity"; |
| 57 | 57 | if ( $res->isOK() ) { |
| 58 | 58 | $msg = $res->getStatus() === TaskResult::STATUS_NOTHING ? |
| 59 | - ': nothing to do' : |
|
| 60 | - ' completed successfully'; |
|
| 59 | + ': nothing to do' : ' completed successfully'; |
|
| 61 | 60 | $this->logger->info( $base . $msg ); |
| 62 | 61 | } else { |
| 63 | 62 | $this->logger->error( "$base failed.\n$res" ); |
@@ -67,7 +66,7 @@ discard block |
||
| 67 | 66 | /** |
| 68 | 67 | * Entry point for the whole process |
| 69 | 68 | */ |
| 70 | - public function runAll() : void { |
|
| 69 | + public function runAll () : void { |
|
| 71 | 70 | $this->run(); |
| 72 | 71 | } |
| 73 | 72 | |
@@ -76,7 +75,7 @@ discard block |
||
| 76 | 75 | * |
| 77 | 76 | * @param string $task |
| 78 | 77 | */ |
| 79 | - public function runTask( string $task ) : void { |
|
| 78 | + public function runTask ( string $task ) : void { |
|
| 80 | 79 | $this->run( TaskManager::MODE_TASK, $task ); |
| 81 | 80 | } |
| 82 | 81 | |
@@ -85,7 +84,7 @@ discard block |
||
| 85 | 84 | * |
| 86 | 85 | * @param string $subtask |
| 87 | 86 | */ |
| 88 | - public function runSubtask( string $subtask ) : void { |
|
| 87 | + public function runSubtask ( string $subtask ) : void { |
|
| 89 | 88 | $this->run( TaskManager::MODE_SUBTASK, $subtask ); |
| 90 | 89 | } |
| 91 | 90 | } |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** @var User[]|null */ |
| 15 | 15 | private $processUsers; |
| 16 | 16 | /** @var PageRiconferma[] */ |
| 17 | - private $createdPages = []; |
|
| 17 | + private $createdPages = [ ]; |
|
| 18 | 18 | /** @var PageRiconferma[]|null */ |
| 19 | 19 | private $openPages; |
| 20 | 20 | /** @var PageRiconferma[]|null */ |
@@ -25,9 +25,9 @@ discard block |
||
| 25 | 25 | * |
| 26 | 26 | * @return User[] |
| 27 | 27 | */ |
| 28 | - public function getUsersToProcess() : array { |
|
| 28 | + public function getUsersToProcess () : array { |
|
| 29 | 29 | if ( $this->processUsers === null ) { |
| 30 | - $this->processUsers = []; |
|
| 30 | + $this->processUsers = [ ]; |
|
| 31 | 31 | foreach ( $this->getBotList()->getAdminsList() as $name => $userInfo ) { |
| 32 | 32 | if ( $this->shouldAddUser( $userInfo ) ) { |
| 33 | 33 | $this->processUsers[ $name ] = new User( $userInfo, $this->getWiki() ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param UserInfo $ui |
| 45 | 45 | * @return bool |
| 46 | 46 | */ |
| 47 | - private function shouldAddUser( UserInfo $ui ) : bool { |
|
| 47 | + private function shouldAddUser ( UserInfo $ui ) : bool { |
|
| 48 | 48 | $timestamp = $this->getBotList()->getOverrideTimestamp( $ui ); |
| 49 | 49 | $override = $timestamp !== null; |
| 50 | 50 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return PageRiconferma[] |
| 64 | 64 | */ |
| 65 | - public function getOpenPages() : array { |
|
| 65 | + public function getOpenPages () : array { |
|
| 66 | 66 | if ( $this->openPages === null ) { |
| 67 | - $this->openPages = []; |
|
| 67 | + $this->openPages = [ ]; |
|
| 68 | 68 | $mainTitle = $this->getOpt( 'main-page-title' ); |
| 69 | 69 | $params = [ |
| 70 | 70 | 'action' => 'query', |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $pages = $this->getRequestFactory()->newFromParams( $params )->execute()->query->pages; |
| 79 | 79 | foreach ( reset( $pages )->templates as $page ) { |
| 80 | 80 | if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) { |
| 81 | - $this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
| 81 | + $this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return PageRiconferma[] |
| 93 | 93 | */ |
| 94 | - public function getPagesToClose() : array { |
|
| 94 | + public function getPagesToClose () : array { |
|
| 95 | 95 | if ( $this->pagesToClose === null ) { |
| 96 | - $this->pagesToClose = []; |
|
| 96 | + $this->pagesToClose = [ ]; |
|
| 97 | 97 | foreach ( $this->getOpenPages() as $page ) { |
| 98 | 98 | if ( time() > $page->getEndTimestamp() ) { |
| 99 | - $this->pagesToClose[] = $page; |
|
| 99 | + $this->pagesToClose[ ] = $page; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -108,21 +108,21 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param string $name |
| 110 | 110 | */ |
| 111 | - public function removeUser( string $name ) : void { |
|
| 111 | + public function removeUser ( string $name ) : void { |
|
| 112 | 112 | unset( $this->processUsers[ $name ] ); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * @return PageRiconferma[] |
| 117 | 117 | */ |
| 118 | - public function getCreatedPages() : array { |
|
| 118 | + public function getCreatedPages () : array { |
|
| 119 | 119 | return $this->createdPages; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /** |
| 123 | 123 | * @param PageRiconferma $page |
| 124 | 124 | */ |
| 125 | - public function addCreatedPage( PageRiconferma $page ) : void { |
|
| 126 | - $this->createdPages[] = $page; |
|
| 125 | + public function addCreatedPage ( PageRiconferma $page ) : void { |
|
| 126 | + $this->createdPages[ ] = $page; |
|
| 127 | 127 | } |
| 128 | 128 | } |
@@ -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 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param MessageProvider $mp |
| 37 | 37 | * @param PageBotList $pbl |
| 38 | 38 | */ |
| 39 | - public function __construct( |
|
| 39 | + public function __construct ( |
|
| 40 | 40 | LoggerInterface $logger, |
| 41 | 41 | WikiGroup $wikiGroup, |
| 42 | 42 | MessageProvider $mp, |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return LoggerInterface |
| 54 | 54 | */ |
| 55 | - protected function getLogger() : LoggerInterface { |
|
| 55 | + protected function getLogger () : LoggerInterface { |
|
| 56 | 56 | return $this->logger; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | 60 | * @inheritDoc |
| 61 | 61 | */ |
| 62 | - public function setLogger( LoggerInterface $logger ) : void { |
|
| 62 | + public function setLogger ( LoggerInterface $logger ) : void { |
|
| 63 | 63 | $this->logger = $logger; |
| 64 | 64 | } |
| 65 | 65 | |
@@ -69,21 +69,21 @@ discard block |
||
| 69 | 69 | * @param string $optname |
| 70 | 70 | * @return mixed |
| 71 | 71 | */ |
| 72 | - protected function getOpt( string $optname ) { |
|
| 72 | + protected function getOpt ( string $optname ) { |
|
| 73 | 73 | return $this->getConfig()->get( $optname ); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @return Config |
| 78 | 78 | */ |
| 79 | - protected function getConfig() : Config { |
|
| 79 | + protected function getConfig () : Config { |
|
| 80 | 80 | return $this->config; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @param Config $cfg |
| 85 | 85 | */ |
| 86 | - protected function setConfig( Config $cfg ) : void { |
|
| 86 | + protected function setConfig ( Config $cfg ) : void { |
|
| 87 | 87 | $this->config = $cfg; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -91,35 +91,35 @@ discard block |
||
| 91 | 91 | * Shorthand |
| 92 | 92 | * @return Wiki |
| 93 | 93 | */ |
| 94 | - protected function getWiki() : Wiki { |
|
| 94 | + protected function getWiki () : Wiki { |
|
| 95 | 95 | return $this->getWikiGroup()->getMainWiki(); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
| 99 | 99 | * @return WikiGroup |
| 100 | 100 | */ |
| 101 | - protected function getWikiGroup() : WikiGroup { |
|
| 101 | + protected function getWikiGroup () : WikiGroup { |
|
| 102 | 102 | return $this->wikiGroup; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | 106 | * @param WikiGroup $wikiGroup |
| 107 | 107 | */ |
| 108 | - protected function setWikiGroup( WikiGroup $wikiGroup ) : void { |
|
| 108 | + protected function setWikiGroup ( WikiGroup $wikiGroup ) : void { |
|
| 109 | 109 | $this->wikiGroup = $wikiGroup; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * @return MessageProvider |
| 114 | 114 | */ |
| 115 | - protected function getMessageProvider() : MessageProvider { |
|
| 115 | + protected function getMessageProvider () : MessageProvider { |
|
| 116 | 116 | return $this->messageProvider; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * @param MessageProvider $mp |
| 121 | 121 | */ |
| 122 | - protected function setMessageProvider( MessageProvider $mp ) : void { |
|
| 122 | + protected function setMessageProvider ( MessageProvider $mp ) : void { |
|
| 123 | 123 | $this->messageProvider = $mp; |
| 124 | 124 | } |
| 125 | 125 | |
@@ -129,21 +129,21 @@ discard block |
||
| 129 | 129 | * @param string $key |
| 130 | 130 | * @return Message |
| 131 | 131 | */ |
| 132 | - protected function msg( string $key ) : Message { |
|
| 132 | + protected function msg ( string $key ) : Message { |
|
| 133 | 133 | return $this->messageProvider->getMessage( $key ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * @return PageBotList |
| 138 | 138 | */ |
| 139 | - public function getBotList() : PageBotList { |
|
| 139 | + public function getBotList () : PageBotList { |
|
| 140 | 140 | return $this->pageBotList; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * @return RequestFactory |
| 145 | 145 | */ |
| 146 | - public function getRequestFactory() : RequestFactory { |
|
| 146 | + public function getRequestFactory () : RequestFactory { |
|
| 147 | 147 | return $this->getWiki()->getRequestFactory(); |
| 148 | 148 | } |
| 149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $title |
| 154 | 154 | * @return Page |
| 155 | 155 | */ |
| 156 | - protected function getPage( string $title ) : Page { |
|
| 156 | + protected function getPage ( string $title ) : Page { |
|
| 157 | 157 | return new Page( $title, $this->getWiki() ); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param string $name |
| 164 | 164 | * @return User |
| 165 | 165 | */ |
| 166 | - protected function getUser( string $name ) : User { |
|
| 166 | + protected function getUser ( string $name ) : User { |
|
| 167 | 167 | $ui = $this->getBotList()->getUserInfo( $name ); |
| 168 | 168 | return new User( $ui, $this->getWiki() ); |
| 169 | 169 | } |
@@ -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 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @param string $name |
| 18 | 18 | * @param array $info |
| 19 | 19 | */ |
| 20 | - public function __construct( string $name, array $info ) { |
|
| 20 | + public function __construct ( string $name, array $info ) { |
|
| 21 | 21 | $this->name = $name; |
| 22 | 22 | $this->info = $info; |
| 23 | 23 | } |
@@ -25,35 +25,35 @@ discard block |
||
| 25 | 25 | /** |
| 26 | 26 | * @return string |
| 27 | 27 | */ |
| 28 | - public function getName() : string { |
|
| 28 | + public function getName () : string { |
|
| 29 | 29 | return $this->name; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * @return array |
| 34 | 34 | */ |
| 35 | - public function getInfo() : array { |
|
| 35 | + public function getInfo () : array { |
|
| 36 | 36 | return $this->info; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * @return array |
| 41 | 41 | */ |
| 42 | - public function extractGroups() : array { |
|
| 42 | + public function extractGroups () : array { |
|
| 43 | 43 | return array_keys( $this->extractGroupsWithDates() ); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @return array |
| 48 | 48 | */ |
| 49 | - public function extractGroupsWithDates() : array { |
|
| 49 | + public function extractGroupsWithDates () : array { |
|
| 50 | 50 | return array_intersect_key( $this->getInfo(), array_fill_keys( self::GROUP_KEYS, 1 ) ); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - public function getAliases() : array { |
|
| 57 | - return $this->getInfo()['aliases'] ?? []; |
|
| 56 | + public function getAliases () : array { |
|
| 57 | + return $this->getInfo()[ 'aliases' ] ?? [ ]; |
|
| 58 | 58 | } |
| 59 | 59 | } |