Passed
Push — master ( c54283...c340dc )
by Daimona
03:40 queued 01:46
created
includes/Logger/SimpleLogger.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @inheritDoc
26 26
 	 * @suppress PhanUnusedPublicMethodParameter
27 27
 	 */
28
-	public function log( $level, $message, array $context = [] ) {
28
+	public function log ( $level, $message, array $context = [ ] ) {
29 29
 		if ( $this->levelToInt( $level ) >= $this->minLevel ) {
30 30
 			echo $this->getFormattedMessage( $level, $message ) . "\n";
31 31
 		}
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * @inheritDoc
36 36
 	 */
37
-	public function flush() : void {
37
+	public function flush () : void {
38 38
 		// Everything else is printed immediately
39 39
 		echo "\n" . str_repeat( '-', 80 ) . "\n\n";
40 40
 	}
Please login to merge, or discard this patch.
includes/Logger/WikiLogger.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
 block discarded – undo
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->minLevel = $this->levelToInt( $minlevel );
31 31
 		$this->logPage = $logPage;
32 32
 	}
@@ -35,16 +35,16 @@  discard block
 block discarded – undo
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
 	 * @return string
46 46
 	 */
47
-	protected function getOutput() : string {
47
+	protected function getOutput () : string {
48 48
 		$line = str_repeat( '-', 80 );
49 49
 		return implode( "\n", $this->buffer ) . "\n$line\n\n";
50 50
 	}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @inheritDoc
54 54
 	 */
55
-	public function flush() : void {
55
+	public function flush () : void {
56 56
 		if ( $this->buffer ) {
57 57
 			$this->logPage->edit( [
58 58
 				'appendtext' => $this->getOutput(),
Please login to merge, or discard this patch.
includes/Task/TaskBase.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return TaskResult
40 40
 	 */
41
-	final public function run() : TaskResult {
41
+	final public function run () : TaskResult {
42 42
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
43 43
 		$opName = $this->getOperationName();
44 44
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return int One of the STATUS_* constants
71 71
 	 */
72
-	abstract protected function runInternal() : int;
72
+	abstract protected function runInternal () : int;
73 73
 
74 74
 	/**
75 75
 	 * How this operation should be called in logs
76 76
 	 *
77 77
 	 * @return string
78 78
 	 */
79
-	abstract public function getOperationName() : string;
79
+	abstract public function getOperationName () : string;
80 80
 
81 81
 	/**
82 82
 	 * @return TaskDataProvider
83 83
 	 */
84
-	protected function getDataProvider() : TaskDataProvider {
84
+	protected function getDataProvider () : TaskDataProvider {
85 85
 		return $this->dataProvider;
86 86
 	}
87 87
 }
Please login to merge, or discard this patch.
includes/Logger/IFlushingAwareLogger.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Logger;
4 4
 
@@ -8,5 +8,5 @@  discard block
 block discarded – undo
8 8
  * Logger aware of flushing. Can be declared empty if the buffer is flushed immediately.
9 9
  */
10 10
 interface IFlushingAwareLogger extends LoggerInterface {
11
-	public function flush() : void;
11
+	public function flush () : void;
12 12
 }
Please login to merge, or discard this patch.
run.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
  */
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 $type = current( array_keys( $taskOpt ) );
55 55
 try {
56 56
 	if ( $type === 'task' ) {
57
-		$bot->runTask( $taskOpt['task'] );
57
+		$bot->runTask( $taskOpt[ 'task' ] );
58 58
 	} elseif ( $type === 'subtask' ) {
59
-		$bot->runSubtask( $taskOpt['subtask'] );
59
+		$bot->runSubtask( $taskOpt[ 'subtask' ] );
60 60
 	} else {
61 61
 		$bot->runAll();
62 62
 	}
Please login to merge, or discard this patch.
includes/CLI.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
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
 block discarded – undo
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->checkRequired( $opts );
70 70
 		$this->canonicalize( $opts );
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 	/**
75 75
 	 * @param array $opts
76 76
 	 */
77
-	private function checkRequired( array $opts ) {
77
+	private function checkRequired ( array $opts ) {
78 78
 		foreach ( self::REQUIRED_OPTS as $opt ) {
79 79
 			if ( !array_key_exists( $opt, $opts ) ) {
80 80
 				exit( "Required option $opt missing." );
81 81
 			}
82 82
 		}
83 83
 
84
-		if ( count( array_intersect_key( [ 'password' => true, 'use-password-file' => true ] , $opts ) ) === 0 ) {
84
+		if ( count( array_intersect_key( [ 'password' => true, 'use-password-file' => true ], $opts ) ) === 0 ) {
85 85
 			exit( 'Please provide a password or use a password file' );
86
-		} elseif ( count( array_intersect_key( [ 'password' => true, 'use-password-file' => true ] , $opts ) ) === 2 ) {
86
+		} elseif ( count( array_intersect_key( [ 'password' => true, 'use-password-file' => true ], $opts ) ) === 2 ) {
87 87
 			exit( 'Can only use one of "password" and "use-password-file"' );
88 88
 		}
89 89
 
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 	/**
100 100
 	 * @param array &$opts
101 101
 	 */
102
-	private function canonicalize( array &$opts ) {
102
+	private function canonicalize ( array &$opts ) {
103 103
 		if ( array_key_exists( 'use-password-file', $opts ) ) {
104 104
 			$pw = file_get_contents( self::PASSWORD_FILE );
105
-			$opts['password'] = $pw;
106
-			unset( $opts['use-password-file'] );
105
+			$opts[ 'password' ] = $pw;
106
+			unset( $opts[ 'use-password-file' ] );
107 107
 		}
108 108
 	}
109 109
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * These are the options required by Config.
112 112
 	 * @return array
113 113
 	 */
114
-	public function getMainOpts() : array {
114
+	public function getMainOpts () : array {
115 115
 		return array_intersect_key(
116 116
 			$this->opts,
117 117
 			array_fill_keys( Config::REQUIRED_OPTS, true )
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 	 * @param mixed|null $default
124 124
 	 * @return mixed
125 125
 	 */
126
-	public function getOpt( string $opt, $default = null ) {
127
-		return $this->opts[$opt] ?? $default;
126
+	public function getOpt ( string $opt, $default = null ) {
127
+		return $this->opts[ $opt ] ?? $default;
128 128
 	}
129 129
 
130 130
 	/**
131 131
 	 * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ]
132 132
 	 */
133
-	public function getTaskOpt() : array {
133
+	public function getTaskOpt () : array {
134 134
 		return array_intersect_key(
135 135
 			$this->opts,
136 136
 			[ 'task' => true, 'subtask' => true ]
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	/**
141 141
 	 * @return string|null
142 142
 	 */
143
-	public function getURL() : ?string {
143
+	public function getURL () : ?string {
144 144
 		return $this->getOpt( 'force-url' );
145 145
 	}
146 146
 }
Please login to merge, or discard this patch.