Passed
Push — master ( 4b4859...1d252d )
by Daimona
02:04
created
includes/Exception/MissingMatchException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Exception;
4 4
 
Please login to merge, or discard this patch.
includes/Request/NativeRequest.php 1 patch
Spacing   +5 added lines, -5 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\Request;
4 4
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * @inheritDoc
11 11
 	 */
12
-	protected function reallyMakeRequest( string $params ) : string {
12
+	protected function reallyMakeRequest ( string $params ) : string {
13 13
 		$context = [
14 14
 			'http' => [
15 15
 				'method' => $this->method,
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		];
19 19
 		$url = $this->url;
20 20
 		if ( $this->method === self::METHOD_POST ) {
21
-			$context['http']['content'] = $params;
21
+			$context[ 'http' ][ 'content' ] = $params;
22 22
 		} else {
23 23
 			$url = "$url?$params";
24 24
 		}
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 
28 28
 		foreach ( $http_response_header as $header ) {
29 29
 			$bits = explode( ':', $header, 2 );
30
-			if ( trim( $bits[0] ) === 'Set-Cookie' ) {
31
-				$this->newCookies[] = $bits[1];
30
+			if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
31
+				$this->newCookies[ ] = $bits[ 1 ];
32 32
 			}
33 33
 		}
34 34
 
Please login to merge, or discard this patch.
includes/Request/RequestBase.php 1 patch
Spacing   +23 added lines, -23 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\Request;
4 4
 
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 	/** @var string */
34 34
 	protected $method = self::METHOD_GET;
35 35
 	/** @var string[] */
36
-	protected $newCookies = [];
36
+	protected $newCookies = [ ];
37 37
 
38 38
 	/**
39 39
 	 * Use self::newFromParams, which will provide the right class to use
40 40
 	 *
41 41
 	 * @param array $params
42 42
 	 */
43
-	protected function __construct( array $params ) {
43
+	protected function __construct ( array $params ) {
44 44
 		$this->params = [ 'format' => 'json' ] + $params;
45 45
 		$this->url = DEFAULT_URL;
46 46
 	}
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param array $params
52 52
 	 * @return self
53 53
 	 */
54
-	public static function newFromParams( array $params ) : self {
54
+	public static function newFromParams ( array $params ) : self {
55 55
 		if ( extension_loaded( 'curl' ) ) {
56 56
 			$ret = new CurlRequest( $params );
57 57
 		} else {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @return self For chaining
67 67
 	 */
68
-	public function setPost() : self {
68
+	public function setPost () : self {
69 69
 		$this->method = self::METHOD_POST;
70 70
 		return $this;
71 71
 	}
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $url
77 77
 	 * @return self for chaining
78 78
 	 */
79
-	public function setUrl( string $url ) : self {
79
+	public function setUrl ( string $url ) : self {
80 80
 		$this->url = $url;
81 81
 		return $this;
82 82
 	}
@@ -88,14 +88,14 @@  discard block
 block discarded – undo
88 88
 	 * @todo Return an iterable object which automatically continues the query only if the last
89 89
 	 *   entry available is reached.
90 90
 	 */
91
-	public function execute() : \stdClass {
91
+	public function execute () : \stdClass {
92 92
 		$curParams = $this->params;
93
-		$sets = [];
93
+		$sets = [ ];
94 94
 		do {
95 95
 			$res = $this->makeRequestInternal( $curParams );
96 96
 
97 97
 			$this->handleErrorAndWarnings( $res );
98
-			$sets[] = $res;
98
+			$sets[ ] = $res;
99 99
 
100 100
 			$finished = true;
101 101
 			if ( isset( $res->continue ) ) {
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 * @param array $params
114 114
 	 * @return \stdClass
115 115
 	 */
116
-	private function makeRequestInternal( array $params ) : \stdClass {
116
+	private function makeRequestInternal ( array $params ) : \stdClass {
117 117
 		if ( $this->method === self::METHOD_POST ) {
118
-			$params['maxlag'] = self::MAXLAG;
118
+			$params[ 'maxlag' ] = self::MAXLAG;
119 119
 		}
120 120
 		$query = http_build_query( $params );
121 121
 
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 	 * @param string $params
132 132
 	 * @return string
133 133
 	 */
134
-	abstract protected function reallyMakeRequest( string $params ) : string;
134
+	abstract protected function reallyMakeRequest ( string $params ) : string;
135 135
 
136 136
 	/**
137 137
 	 * After a request, set cookies for the next ones
138 138
 	 *
139 139
 	 * @param array $cookies
140 140
 	 */
141
-	protected function setCookies( array $cookies ) : void {
141
+	protected function setCookies ( array $cookies ) : void {
142 142
 		foreach ( $cookies as $cookie ) {
143 143
 			$bits = explode( ';', $cookie );
144
-			[ $name, $value ] = explode( '=', $bits[0] );
144
+			[ $name, $value ] = explode( '=', $bits[ 0 ] );
145 145
 			self::$cookiesToSet[ $name ] = $value;
146 146
 		}
147 147
 	}
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param \stdClass $res
153 153
 	 * @return APIRequestException
154 154
 	 */
155
-	private function getException( \stdClass $res ) : APIRequestException {
155
+	private function getException ( \stdClass $res ) : APIRequestException {
156 156
 		switch ( $res->error->code ) {
157 157
 			case 'missingtitle':
158 158
 				$ex = new MissingPageException;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	 * @param \stdClass $res
176 176
 	 * @throws APIRequestException
177 177
 	 */
178
-	protected function handleErrorAndWarnings( \stdClass $res ) : void {
178
+	protected function handleErrorAndWarnings ( \stdClass $res ) : void {
179 179
 		if ( isset( $res->error ) ) {
180 180
 			throw $this->getException( $res );
181 181
 		} elseif ( isset( $res->warnings ) ) {
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 * @param \stdClass[] $sets
192 192
 	 * @return \stdClass
193 193
 	 */
194
-	private function mergeSets( array $sets ) : \stdClass {
194
+	private function mergeSets ( array $sets ) : \stdClass {
195 195
 		// Use the first set as template
196 196
 		$ret = array_shift( $sets );
197 197
 
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 * @param array|\stdClass $second
209 209
 	 * @return array|\stdClass array
210 210
 	 */
211
-	private function recursiveMerge( $first, $second ) {
211
+	private function recursiveMerge ( $first, $second ) {
212 212
 		$ret = $first;
213 213
 		if ( is_array( $second ) ) {
214 214
 			$ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second;
@@ -226,14 +226,14 @@  discard block
 block discarded – undo
226 226
 	 *
227 227
 	 * @return array
228 228
 	 */
229
-	protected function getHeaders() :array {
229
+	protected function getHeaders () :array {
230 230
 		$ret = self::HEADERS;
231 231
 		if ( self::$cookiesToSet ) {
232
-			$cookies = [];
232
+			$cookies = [ ];
233 233
 			foreach ( self::$cookiesToSet as $cname => $cval ) {
234
-				$cookies[] = trim( "$cname=$cval" );
234
+				$cookies[ ] = trim( "$cname=$cval" );
235 235
 			}
236
-			$ret[] = 'Cookie: ' . implode( '; ', $cookies );
236
+			$ret[ ] = 'Cookie: ' . implode( '; ', $cookies );
237 237
 		}
238 238
 		return $ret;
239 239
 	}
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 * @param array $headers
245 245
 	 * @return string
246 246
 	 */
247
-	protected function buildHeadersString( array $headers ) : string {
247
+	protected function buildHeadersString ( array $headers ) : string {
248 248
 		$ret = '';
249 249
 		foreach ( $headers as $header ) {
250 250
 			$ret .= "$header\r\n";
Please login to merge, or discard this patch.
includes/Message.php 1 patch
Spacing   +10 added lines, -10 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
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @param string $value
25 25
 	 */
26
-	public function __construct( string $value ) {
26
+	public function __construct ( string $value ) {
27 27
 		$this->value = $value;
28 28
 	}
29 29
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param array $args
32 32
 	 * @return self
33 33
 	 */
34
-	public function params( array $args ) : self {
34
+	public function params ( array $args ) : self {
35 35
 		$this->value = strtr( $this->value, $args );
36 36
 		return $this;
37 37
 	}
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @return string
41 41
 	 */
42
-	public function text() : string {
42
+	public function text () : string {
43 43
 		$this->parsePlurals();
44 44
 		return $this->value;
45 45
 	}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * Replace {{$plur|<amount>|sing|plur}}
49 49
 	 */
50
-	protected function parsePlurals() : void {
50
+	protected function parsePlurals () : void {
51 51
 		$reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!';
52 52
 
53 53
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$this->value = preg_replace_callback(
57 57
 			$reg,
58 58
 			static function ( $matches ) {
59
-				return (int)$matches['amount'] > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
59
+				return (int)$matches[ 'amount' ] > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
60 60
 			},
61 61
 			$this->value
62 62
 		);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param string $timeString Full format, e.g. "15 aprile 2019 18:27"
69 69
 	 * @return int
70 70
 	 */
71
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
71
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
72 72
 		$englishTime = str_ireplace(
73 73
 			array_values( self::MONTHS ),
74 74
 			array_keys( self::MONTHS ),
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 * @param string $emptyText
87 87
 	 * @return string
88 88
 	 */
89
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
89
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
90 90
 		if ( count( $data ) > 1 ) {
91 91
 			$last = array_pop( $data );
92 92
 			$ret = implode( ', ', $data ) . " e $last";
93 93
 		} elseif ( $data ) {
94
-			$ret = (string)$data[0];
94
+			$ret = (string)$data[ 0 ];
95 95
 		} else {
96 96
 			$ret = $emptyText;
97 97
 		}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		return $ret;
100 100
 	}
101 101
 
102
-	public function __toString() {
102
+	public function __toString () {
103 103
 		return $this->text();
104 104
 	}
105 105
 }
Please login to merge, or discard this patch.
includes/Task/Task.php 1 patch
Spacing   +5 added lines, -5 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
 
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @return string[]
16 16
 	 */
17
-	abstract protected function getSubtasksMap() : array;
17
+	abstract protected function getSubtasksMap () : array;
18 18
 
19 19
 	/**
20 20
 	 * @param string $subtask Defined in self::SUBTASKS_MAP
21 21
 	 * @return TaskResult
22 22
 	 */
23
-	protected function runSubtask( string $subtask ) : TaskResult {
23
+	protected function runSubtask ( string $subtask ) : TaskResult {
24 24
 		$map = $this->getSubtasksMap();
25 25
 		if ( !isset( $map[ $subtask ] ) ) {
26 26
 			throw new \InvalidArgumentException( "'$subtask' is not a valid task." );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @inheritDoc
35 35
 	 */
36
-	final public function getOperationName(): string {
36
+	final public function getOperationName (): string {
37 37
 		return 'task';
38 38
 	}
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param string $class
44 44
 	 * @return Subtask
45 45
 	 */
46
-	private function getSubtaskInstance( string $class ) : Subtask {
46
+	private function getSubtaskInstance ( string $class ) : Subtask {
47 47
 		/** @var Subtask $ret */
48 48
 		$ret = new $class(
49 49
 			$this->getLogger(),
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
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 abstract class TaskBase extends ContextSource {
16 16
 	/** @var string[] */
17
-	protected $errors = [];
17
+	protected $errors = [ ];
18 18
 	/** @var TaskDataProvider */
19 19
 	protected $dataProvider;
20 20
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param TaskDataProvider $dataProvider
27 27
 	 * @param MessageProvider $mp
28 28
 	 */
29
-	final public function __construct(
29
+	final public function __construct (
30 30
 		LoggerInterface $logger,
31 31
 		Wiki $wiki,
32 32
 		TaskDataProvider $dataProvider,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return TaskResult
43 43
 	 */
44
-	final public function run() : TaskResult {
44
+	final public function run () : TaskResult {
45 45
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
46 46
 		$opName = $this->getOperationName();
47 47
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -72,19 +72,19 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return int One of the STATUS_* constants
74 74
 	 */
75
-	abstract protected function runInternal() : int;
75
+	abstract protected function runInternal () : int;
76 76
 
77 77
 	/**
78 78
 	 * How this operation should be called in logs
79 79
 	 *
80 80
 	 * @return string
81 81
 	 */
82
-	abstract public function getOperationName() : string;
82
+	abstract public function getOperationName () : string;
83 83
 
84 84
 	/**
85 85
 	 * @return TaskDataProvider
86 86
 	 */
87
-	protected function getDataProvider() : TaskDataProvider {
87
+	protected function getDataProvider () : TaskDataProvider {
88 88
 		return $this->dataProvider;
89 89
 	}
90 90
 }
Please login to merge, or discard this patch.
includes/Exception/CannotLoginException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Exception;
4 4
 
Please login to merge, or discard this patch.
includes/Exception/MessageNotFoundException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Exception;
4 4
 
Please login to merge, or discard this patch.
includes/Exception/MessagesPageDoesNotExistException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Exception;
4 4
 
Please login to merge, or discard this patch.