@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param array $info |
| 22 | 22 | * @phan-param array<string,string|string[]> $info |
| 23 | 23 | */ |
| 24 | - public function __construct( string $name, array $info ) { |
|
| 24 | + public function __construct ( string $name, array $info ) { |
|
| 25 | 25 | $this->name = $name; |
| 26 | 26 | $this->info = $info; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - public function getName() : string { |
|
| 32 | + public function getName () : string { |
|
| 33 | 33 | return $this->name; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -37,28 +37,28 @@ discard block |
||
| 37 | 37 | * @return array |
| 38 | 38 | * @phan-return array<string,string|string[]> |
| 39 | 39 | */ |
| 40 | - public function getInfo() : array { |
|
| 40 | + public function getInfo () : array { |
|
| 41 | 41 | return $this->info; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * @return string[] |
| 46 | 46 | */ |
| 47 | - public function extractGroups() : array { |
|
| 47 | + public function extractGroups () : array { |
|
| 48 | 48 | return array_keys( $this->extractGroupsWithDates() ); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * @return string[] |
| 53 | 53 | */ |
| 54 | - public function extractGroupsWithDates() : array { |
|
| 54 | + public function extractGroupsWithDates () : array { |
|
| 55 | 55 | return array_intersect_key( $this->getInfo(), array_fill_keys( self::GROUP_KEYS, 1 ) ); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @return string[] |
| 60 | 60 | */ |
| 61 | - public function getAliases() : array { |
|
| 62 | - return $this->getInfo()['aliases'] ?? []; |
|
| 61 | + public function getAliases () : array { |
|
| 62 | + return $this->getInfo()[ 'aliases' ] ?? [ ]; |
|
| 63 | 63 | } |
| 64 | 64 | } |
@@ -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\Subtask; |
| 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 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 19 | 19 | |
| 20 | 20 | if ( !$pages ) { |
@@ -36,15 +36,15 @@ discard block |
||
| 36 | 36 | * @param PageRiconferma[] $pages |
| 37 | 37 | * @see OpenUpdates::addToVotazioni() |
| 38 | 38 | */ |
| 39 | - protected function updateVotazioni( array $pages ) : void { |
|
| 39 | + protected function updateVotazioni ( array $pages ) : void { |
|
| 40 | 40 | $this->getLogger()->info( |
| 41 | 41 | 'Updating votazioni: ' . implode( ', ', $pages ) |
| 42 | 42 | ); |
| 43 | 43 | $votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) ); |
| 44 | 44 | |
| 45 | - $users = []; |
|
| 45 | + $users = [ ]; |
|
| 46 | 46 | foreach ( $pages as $page ) { |
| 47 | - $users[] = $this->getUser( $page->getUserName() ); |
|
| 47 | + $users[ ] = $this->getUser( $page->getUserName() ); |
|
| 48 | 48 | } |
| 49 | 49 | $usersReg = RegexUtils::regexFromArray( '!', ...$users ); |
| 50 | 50 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @param PageRiconferma[] $pages |
| 66 | 66 | * @see OpenUpdates::addToNews() |
| 67 | 67 | */ |
| 68 | - protected function updateNews( array $pages ) : void { |
|
| 68 | + protected function updateNews ( array $pages ) : void { |
|
| 69 | 69 | $simpleAmount = $voteAmount = 0; |
| 70 | 70 | foreach ( $pages as $page ) { |
| 71 | 71 | if ( $page->isVote() ) { |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 86 | 86 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 87 | 87 | |
| 88 | - $newSimp = ( (int)$simpleMatches[2] - $simpleAmount ) ?: ''; |
|
| 89 | - $newVote = ( (int)$voteMatches[2] - $voteAmount ) ?: ''; |
|
| 88 | + $newSimp = ( (int)$simpleMatches[ 2 ] - $simpleAmount ) ?: ''; |
|
| 89 | + $newVote = ( (int)$voteMatches[ 2 ] - $voteAmount ) ?: ''; |
|
| 90 | 90 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() ); |
| 91 | 91 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 92 | 92 | |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @param bool[] $outcomes |
| 106 | 106 | */ |
| 107 | - protected function updateAdminList( array $outcomes ) : void { |
|
| 107 | + protected function updateAdminList ( array $outcomes ) : void { |
|
| 108 | 108 | $this->getLogger()->info( 'Updating admin list' ); |
| 109 | 109 | $adminsPage = $this->getPage( $this->getOpt( 'admins-list-title' ) ); |
| 110 | 110 | $newContent = $adminsPage->getContent(); |
| 111 | 111 | |
| 112 | - $riconfNames = $removeNames = []; |
|
| 112 | + $riconfNames = $removeNames = [ ]; |
|
| 113 | 113 | foreach ( $outcomes as $username => $confirmed ) { |
| 114 | 114 | $user = $this->getUser( $username ); |
| 115 | 115 | $userReg = $user->getRegex( '!' ); |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | '${1}{{subst:#timel:Ymd}}|' . $nextDate . '$2', |
| 125 | 125 | $newContent |
| 126 | 126 | ); |
| 127 | - $riconfNames[] = $username; |
|
| 127 | + $riconfNames[ ] = $username; |
|
| 128 | 128 | } else { |
| 129 | 129 | $newContent = preg_replace( $reg, '', $newContent ); |
| 130 | - $removeNames[] = $username; |
|
| 130 | + $removeNames[ ] = $username; |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -147,21 +147,21 @@ discard block |
||
| 147 | 147 | /** |
| 148 | 148 | * @param bool[] $outcomes |
| 149 | 149 | */ |
| 150 | - protected function updateCUList( array $outcomes ) : void { |
|
| 150 | + protected function updateCUList ( array $outcomes ) : void { |
|
| 151 | 151 | $this->getLogger()->info( 'Updating CU list.' ); |
| 152 | 152 | $cuList = $this->getPage( $this->getOpt( 'cu-list-title' ) ); |
| 153 | 153 | $newContent = $cuList->getContent(); |
| 154 | 154 | |
| 155 | - $riconfNames = $removeNames = []; |
|
| 155 | + $riconfNames = $removeNames = [ ]; |
|
| 156 | 156 | foreach ( $outcomes as $user => $confirmed ) { |
| 157 | 157 | $userReg = $this->getUser( $user )->getRegex( '!' ); |
| 158 | 158 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
| 159 | 159 | if ( $confirmed ) { |
| 160 | 160 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
| 161 | - $riconfNames[] = $user; |
|
| 161 | + $riconfNames[ ] = $user; |
|
| 162 | 162 | } else { |
| 163 | 163 | $newContent = preg_replace( $reg, '', $newContent ); |
| 164 | - $removeNames[] = $user; |
|
| 164 | + $removeNames[ ] = $user; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
@@ -185,8 +185,8 @@ discard block |
||
| 185 | 185 | * @param PageRiconferma[] $pages |
| 186 | 186 | * @return bool[] |
| 187 | 187 | */ |
| 188 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
| 189 | - $ret = []; |
|
| 188 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
| 189 | + $ret = [ ]; |
|
| 190 | 190 | foreach ( $pages as $page ) { |
| 191 | 191 | $user = $this->getUser( $page->getUserName() ); |
| 192 | 192 | if ( $user->inGroup( $group ) ) { |
@@ -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\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\Logger; |
| 4 | 4 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $summary |
| 30 | 30 | * @param string $minlevel |
| 31 | 31 | */ |
| 32 | - public function __construct( Page $logPage, string $summary, $minlevel = LogLevel::INFO ) { |
|
| 32 | + public function __construct ( Page $logPage, string $summary, $minlevel = LogLevel::INFO ) { |
|
| 33 | 33 | $this->minLevel = $this->levelToInt( $minlevel ); |
| 34 | 34 | $this->logPage = $logPage; |
| 35 | 35 | $this->summary = $summary; |
@@ -40,16 +40,16 @@ discard block |
||
| 40 | 40 | * @param mixed[] $context |
| 41 | 41 | * @suppress PhanUnusedPublicMethodParameter |
| 42 | 42 | */ |
| 43 | - public function log( $level, $message, array $context = [] ) :void { |
|
| 43 | + public function log ( $level, $message, array $context = [ ] ) :void { |
|
| 44 | 44 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
| 45 | - $this->buffer[] = $this->getFormattedMessage( $level, $message ); |
|
| 45 | + $this->buffer[ ] = $this->getFormattedMessage( $level, $message ); |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - protected function getOutput() : string { |
|
| 52 | + protected function getOutput () : string { |
|
| 53 | 53 | $line = str_repeat( '-', 80 ); |
| 54 | 54 | return "\n\n" . implode( "\n", $this->buffer ) . "\n$line\n\n"; |
| 55 | 55 | } |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @inheritDoc |
| 59 | 59 | */ |
| 60 | - public function flush() : void { |
|
| 60 | + public function flush () : void { |
|
| 61 | 61 | if ( $this->buffer ) { |
| 62 | 62 | $this->logPage->edit( [ |
| 63 | 63 | 'appendtext' => $this->getOutput(), |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @param IFlushingAwareLogger ...$loggers |
| 16 | 16 | */ |
| 17 | - public function __construct( IFlushingAwareLogger ...$loggers ) { |
|
| 17 | + public function __construct ( IFlushingAwareLogger ...$loggers ) { |
|
| 18 | 18 | $this->loggers = $loggers; |
| 19 | 19 | } |
| 20 | 20 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param mixed[] $context |
| 24 | 24 | * @suppress PhanUnusedPublicMethodParameter |
| 25 | 25 | */ |
| 26 | - public function log( $level, $message, array $context = [] ) :void { |
|
| 26 | + public function log ( $level, $message, array $context = [ ] ) :void { |
|
| 27 | 27 | foreach ( $this->loggers as $logger ) { |
| 28 | 28 | $logger->log( $level, $message ); |
| 29 | 29 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @inheritDoc |
| 34 | 34 | */ |
| 35 | - public function flush() : void { |
|
| 35 | + public function flush () : void { |
|
| 36 | 36 | foreach ( $this->loggers as $logger ) { |
| 37 | 37 | $logger->flush(); |
| 38 | 38 | } |
@@ -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 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @param string $minlevel |
| 19 | 19 | */ |
| 20 | - public function __construct( $minlevel = LogLevel::INFO ) { |
|
| 20 | + public function __construct ( $minlevel = LogLevel::INFO ) { |
|
| 21 | 21 | $this->minLevel = $this->levelToInt( $minlevel ); |
| 22 | 22 | } |
| 23 | 23 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param mixed[] $context |
| 27 | 27 | * @suppress PhanUnusedPublicMethodParameter |
| 28 | 28 | */ |
| 29 | - public function log( $level, $message, array $context = [] ) : void { |
|
| 29 | + public function log ( $level, $message, array $context = [ ] ) : void { |
|
| 30 | 30 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
| 31 | 31 | echo $this->getFormattedMessage( $level, $message ) . "\n"; |
| 32 | 32 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @inheritDoc |
| 37 | 37 | */ |
| 38 | - public function flush() : void { |
|
| 38 | + public function flush () : void { |
|
| 39 | 39 | // Everything else is printed immediately |
| 40 | 40 | echo "\n" . str_repeat( '-', 80 ) . "\n\n"; |
| 41 | 41 | } |
@@ -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 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param UserInfo $ui |
| 24 | 24 | * @param Wiki $wiki |
| 25 | 25 | */ |
| 26 | - public function __construct( UserInfo $ui, Wiki $wiki ) { |
|
| 26 | + public function __construct ( UserInfo $ui, Wiki $wiki ) { |
|
| 27 | 27 | $this->wiki = $wiki; |
| 28 | 28 | $this->name = $ui->getName(); |
| 29 | 29 | $this->ui = $ui; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @return string |
| 34 | 34 | */ |
| 35 | - public function getName() : string { |
|
| 35 | + public function getName () : string { |
|
| 36 | 36 | return $this->name; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return string[] |
| 43 | 43 | */ |
| 44 | - public function getGroups() : array { |
|
| 44 | + public function getGroups () : array { |
|
| 45 | 45 | return $this->ui->extractGroups(); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return string[] [ group => date ] |
| 52 | 52 | */ |
| 53 | - public function getGroupsWithDates() : array { |
|
| 53 | + public function getGroupsWithDates () : array { |
|
| 54 | 54 | return $this->ui->extractGroupsWithDates(); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param string $groupName |
| 61 | 61 | * @return bool |
| 62 | 62 | */ |
| 63 | - public function inGroup( string $groupName ) : bool { |
|
| 63 | + public function inGroup ( string $groupName ) : bool { |
|
| 64 | 64 | return in_array( $groupName, $this->getGroups(), true ); |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,9 +69,9 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @inheritDoc |
| 71 | 71 | */ |
| 72 | - public function getRegex( string $delimiter = '/' ) : string { |
|
| 72 | + public function getRegex ( string $delimiter = '/' ) : string { |
|
| 73 | 73 | $bits = $this->getAliases(); |
| 74 | - $bits[] = $this->name; |
|
| 74 | + $bits[ ] = $this->name; |
|
| 75 | 75 | $regexify = static function ( string $el ) use ( $delimiter ) : string { |
| 76 | 76 | return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) ); |
| 77 | 77 | }; |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return string[] |
| 85 | 85 | */ |
| 86 | - public function getAliases() : array { |
|
| 86 | + public function getAliases () : array { |
|
| 87 | 87 | return $this->ui->getAliases(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * @return Page |
| 92 | 92 | */ |
| 93 | - public function getTalkPage() : Page { |
|
| 93 | + public function getTalkPage () : Page { |
|
| 94 | 94 | return new Page( "User talk:{$this->name}", $this->wiki ); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * Get the default base page, e.g. WP:A/Riconferma annuale/XXX |
| 99 | 99 | * @return Page |
| 100 | 100 | */ |
| 101 | - public function getBasePage() : Page { |
|
| 101 | + public function getBasePage () : Page { |
|
| 102 | 102 | $prefix = Config::getInstance()->get( 'main-page-title' ); |
| 103 | 103 | return new Page( "$prefix/$this", $this->wiki ); |
| 104 | 104 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @throws MissingPageException |
| 111 | 111 | * @return Page |
| 112 | 112 | */ |
| 113 | - public function getExistingBasePage() : Page { |
|
| 113 | + public function getExistingBasePage () : Page { |
|
| 114 | 114 | $basePage = $this->getBasePage(); |
| 115 | 115 | if ( !$basePage->exists() ) { |
| 116 | 116 | $basePage = null; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | /** |
| 135 | 135 | * @return string |
| 136 | 136 | */ |
| 137 | - public function __toString() : string { |
|
| 137 | + public function __toString () : string { |
|
| 138 | 138 | return $this->name; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -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 | |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @param CLI $cli |
| 35 | 35 | */ |
| 36 | - public function __construct( CLI $cli ) { |
|
| 36 | + public function __construct ( CLI $cli ) { |
|
| 37 | 37 | $this->cli = $cli; |
| 38 | 38 | $this->initialize(); |
| 39 | 39 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | /** |
| 42 | 42 | * Initialize all members. |
| 43 | 43 | */ |
| 44 | - private function initialize() : void { |
|
| 44 | + private function initialize () : void { |
|
| 45 | 45 | $simpleLogger = new SimpleLogger(); |
| 46 | 46 | $this->createWikiGroup( $simpleLogger ); |
| 47 | 47 | $this->messageProvider = new MessageProvider( |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Main entry point |
| 57 | 57 | */ |
| 58 | - public function run() : void { |
|
| 58 | + public function run () : void { |
|
| 59 | 59 | $taskOpt = $this->cli->getTaskOpt(); |
| 60 | 60 | $type = current( array_keys( $taskOpt ) ); |
| 61 | 61 | try { |
| 62 | 62 | if ( $type === 'tasks' ) { |
| 63 | - $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt['tasks'] ) ); |
|
| 63 | + $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt[ 'tasks' ] ) ); |
|
| 64 | 64 | } elseif ( $type === 'subtasks' ) { |
| 65 | - $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt['subtasks'] ) ); |
|
| 65 | + $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt[ 'subtasks' ] ) ); |
|
| 66 | 66 | } else { |
| 67 | 67 | $this->runInternal(); |
| 68 | 68 | } |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | /** |
| 77 | 77 | * @param LoggerInterface $baseLogger |
| 78 | 78 | */ |
| 79 | - private function createWikiGroup( LoggerInterface $baseLogger ) : void { |
|
| 79 | + private function createWikiGroup ( LoggerInterface $baseLogger ) : void { |
|
| 80 | 80 | // FIXME Hardcoded |
| 81 | 81 | $url = $this->cli->getURL() ?? 'https://it.wikipedia.org/w/api.php'; |
| 82 | 82 | $localUserIdentifier = '@itwiki'; |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param IFlushingAwareLogger $baseLogger |
| 116 | 116 | */ |
| 117 | - private function createMainLogger( IFlushingAwareLogger $baseLogger ) : void { |
|
| 117 | + private function createMainLogger ( IFlushingAwareLogger $baseLogger ) : void { |
|
| 118 | 118 | $mainWiki = $this->wikiGroup->getMainWiki(); |
| 119 | 119 | $mp = $this->messageProvider; |
| 120 | 120 | $errTitle = $this->cli->getOpt( 'error-title' ); |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * Create the Config |
| 143 | 143 | */ |
| 144 | - private function initConfig() : void { |
|
| 144 | + private function initConfig () : void { |
|
| 145 | 145 | $wiki = $this->wikiGroup->getMainWiki(); |
| 146 | 146 | try { |
| 147 | 147 | $confValues = json_decode( $wiki->getPageContent( $this->cli->getOpt( 'config-title' ) ), true ); |
@@ -158,9 +158,9 @@ discard block |
||
| 158 | 158 | * @param string $mode |
| 159 | 159 | * @param string[] $taskNames |
| 160 | 160 | */ |
| 161 | - private function runInternal( |
|
| 161 | + private function runInternal ( |
|
| 162 | 162 | string $mode = TaskManager::MODE_COMPLETE, |
| 163 | - array $taskNames = [] |
|
| 163 | + array $taskNames = [ ] |
|
| 164 | 164 | ) : void { |
| 165 | 165 | $activity = $mode === TaskManager::MODE_COMPLETE |
| 166 | 166 | ? 'full process' |
@@ -180,8 +180,7 @@ discard block |
||
| 180 | 180 | $base = "Execution of $activity"; |
| 181 | 181 | if ( $res->isOK() ) { |
| 182 | 182 | $msg = $res->getStatus() === TaskResult::STATUS_NOTHING ? |
| 183 | - ': nothing to do' : |
|
| 184 | - ' completed successfully'; |
|
| 183 | + ': nothing to do' : ' completed successfully'; |
|
| 185 | 184 | $this->mainLogger->info( $base . $msg ); |
| 186 | 185 | } else { |
| 187 | 186 | $this->mainLogger->error( "$base failed.\n$res" ); |