@@ -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,7 +11,7 @@ discard block |
||
| 11 | 11 | * @param string $level |
| 12 | 12 | * @return int |
| 13 | 13 | */ |
| 14 | - protected function levelToInt( string $level ) : int { |
|
| 14 | + protected function levelToInt ( string $level ) : int { |
|
| 15 | 15 | // Order matters |
| 16 | 16 | $mapping = [ |
| 17 | 17 | LogLevel::DEBUG, |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param string $message |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - protected function getFormattedMessage( string $level, string $message ) { |
|
| 34 | + protected function getFormattedMessage ( string $level, string $message ) { |
|
| 35 | 35 | return sprintf( "%s [%s] - %s\n", date( 'd M H:i:s' ), $level, $message ); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | abstract class TaskBase extends ContextSource { |
| 15 | 15 | /** @var string[] */ |
| 16 | - protected $errors = []; |
|
| 16 | + protected $errors = [ ]; |
|
| 17 | 17 | /** @var TaskDataProvider */ |
| 18 | 18 | protected $dataProvider; |
| 19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @param Wiki $wiki |
| 25 | 25 | * @param TaskDataProvider $dataProvider |
| 26 | 26 | */ |
| 27 | - final public function __construct( |
|
| 27 | + final public function __construct ( |
|
| 28 | 28 | LoggerInterface $logger, |
| 29 | 29 | Wiki $wiki, |
| 30 | 30 | TaskDataProvider $dataProvider |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $this->dataProvider = $dataProvider; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - public function __destruct() { |
|
| 38 | + public function __destruct () { |
|
| 39 | 39 | restore_error_handler(); |
| 40 | 40 | restore_exception_handler(); |
| 41 | 41 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return TaskResult |
| 47 | 47 | */ |
| 48 | - final public function run() : TaskResult { |
|
| 48 | + final public function run () : TaskResult { |
|
| 49 | 49 | $class = ( new \ReflectionClass( $this ) )->getShortName(); |
| 50 | 50 | $opName = $this->getOperationName(); |
| 51 | 51 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return int One of the STATUS_* constants |
| 78 | 78 | */ |
| 79 | - abstract protected function runInternal() : int; |
|
| 79 | + abstract protected function runInternal () : int; |
|
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | 82 | * How this operation should be called in logs |
| 83 | 83 | * |
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | - abstract public function getOperationName() : string; |
|
| 86 | + abstract public function getOperationName () : string; |
|
| 87 | 87 | |
| 88 | 88 | /** |
| 89 | 89 | * Exception handler. |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param \Throwable $ex |
| 92 | 92 | * @protected |
| 93 | 93 | */ |
| 94 | - public function handleException( \Throwable $ex ) { |
|
| 94 | + public function handleException ( \Throwable $ex ) { |
|
| 95 | 95 | $this->getLogger()->error( "$ex" ); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * @throws \ErrorException |
| 106 | 106 | * @protected |
| 107 | 107 | */ |
| 108 | - public function handleError( $errno, $errstr, $errfile, $errline ) { |
|
| 108 | + public function handleError ( $errno, $errstr, $errfile, $errline ) { |
|
| 109 | 109 | throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline ); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | 113 | * @return TaskDataProvider |
| 114 | 114 | */ |
| 115 | - protected function getDataProvider() : TaskDataProvider { |
|
| 115 | + protected function getDataProvider () : TaskDataProvider { |
|
| 116 | 116 | return $this->dataProvider; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -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 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @param Page $logPage |
| 27 | 27 | * @param string $minlevel |
| 28 | 28 | */ |
| 29 | - public function __construct( Page $logPage, $minlevel = LogLevel::INFO ) { |
|
| 29 | + public function __construct ( Page $logPage, $minlevel = LogLevel::INFO ) { |
|
| 30 | 30 | $this->logPage = $logPage; |
| 31 | 31 | $this->minLevel = $this->levelToInt( $minlevel ); |
| 32 | 32 | } |
@@ -35,16 +35,16 @@ discard block |
||
| 35 | 35 | * @inheritDoc |
| 36 | 36 | * @suppress PhanUnusedPublicMethodParameter |
| 37 | 37 | */ |
| 38 | - public function log( $level, $message, array $context = [] ) { |
|
| 38 | + public function log ( $level, $message, array $context = [ ] ) { |
|
| 39 | 39 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
| 40 | - $this->buffer[] = $this->getFormattedMessage( $level, $message ); |
|
| 40 | + $this->buffer[ ] = $this->getFormattedMessage( $level, $message ); |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
| 45 | 45 | * Actually writes data to the wiki |
| 46 | 46 | */ |
| 47 | - public function doOutput() { |
|
| 47 | + public function doOutput () { |
|
| 48 | 48 | if ( $this->buffer ) { |
| 49 | 49 | $this->logPage->edit( [ |
| 50 | 50 | // @todo Print a line à la Bot.php |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | /** |
| 58 | 58 | * @todo Can we move this? |
| 59 | 59 | */ |
| 60 | - public function __destruct() { |
|
| 60 | + public function __destruct () { |
|
| 61 | 61 | $this->doOutput(); |
| 62 | 62 | } |
| 63 | 63 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | /** |
| 3 | 3 | * Entry point for the bot, called by CLI |
| 4 | 4 | */ |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | /* URL (for debugging purpose) */ |
| 41 | 41 | $urlParam = getopt( '', [ 'force-url:' ] ); |
| 42 | -$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php'; |
|
| 42 | +$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php'; |
|
| 43 | 43 | |
| 44 | 44 | define( 'DEFAULT_URL', $url ); |
| 45 | 45 | define( 'META_URL', 'https://meta.wikimedia.org/w/api.php' ); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | /* START */ |
| 77 | 77 | |
| 78 | 78 | $errParam = getopt( '', [ 'error-title::' ] ); |
| 79 | -$errTitle = $errParam['error-title'] ?? null; |
|
| 79 | +$errTitle = $errParam[ 'error-title' ] ?? null; |
|
| 80 | 80 | |
| 81 | 81 | $simpleLogger = new \BotRiconferme\Logger\SimpleLogger(); |
| 82 | 82 | // @fixme |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | if ( count( $taskOpts ) === 2 ) { |
| 107 | 107 | throw new InvalidArgumentException( 'Cannot specify both task and subtask.' ); |
| 108 | -} elseif ( isset( $taskOpts['task'] ) ) { |
|
| 108 | +} elseif ( isset( $taskOpts[ 'task' ] ) ) { |
|
| 109 | 109 | $bot->runTask( $taskOpts[ 'task' ] ); |
| 110 | -} elseif ( isset( $taskOpts['subtask'] ) ) { |
|
| 110 | +} elseif ( isset( $taskOpts[ 'subtask' ] ) ) { |
|
| 111 | 111 | $bot->runSubtask( $taskOpts[ 'subtask' ] ); |
| 112 | 112 | } else { |
| 113 | 113 | $bot->runAll(); |