@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param Wiki $wiki |
| 21 | 21 | * @param string $msgTitle |
| 22 | 22 | */ |
| 23 | - public function __construct( Wiki $wiki, string $msgTitle ) { |
|
| 23 | + public function __construct ( Wiki $wiki, string $msgTitle ) { |
|
| 24 | 24 | $this->wiki = $wiki; |
| 25 | 25 | $this->msgTitle = $msgTitle; |
| 26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @throws MessagesPageDoesNotExistException |
| 30 | 30 | */ |
| 31 | - private function grabWikiMessages() : void { |
|
| 31 | + private function grabWikiMessages () : void { |
|
| 32 | 32 | if ( self::$messages !== null ) { |
| 33 | 33 | return; |
| 34 | 34 | } |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | * @return Message |
| 46 | 46 | * @throws MessageNotFoundException |
| 47 | 47 | */ |
| 48 | - public function getMessage( string $key ) : Message { |
|
| 48 | + public function getMessage ( string $key ) : Message { |
|
| 49 | 49 | $this->grabWikiMessages(); |
| 50 | 50 | if ( !isset( self::$messages[ $key ] ) ) { |
| 51 | 51 | throw new MessageNotFoundException( "Message '$key' does not exist." ); |
| 52 | 52 | } |
| 53 | 53 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
| 54 | - return new Message( self::$messages[$key] ); |
|
| 54 | + return new Message( self::$messages[ $key ] ); |
|
| 55 | 55 | } |
| 56 | 56 | } |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @param string $username |
| 16 | 16 | * @param string $password |
| 17 | 17 | */ |
| 18 | - public function __construct( string $username, string $password ) { |
|
| 18 | + public function __construct ( string $username, string $password ) { |
|
| 19 | 19 | $this->username = $username; |
| 20 | 20 | $this->password = $password; |
| 21 | 21 | } |
@@ -23,14 +23,14 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public function getUsername() : string { |
|
| 26 | + public function getUsername () : string { |
|
| 27 | 27 | return $this->username; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getPassword() : string { |
|
| 33 | + public function getPassword () : string { |
|
| 34 | 34 | return $this->password; |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -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; |
@@ -39,16 +39,16 @@ discard block |
||
| 39 | 39 | * @inheritDoc |
| 40 | 40 | * @suppress PhanUnusedPublicMethodParameter |
| 41 | 41 | */ |
| 42 | - public function log( $level, $message, array $context = [] ) :void { |
|
| 42 | + public function log ( $level, $message, array $context = [ ] ) :void { |
|
| 43 | 43 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
| 44 | - $this->buffer[] = $this->getFormattedMessage( $level, $message ); |
|
| 44 | + $this->buffer[ ] = $this->getFormattedMessage( $level, $message ); |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - protected function getOutput() : string { |
|
| 51 | + protected function getOutput () : string { |
|
| 52 | 52 | $line = str_repeat( '-', 80 ); |
| 53 | 53 | return "\n\n" . implode( "\n", $this->buffer ) . "\n$line\n\n"; |
| 54 | 54 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * @inheritDoc |
| 58 | 58 | */ |
| 59 | - public function flush() : void { |
|
| 59 | + public function flush () : void { |
|
| 60 | 60 | if ( $this->buffer ) { |
| 61 | 61 | $this->logPage->edit( [ |
| 62 | 62 | '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; |
| 4 | 4 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public static function isCLI() : bool { |
|
| 60 | + public static function isCLI () : bool { |
|
| 61 | 61 | return PHP_SAPI === 'cli'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * Populate options and check for required ones |
| 66 | 66 | */ |
| 67 | - public function __construct() { |
|
| 67 | + public function __construct () { |
|
| 68 | 68 | $opts = getopt( self::SHORT_OPTS, self::LONG_OPTS ); |
| 69 | 69 | $this->checkRequiredOpts( $opts ); |
| 70 | 70 | $this->checkConflictingOpts( $opts ); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | /** |
| 76 | 76 | * @param array $opts |
| 77 | 77 | */ |
| 78 | - private function checkRequiredOpts( array $opts ) : void { |
|
| 78 | + private function checkRequiredOpts ( array $opts ) : void { |
|
| 79 | 79 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
| 80 | 80 | if ( $missingOpts ) { |
| 81 | 81 | exit( 'Required options missing: ' . implode( ', ', $missingOpts ) ); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /** |
| 92 | 92 | * @param array $opts |
| 93 | 93 | */ |
| 94 | - private function checkConflictingOpts( array $opts ) : void { |
|
| 94 | + private function checkConflictingOpts ( array $opts ) : void { |
|
| 95 | 95 | $hasPw = array_key_exists( 'password', $opts ); |
| 96 | 96 | $hasPwFile = array_key_exists( 'use-password-file', $opts ); |
| 97 | 97 | if ( $hasPw && $hasPwFile ) { |
@@ -108,11 +108,11 @@ discard block |
||
| 108 | 108 | /** |
| 109 | 109 | * @param array &$opts |
| 110 | 110 | */ |
| 111 | - private function canonicalize( array &$opts ) : void { |
|
| 111 | + private function canonicalize ( array &$opts ) : void { |
|
| 112 | 112 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
| 113 | 113 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
| 114 | - $opts['password'] = $pw; |
|
| 115 | - unset( $opts['use-password-file'] ); |
|
| 114 | + $opts[ 'password' ] = $pw; |
|
| 115 | + unset( $opts[ 'use-password-file' ] ); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | |
@@ -121,14 +121,14 @@ discard block |
||
| 121 | 121 | * @param mixed|null $default |
| 122 | 122 | * @return mixed |
| 123 | 123 | */ |
| 124 | - public function getOpt( string $opt, $default = null ) { |
|
| 125 | - return $this->opts[$opt] ?? $default; |
|
| 124 | + public function getOpt ( string $opt, $default = null ) { |
|
| 125 | + return $this->opts[ $opt ] ?? $default; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
| 129 | 129 | * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ] |
| 130 | 130 | */ |
| 131 | - public function getTaskOpt() : array { |
|
| 131 | + public function getTaskOpt () : array { |
|
| 132 | 132 | return array_intersect_key( |
| 133 | 133 | $this->opts, |
| 134 | 134 | [ 'task' => true, 'subtask' => true ] |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | /** |
| 139 | 139 | * @return string|null |
| 140 | 140 | */ |
| 141 | - public function getURL() : ?string { |
|
| 141 | + public function getURL () : ?string { |
|
| 142 | 142 | return $this->getOpt( 'force-url' ); |
| 143 | 143 | } |
| 144 | 144 | } |
@@ -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 array */ |
| 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 array $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\Subtask; |
| 4 | 4 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @inheritDoc |
| 14 | 14 | */ |
| 15 | - public function runInternal() : int { |
|
| 15 | + public function runInternal () : int { |
|
| 16 | 16 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 17 | 17 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | return TaskResult::STATUS_NOTHING; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $ricNums = []; |
|
| 23 | + $ricNums = [ ]; |
|
| 24 | 24 | foreach ( $pages as $page ) { |
| 25 | 25 | $ricNums[ $page->getUserName() ] = $page->getNum(); |
| 26 | 26 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param User $user |
| 39 | 39 | * @param int $ricNum |
| 40 | 40 | */ |
| 41 | - protected function addMsg( User $user, int $ricNum ) : void { |
|
| 41 | + protected function addMsg ( User $user, int $ricNum ) : void { |
|
| 42 | 42 | $this->getLogger()->info( "Leaving msg to $user" ); |
| 43 | 43 | $msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text(); |
| 44 | 44 | |
@@ -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, |