@@ -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,15 +14,15 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - protected function getSubtasksMap(): array { |
|
| 17 | + protected function getSubtasksMap (): array { |
|
| 18 | 18 | // Everything is done here. |
| 19 | - return []; |
|
| 19 | + return [ ]; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @inheritDoc |
| 24 | 24 | */ |
| 25 | - public function runInternal(): int { |
|
| 25 | + public function runInternal (): int { |
|
| 26 | 26 | $pages = $this->getDataProvider()->getOpenPages(); |
| 27 | 27 | |
| 28 | 28 | if ( !$pages ) { |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | * @param PageRiconferma[] $pages |
| 37 | 37 | * @return int a STATUS_* constant |
| 38 | 38 | */ |
| 39 | - protected function processPages( array $pages ): int { |
|
| 40 | - $donePages = []; |
|
| 39 | + protected function processPages ( array $pages ): int { |
|
| 40 | + $donePages = [ ]; |
|
| 41 | 41 | foreach ( $pages as $page ) { |
| 42 | 42 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 43 | 43 | $this->openVote( $page ); |
| 44 | 44 | $this->updateBasePage( $page ); |
| 45 | - $donePages[] = $page; |
|
| 45 | + $donePages[ ] = $page; |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param PageRiconferma $page |
| 62 | 62 | */ |
| 63 | - protected function openVote( PageRiconferma $page ): void { |
|
| 63 | + protected function openVote ( PageRiconferma $page ): void { |
|
| 64 | 64 | $this->getLogger()->info( "Starting vote on $page" ); |
| 65 | 65 | |
| 66 | 66 | $content = $page->getContent(); |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * @see SimpleUpdates::updateVotazioni() |
| 100 | 100 | * @see OpenUpdates::addToVotazioni() |
| 101 | 101 | */ |
| 102 | - protected function updateVotazioni( array $pages ): void { |
|
| 102 | + protected function updateVotazioni ( array $pages ): void { |
|
| 103 | 103 | $votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) ); |
| 104 | 104 | |
| 105 | - $users = []; |
|
| 105 | + $users = [ ]; |
|
| 106 | 106 | foreach ( $pages as $page ) { |
| 107 | - $users[] = $this->getUser( $page->getUserName() ); |
|
| 107 | + $users[ ] = $this->getUser( $page->getUserName() ); |
|
| 108 | 108 | } |
| 109 | 109 | $usersReg = RegexUtils::regexFromArray( '!', ...$users ); |
| 110 | 110 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @param PageRiconferma $page |
| 139 | 139 | * @see \BotRiconferme\Task\Subtask\ClosePages::updateBasePage() |
| 140 | 140 | */ |
| 141 | - protected function updateBasePage( PageRiconferma $page ): void { |
|
| 141 | + protected function updateBasePage ( PageRiconferma $page ): void { |
|
| 142 | 142 | $this->getLogger()->info( "Updating base page for $page" ); |
| 143 | 143 | |
| 144 | 144 | if ( $page->getNum() === 1 ) { |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @see SimpleUpdates::updateNews() |
| 166 | 166 | * @see OpenUpdates::addToNews() |
| 167 | 167 | */ |
| 168 | - protected function updateNews( int $amount ): void { |
|
| 168 | + protected function updateNews ( int $amount ): void { |
|
| 169 | 169 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 170 | 170 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
| 171 | 171 | |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $newTac = ( (int)$newsPage->getMatch( $regTac )[2] - $amount ) ?: ''; |
|
| 184 | - $newVot = ( (int)$newsPage->getMatch( $regVot )[2] + $amount ) ?: ''; |
|
| 183 | + $newTac = ( (int)$newsPage->getMatch( $regTac )[ 2 ] - $amount ) ?: ''; |
|
| 184 | + $newVot = ( (int)$newsPage->getMatch( $regVot )[ 2 ] + $amount ) ?: ''; |
|
| 185 | 185 | |
| 186 | 186 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 187 | 187 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |
@@ -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 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @inheritDoc |
| 24 | 24 | */ |
| 25 | - protected function getSubtasksMap(): array { |
|
| 25 | + protected function getSubtasksMap (): array { |
|
| 26 | 26 | // Everything is done here. |
| 27 | - return []; |
|
| 27 | + return [ ]; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @inheritDoc |
| 32 | 32 | */ |
| 33 | - public function runInternal(): int { |
|
| 33 | + public function runInternal (): int { |
|
| 34 | 34 | $this->actualList = $this->getActualAdmins(); |
| 35 | 35 | $pageBotList = $this->getBotList(); |
| 36 | 36 | $this->botList = $pageBotList->getDecodedContent(); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return string[][] |
| 59 | 59 | * @phan-return array<string,string[]> |
| 60 | 60 | */ |
| 61 | - protected function getActualAdmins(): array { |
|
| 61 | + protected function getActualAdmins (): array { |
|
| 62 | 62 | $params = [ |
| 63 | 63 | 'action' => 'query', |
| 64 | 64 | 'list' => 'allusers', |
@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | * @return string[][] |
| 77 | 77 | * @phan-return array<string,string[]> |
| 78 | 78 | */ |
| 79 | - protected function extractAdmins( Generator $data ): array { |
|
| 80 | - $ret = []; |
|
| 79 | + protected function extractAdmins ( Generator $data ): array { |
|
| 80 | + $ret = [ ]; |
|
| 81 | 81 | $blacklist = $this->getOpt( 'exclude-admins' ); |
| 82 | 82 | foreach ( $data as $u ) { |
| 83 | 83 | if ( in_array( $u->name, $blacklist, true ) ) { |
@@ -94,16 +94,16 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return string[][] |
| 96 | 96 | */ |
| 97 | - protected function getMissingGroups(): array { |
|
| 98 | - $missing = []; |
|
| 97 | + protected function getMissingGroups (): array { |
|
| 98 | + $missing = [ ]; |
|
| 99 | 99 | foreach ( $this->actualList as $adm => $groups ) { |
| 100 | - $curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) ); |
|
| 100 | + $curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) ); |
|
| 101 | 101 | |
| 102 | 102 | foreach ( $curMissing as $group ) { |
| 103 | 103 | try { |
| 104 | 104 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 105 | 105 | } catch ( TaskException $e ) { |
| 106 | - $this->errors[] = $e->getMessage(); |
|
| 106 | + $this->errors[ ] = $e->getMessage(); |
|
| 107 | 107 | } |
| 108 | 108 | } |
| 109 | 109 | } |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @return string |
| 119 | 119 | * @throws TaskException |
| 120 | 120 | */ |
| 121 | - protected function getFlagDate( string $admin, string $group ): string { |
|
| 121 | + protected function getFlagDate ( string $admin, string $group ): string { |
|
| 122 | 122 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 123 | 123 | |
| 124 | 124 | $wiki = $this->getWiki(); |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $group |
| 154 | 154 | * @return string|null |
| 155 | 155 | */ |
| 156 | - private function extractTimestamp( Generator $data, string $group ): ?string { |
|
| 156 | + private function extractTimestamp ( Generator $data, string $group ): ?string { |
|
| 157 | 157 | $ts = null; |
| 158 | 158 | foreach ( $data as $entry ) { |
| 159 | 159 | if ( |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | * |
| 173 | 173 | * @return string[][] |
| 174 | 174 | */ |
| 175 | - protected function getExtraGroups(): array { |
|
| 176 | - $extra = []; |
|
| 175 | + protected function getExtraGroups (): array { |
|
| 176 | + $extra = [ ]; |
|
| 177 | 177 | foreach ( $this->botList as $name => $groups ) { |
| 178 | 178 | $groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ); |
| 179 | 179 | if ( !isset( $this->actualList[ $name ] ) ) { |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param string[] $names |
| 190 | 190 | * @return Generator |
| 191 | 191 | */ |
| 192 | - private function getRenameEntries( array $names ): Generator { |
|
| 192 | + private function getRenameEntries ( array $names ): Generator { |
|
| 193 | 193 | $titles = array_map( static function ( string $x ): string { |
| 194 | 194 | return "Utente:$x"; |
| 195 | 195 | }, $names ); |
@@ -213,14 +213,14 @@ discard block |
||
| 213 | 213 | * @param string[] $names |
| 214 | 214 | * @return string[] [ old_name => new_name ] |
| 215 | 215 | */ |
| 216 | - protected function getRenamedUsers( array $names ): array { |
|
| 216 | + protected function getRenamedUsers ( array $names ): array { |
|
| 217 | 217 | if ( !$names ) { |
| 218 | - return []; |
|
| 218 | + return [ ]; |
|
| 219 | 219 | } |
| 220 | 220 | $this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) ); |
| 221 | 221 | |
| 222 | 222 | $data = $this->getRenameEntries( $names ); |
| 223 | - $ret = []; |
|
| 223 | + $ret = [ ]; |
|
| 224 | 224 | foreach ( $data as $entry ) { |
| 225 | 225 | // 1 month is arbitrary |
| 226 | 226 | if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) { |
@@ -239,18 +239,18 @@ discard block |
||
| 239 | 239 | * @phan-param array<string,array<string,string|string[]>> $newContent |
| 240 | 240 | * @param string[][] $removed |
| 241 | 241 | */ |
| 242 | - private function handleRenames( array &$newContent, array $removed ): void { |
|
| 242 | + private function handleRenames ( array &$newContent, array $removed ): void { |
|
| 243 | 243 | $renameMap = $this->getRenamedUsers( array_keys( $removed ) ); |
| 244 | 244 | foreach ( $removed as $oldName => $info ) { |
| 245 | 245 | if ( |
| 246 | 246 | array_key_exists( $oldName, $renameMap ) && |
| 247 | - array_key_exists( $renameMap[$oldName], $newContent ) |
|
| 247 | + array_key_exists( $renameMap[ $oldName ], $newContent ) |
|
| 248 | 248 | ) { |
| 249 | 249 | // This user was renamed! Add this name as alias, if they're still listed |
| 250 | 250 | $newName = $renameMap[ $oldName ]; |
| 251 | 251 | $this->getLogger()->info( "Found rename $oldName -> $newName" ); |
| 252 | - $aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) ); |
|
| 253 | - $newContent[ $newName ]['aliases'] = $aliases; |
|
| 252 | + $aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) ); |
|
| 253 | + $newContent[ $newName ][ 'aliases' ] = $aliases; |
|
| 254 | 254 | // Transfer overrides to the new name. |
| 255 | 255 | $overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] ); |
| 256 | 256 | $newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides ); |
@@ -265,12 +265,12 @@ discard block |
||
| 265 | 265 | * @param string[][] $extra |
| 266 | 266 | * @return string[][] Removed users |
| 267 | 267 | */ |
| 268 | - private function handleExtraAndMissing( |
|
| 268 | + private function handleExtraAndMissing ( |
|
| 269 | 269 | array &$newContent, |
| 270 | 270 | array $missing, |
| 271 | 271 | array $extra |
| 272 | 272 | ): array { |
| 273 | - $removed = []; |
|
| 273 | + $removed = [ ]; |
|
| 274 | 274 | foreach ( $newContent as $user => $groups ) { |
| 275 | 275 | if ( isset( $missing[ $user ] ) ) { |
| 276 | 276 | $newContent[ $user ] = array_merge( $groups, $missing[ $user ] ); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) { |
| 281 | 281 | $newContent[ $user ] = $newGroups; |
| 282 | 282 | } else { |
| 283 | - $removed[$user] = $newContent[$user]; |
|
| 283 | + $removed[ $user ] = $newContent[ $user ]; |
|
| 284 | 284 | unset( $newContent[ $user ] ); |
| 285 | 285 | } |
| 286 | 286 | } |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @param string[][] $extra |
| 298 | 298 | * @return array[] |
| 299 | 299 | */ |
| 300 | - protected function getNewContent( array $missing, array $extra ): array { |
|
| 300 | + protected function getNewContent ( array $missing, array $extra ): array { |
|
| 301 | 301 | $newContent = $this->botList; |
| 302 | 302 | |
| 303 | 303 | $removed = $this->handleExtraAndMissing( $newContent, $missing, $extra ); |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | * |
| 317 | 317 | * @param array[] &$newContent |
| 318 | 318 | */ |
| 319 | - protected function removeOverrides( array &$newContent ): void { |
|
| 320 | - $removed = []; |
|
| 319 | + protected function removeOverrides ( array &$newContent ): void { |
|
| 320 | + $removed = [ ]; |
|
| 321 | 321 | foreach ( $newContent as $user => $groups ) { |
| 322 | 322 | if ( PageBotList::isOverrideExpired( $groups ) ) { |
| 323 | 323 | unset( $newContent[ $user ][ 'override' ] ); |
| 324 | - $removed[] = $user; |
|
| 324 | + $removed[ ] = $user; |
|
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
@@ -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 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function runInternal(): int { |
|
| 17 | + public function runInternal (): int { |
|
| 18 | 18 | $orderedList = [ |
| 19 | 19 | 'create-pages', |
| 20 | 20 | 'open-updates', |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @inheritDoc |
| 34 | 34 | */ |
| 35 | - protected function getSubtasksMap(): array { |
|
| 35 | + protected function getSubtasksMap (): array { |
|
| 36 | 36 | return [ |
| 37 | 37 | 'create-pages' => CreatePages::class, |
| 38 | 38 | 'open-updates' => OpenUpdates::class, |
@@ -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 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param MessageProvider $mp |
| 73 | 73 | * @param PageBotList $pbl |
| 74 | 74 | */ |
| 75 | - public function __construct( |
|
| 75 | + public function __construct ( |
|
| 76 | 76 | LoggerInterface $logger, |
| 77 | 77 | WikiGroup $wikiGroup, |
| 78 | 78 | MessageProvider $mp, |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string[] $tasks Only used in MODE_TASK and MODE_SUBTASK |
| 98 | 98 | * @return TaskResult |
| 99 | 99 | */ |
| 100 | - public function run( string $mode, array $tasks = [] ): TaskResult { |
|
| 100 | + public function run ( string $mode, array $tasks = [ ] ): TaskResult { |
|
| 101 | 101 | if ( $mode === self::MODE_COMPLETE ) { |
| 102 | 102 | return $this->runTasks( self::FULL_RUN_ORDERED ); |
| 103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param string[] $tasks |
| 114 | 114 | * @return TaskResult |
| 115 | 115 | */ |
| 116 | - private function runTasks( array $tasks ): TaskResult { |
|
| 116 | + private function runTasks ( array $tasks ): TaskResult { |
|
| 117 | 117 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
| 118 | 118 | do { |
| 119 | 119 | $res->merge( $this->runTask( current( $tasks ) ) ); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $name |
| 129 | 129 | * @return TaskResult |
| 130 | 130 | */ |
| 131 | - protected function runTask( string $name ): TaskResult { |
|
| 131 | + protected function runTask ( string $name ): TaskResult { |
|
| 132 | 132 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 133 | 133 | throw new InvalidArgumentException( "'$name' is not a valid task." ); |
| 134 | 134 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string[] $subtasks |
| 143 | 143 | * @return TaskResult |
| 144 | 144 | */ |
| 145 | - private function runSubtasks( array $subtasks ): TaskResult { |
|
| 145 | + private function runSubtasks ( array $subtasks ): TaskResult { |
|
| 146 | 146 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
| 147 | 147 | do { |
| 148 | 148 | $res->merge( $this->runSubtask( current( $subtasks ) ) ); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $name |
| 158 | 158 | * @return TaskResult |
| 159 | 159 | */ |
| 160 | - protected function runSubtask( string $name ): TaskResult { |
|
| 160 | + protected function runSubtask ( string $name ): TaskResult { |
|
| 161 | 161 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 162 | 162 | throw new InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 163 | 163 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param string $name |
| 173 | 173 | * @return Task |
| 174 | 174 | */ |
| 175 | - private function getTaskInstance( string $name ): Task { |
|
| 175 | + private function getTaskInstance ( string $name ): Task { |
|
| 176 | 176 | $class = self::TASKS_MAP[ $name ]; |
| 177 | 177 | return new $class( |
| 178 | 178 | $this->logger, |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param string $class |
| 190 | 190 | * @return Subtask |
| 191 | 191 | */ |
| 192 | - private function getSubtaskInstance( string $class ): Subtask { |
|
| 192 | + private function getSubtaskInstance ( string $class ): Subtask { |
|
| 193 | 193 | return new $class( |
| 194 | 194 | $this->logger, |
| 195 | 195 | $this->wikiGroup, |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param Wiki $wiki |
| 22 | 22 | * @param string $msgTitle |
| 23 | 23 | */ |
| 24 | - public function __construct( Wiki $wiki, string $msgTitle ) { |
|
| 24 | + public function __construct ( Wiki $wiki, string $msgTitle ) { |
|
| 25 | 25 | $this->wiki = $wiki; |
| 26 | 26 | $this->msgTitle = $msgTitle; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @throws MessagesPageDoesNotExistException |
| 31 | 31 | */ |
| 32 | - private function grabWikiMessages(): void { |
|
| 32 | + private function grabWikiMessages (): void { |
|
| 33 | 33 | if ( self::$messages !== null ) { |
| 34 | 34 | return; |
| 35 | 35 | } |
@@ -46,12 +46,12 @@ discard block |
||
| 46 | 46 | * @return Message |
| 47 | 47 | * @throws MessageNotFoundException |
| 48 | 48 | */ |
| 49 | - public function getMessage( string $key ): Message { |
|
| 49 | + public function getMessage ( string $key ): Message { |
|
| 50 | 50 | $this->grabWikiMessages(); |
| 51 | 51 | if ( !isset( self::$messages[ $key ] ) ) { |
| 52 | 52 | throw new MessageNotFoundException( "Message '$key' does not exist." ); |
| 53 | 53 | } |
| 54 | 54 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
| 55 | - return new Message( self::$messages[$key] ); |
|
| 55 | + return new Message( self::$messages[ $key ] ); |
|
| 56 | 56 | } |
| 57 | 57 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\TaskHelper; |
| 4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** @var User[]|null */ |
| 16 | 16 | private $processUsers; |
| 17 | 17 | /** @var PageRiconferma[] */ |
| 18 | - private $createdPages = []; |
|
| 18 | + private $createdPages = [ ]; |
|
| 19 | 19 | /** @var PageRiconferma[]|null */ |
| 20 | 20 | private $openPages; |
| 21 | 21 | /** @var PageRiconferma[]|null */ |
@@ -26,9 +26,9 @@ discard block |
||
| 26 | 26 | * |
| 27 | 27 | * @return User[] |
| 28 | 28 | */ |
| 29 | - public function getUsersToProcess(): array { |
|
| 29 | + public function getUsersToProcess (): array { |
|
| 30 | 30 | if ( $this->processUsers === null ) { |
| 31 | - $this->processUsers = []; |
|
| 31 | + $this->processUsers = [ ]; |
|
| 32 | 32 | foreach ( $this->getBotList()->getAdminsList() as $name => $userInfo ) { |
| 33 | 33 | if ( $this->shouldAddUser( $userInfo ) ) { |
| 34 | 34 | $this->processUsers[ $name ] = new User( $userInfo, $this->getWiki() ); |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param UserInfo $ui |
| 46 | 46 | * @return bool |
| 47 | 47 | */ |
| 48 | - private function shouldAddUser( UserInfo $ui ): bool { |
|
| 48 | + private function shouldAddUser ( UserInfo $ui ): bool { |
|
| 49 | 49 | $timestamp = $this->getBotList()->getOverrideTimestamp( $ui ); |
| 50 | 50 | $override = $timestamp !== null; |
| 51 | 51 | |
@@ -63,9 +63,9 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @return PageRiconferma[] |
| 65 | 65 | */ |
| 66 | - public function getOpenPages(): array { |
|
| 66 | + public function getOpenPages (): array { |
|
| 67 | 67 | if ( $this->openPages === null ) { |
| 68 | - $this->openPages = []; |
|
| 68 | + $this->openPages = [ ]; |
|
| 69 | 69 | $mainTitle = $this->getOpt( 'main-page-title' ); |
| 70 | 70 | $params = [ |
| 71 | 71 | 'action' => 'query', |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | $pages = $this->getRequestFactory()->newFromParams( $params )->executeAsQuery(); |
| 80 | 80 | foreach ( $pages->current()->templates as $page ) { |
| 81 | 81 | if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) { |
| 82 | - $this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
| 82 | + $this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return PageRiconferma[] |
| 94 | 94 | */ |
| 95 | - public function getPagesToClose(): array { |
|
| 95 | + public function getPagesToClose (): array { |
|
| 96 | 96 | if ( $this->pagesToClose === null ) { |
| 97 | - $this->pagesToClose = []; |
|
| 97 | + $this->pagesToClose = [ ]; |
|
| 98 | 98 | foreach ( $this->getOpenPages() as $page ) { |
| 99 | 99 | if ( time() > $page->getEndTimestamp() ) { |
| 100 | - $this->pagesToClose[] = $page; |
|
| 100 | + $this->pagesToClose[ ] = $page; |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -109,21 +109,21 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param string $name |
| 111 | 111 | */ |
| 112 | - public function removeUser( string $name ): void { |
|
| 112 | + public function removeUser ( string $name ): void { |
|
| 113 | 113 | unset( $this->processUsers[ $name ] ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
| 117 | 117 | * @return PageRiconferma[] |
| 118 | 118 | */ |
| 119 | - public function getCreatedPages(): array { |
|
| 119 | + public function getCreatedPages (): array { |
|
| 120 | 120 | return $this->createdPages; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * @param PageRiconferma $page |
| 125 | 125 | */ |
| 126 | - public function addCreatedPage( PageRiconferma $page ): void { |
|
| 127 | - $this->createdPages[] = $page; |
|
| 126 | + public function addCreatedPage ( PageRiconferma $page ): void { |
|
| 127 | + $this->createdPages[ ] = $page; |
|
| 128 | 128 | } |
| 129 | 129 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\TaskHelper; |
| 4 | 4 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param int $status One of the Task::STATUS_* constants |
| 22 | 22 | * @param string[] $errors |
| 23 | 23 | */ |
| 24 | - public function __construct( int $status, array $errors = [] ) { |
|
| 24 | + public function __construct ( int $status, array $errors = [ ] ) { |
|
| 25 | 25 | $this->status = $status; |
| 26 | 26 | $this->errors = $errors; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return int |
| 31 | 31 | */ |
| 32 | - public function getStatus(): int { |
|
| 32 | + public function getStatus (): int { |
|
| 33 | 33 | return $this->status; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * @return string[] |
| 38 | 38 | * @suppress PhanUnreferencedPublicMethod |
| 39 | 39 | */ |
| 40 | - public function getErrors(): array { |
|
| 40 | + public function getErrors (): array { |
|
| 41 | 41 | return $this->errors; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @param TaskResult $that |
| 46 | 46 | */ |
| 47 | - public function merge( TaskResult $that ): void { |
|
| 47 | + public function merge ( TaskResult $that ): void { |
|
| 48 | 48 | $this->status |= $that->status; |
| 49 | 49 | $this->errors = array_merge( $this->errors, $that->errors ); |
| 50 | 50 | } |
@@ -52,15 +52,15 @@ discard block |
||
| 52 | 52 | /** |
| 53 | 53 | * @return string |
| 54 | 54 | */ |
| 55 | - public function __toString(): string { |
|
| 55 | + public function __toString (): string { |
|
| 56 | 56 | if ( $this->isOK() ) { |
| 57 | 57 | $stat = 'OK'; |
| 58 | 58 | $errs = "\tNo errors."; |
| 59 | 59 | } else { |
| 60 | 60 | $stat = 'ERROR'; |
| 61 | - $formattedErrs = []; |
|
| 61 | + $formattedErrs = [ ]; |
|
| 62 | 62 | foreach ( $this->errors as $err ) { |
| 63 | - $formattedErrs[] = "\t - $err"; |
|
| 63 | + $formattedErrs[ ] = "\t - $err"; |
|
| 64 | 64 | } |
| 65 | 65 | $errs = implode( "\n", $formattedErrs ); |
| 66 | 66 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return bool |
| 74 | 74 | */ |
| 75 | - public function isOK(): bool { |
|
| 75 | + public function isOK (): bool { |
|
| 76 | 76 | return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -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,12 +11,12 @@ discard block |
||
| 11 | 11 | /** @var self */ |
| 12 | 12 | private static $instance; |
| 13 | 13 | /** @var string[] */ |
| 14 | - private $opts = []; |
|
| 14 | + private $opts = [ ]; |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Use self::init() and self::getInstance() |
| 18 | 18 | */ |
| 19 | - private function __construct() { |
|
| 19 | + private function __construct () { |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param string[] $confValues |
| 26 | 26 | * @throws ConfigException |
| 27 | 27 | */ |
| 28 | - public static function init( array $confValues ): void { |
|
| 28 | + public static function init ( array $confValues ): void { |
|
| 29 | 29 | if ( self::$instance ) { |
| 30 | 30 | throw new ConfigException( 'Config was already initialized' ); |
| 31 | 31 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param string $key |
| 45 | 45 | * @param mixed $value |
| 46 | 46 | */ |
| 47 | - protected function set( string $key, $value ): void { |
|
| 47 | + protected function set ( string $key, $value ): void { |
|
| 48 | 48 | $this->opts[ $key ] = $value; |
| 49 | 49 | } |
| 50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @return self |
| 55 | 55 | * @throws ConfigException |
| 56 | 56 | */ |
| 57 | - public static function getInstance(): self { |
|
| 57 | + public static function getInstance (): self { |
|
| 58 | 58 | if ( !self::$instance ) { |
| 59 | 59 | throw new ConfigException( 'Config not yet initialized' ); |
| 60 | 60 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return mixed |
| 69 | 69 | * @throws ConfigException |
| 70 | 70 | */ |
| 71 | - public function get( string $opt ) { |
|
| 71 | + public function get ( string $opt ) { |
|
| 72 | 72 | if ( !isset( $this->opts[ $opt ] ) ) { |
| 73 | 73 | throw new ConfigException( "Config option '$opt' not set." ); |
| 74 | 74 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Logger; |
| 4 | 4 | |
@@ -11,5 +11,5 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * Flush the buffer |
| 13 | 13 | */ |
| 14 | - public function flush(): void; |
|
| 14 | + public function flush (): void; |
|
| 15 | 15 | } |