@@ -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 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param MessageProvider $mp |
| 65 | 65 | * @param PageBotList $pbl |
| 66 | 66 | */ |
| 67 | - public function __construct( |
|
| 67 | + public function __construct ( |
|
| 68 | 68 | LoggerInterface $logger, |
| 69 | 69 | WikiGroup $wikiGroup, |
| 70 | 70 | MessageProvider $mp, |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param string[] $tasks Only used in MODE_TASK and MODE_SUBTASK |
| 90 | 90 | * @return TaskResult |
| 91 | 91 | */ |
| 92 | - public function run( string $mode, array $tasks = [] ) : TaskResult { |
|
| 92 | + public function run ( string $mode, array $tasks = [ ] ) : TaskResult { |
|
| 93 | 93 | if ( $mode === self::MODE_COMPLETE ) { |
| 94 | 94 | return $this->runAllTasks(); |
| 95 | 95 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return TaskResult |
| 106 | 106 | */ |
| 107 | - protected function runAllTasks() : TaskResult { |
|
| 107 | + protected function runAllTasks () : TaskResult { |
|
| 108 | 108 | $orderedList = [ |
| 109 | 109 | 'update-list', |
| 110 | 110 | 'start-new', |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param array $tasks |
| 122 | 122 | * @return TaskResult |
| 123 | 123 | */ |
| 124 | - private function runTasks( array $tasks ) : TaskResult { |
|
| 124 | + private function runTasks ( array $tasks ) : TaskResult { |
|
| 125 | 125 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
| 126 | 126 | do { |
| 127 | 127 | $res->merge( $this->runTask( current( $tasks ) ) ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @param string $name |
| 137 | 137 | * @return TaskResult |
| 138 | 138 | */ |
| 139 | - protected function runTask( string $name ) : TaskResult { |
|
| 139 | + protected function runTask ( string $name ) : TaskResult { |
|
| 140 | 140 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 141 | 141 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
| 142 | 142 | } |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param string[] $subtasks |
| 151 | 151 | * @return TaskResult |
| 152 | 152 | */ |
| 153 | - private function runSubtasks( array $subtasks ) : TaskResult { |
|
| 153 | + private function runSubtasks ( array $subtasks ) : TaskResult { |
|
| 154 | 154 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
| 155 | 155 | do { |
| 156 | 156 | $res->merge( $this->runSubtask( current( $subtasks ) ) ); |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string $name |
| 166 | 166 | * @return TaskResult |
| 167 | 167 | */ |
| 168 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 168 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 169 | 169 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 170 | 170 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 171 | 171 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | * @param string $name |
| 181 | 181 | * @return Task |
| 182 | 182 | */ |
| 183 | - private function getTaskInstance( string $name ) : Task { |
|
| 183 | + private function getTaskInstance ( string $name ) : Task { |
|
| 184 | 184 | $class = self::TASKS_MAP[ $name ]; |
| 185 | 185 | /** @var Task $ret */ |
| 186 | 186 | $ret = new $class( |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * @param string $class |
| 200 | 200 | * @return Subtask |
| 201 | 201 | */ |
| 202 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 202 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 203 | 203 | /** @var Subtask $ret */ |
| 204 | 204 | $ret = new $class( |
| 205 | 205 | $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; |
| 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 === 'task' ) { |
| 63 | - $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt['task'] ) ); |
|
| 63 | + $this->runInternal( TaskManager::MODE_TASK, explode( ',', $taskOpt[ 'task' ] ) ); |
|
| 64 | 64 | } elseif ( $type === 'subtask' ) { |
| 65 | - $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt['subtask'] ) ); |
|
| 65 | + $this->runInternal( TaskManager::MODE_SUBTASK, explode( ',', $taskOpt[ 'subtask' ] ) ); |
|
| 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 | ? TaskManager::MODE_COMPLETE |
@@ -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" ); |