Passed
Push — master ( 80c5b5...c72e95 )
by Daimona
01:50
created
includes/Request/CurlRequest.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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @inheritDoc
13 13
 	 */
14
-	protected function reallyMakeRequest( string $params ) : string {
14
+	protected function reallyMakeRequest ( string $params ) : string {
15 15
 		$curl = curl_init();
16 16
 		if ( $curl === false ) {
17 17
 			throw new APIRequestException( 'Cannot open cURL handler.' );
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 * @return int
54 54
 	 * @internal Only used as CB for cURL
55 55
 	 */
56
-	public function headersHandler( $ch, string $header ) : int {
56
+	public function headersHandler ( $ch, string $header ) : int {
57 57
 		$bits = explode( ':', $header, 2 );
58
-		if ( trim( $bits[0] ) === 'Set-Cookie' ) {
59
-			$this->newCookies[] = $bits[1];
58
+		if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
59
+			$this->newCookies[ ] = $bits[ 1 ];
60 60
 		}
61 61
 		// @phan-suppress-next-line PhanTypeMismatchReturn WTF? Why does phan thinks this is a string?
62 62
 		return strlen( $header );
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 = self::$url;
20 20
 		if ( $this->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/Bot.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;
4 4
 
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 	const VERSION = 1.0;
13 13
 
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		$this->logger = new Logger;
16 16
 	}
17 17
 
18 18
 	/**
19 19
 	 * Entry point for the whole process
20 20
 	 */
21
-	public function run() {
21
+	public function run () {
22 22
 		$this->logger->info( 'Starting full process.' );
23 23
 		$manager = new TaskManager;
24 24
 		$res = $manager->run( TaskManager::MODE_COMPLETE );
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string $task
37 37
 	 */
38
-	public function runSingle( string $task ) {
38
+	public function runSingle ( string $task ) {
39 39
 		$this->logger->info( "Starting single task $task." );
40 40
 		$manager = new TaskManager;
41 41
 		$res = $manager->run( TaskManager::MODE_SINGLE, $task );
Please login to merge, or discard this patch.
includes/Task/Task.php 1 patch
Spacing   +8 added lines, -8 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
 	const STATUS_OK = 0;
15 15
 	const STATUS_ERROR = 1;
16 16
 	/** @var string[] */
17
-	protected $errors = [];
17
+	protected $errors = [ ];
18 18
 	/** @var TaskDataProvider */
19 19
 	private $dataProvider;
20 20
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param TaskDataProvider $dataProvider
25 25
 	 */
26
-	final public function __construct( TaskDataProvider $dataProvider ) {
26
+	final public function __construct ( TaskDataProvider $dataProvider ) {
27 27
 		set_exception_handler( [ $this, 'handleException' ] );
28 28
 		set_error_handler( [ $this, 'handleError' ] );
29 29
 		parent::__construct();
30 30
 		$this->dataProvider = $dataProvider;
31 31
 	}
32 32
 
33
-	public function __destruct() {
33
+	public function __destruct () {
34 34
 		restore_error_handler();
35 35
 		restore_exception_handler();
36 36
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return TaskResult
42 42
 	 */
43
-	abstract public function run() : TaskResult;
43
+	abstract public function run () : TaskResult;
44 44
 
45 45
 	/**
46 46
 	 * Exception handler.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param \Throwable $ex
49 49
 	 * @protected
50 50
 	 */
51
-	public function handleException( \Throwable $ex ) {
51
+	public function handleException ( \Throwable $ex ) {
52 52
 		$this->getLogger()->error(
53 53
 			get_class( $ex ) . ': ' .
54 54
 			$ex->getMessage() . "\nTrace:\n" .
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	 * @param int $errline
66 66
 	 * @protected
67 67
 	 */
68
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
68
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
69 69
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
70 70
 	}
71 71
 
72 72
 	/**
73 73
 	 * @return TaskDataProvider
74 74
 	 */
75
-	protected function getDataProvider() : TaskDataProvider {
75
+	protected function getDataProvider () : TaskDataProvider {
76 76
 		return $this->dataProvider;
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
includes/Exception/EditException.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/Task/CreatePages.php 1 patch
Spacing   +11 added lines, -11 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
 	 * @inheritDoc
15 15
 	 */
16
-	public function run() : TaskResult {
16
+	public function run () : TaskResult {
17 17
 		$this->getLogger()->info( 'Starting task CreatePages' );
18 18
 		$users = $this->getDataProvider()->getUsersToProcess();
19 19
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param string $user
36 36
 	 * @param array $groups
37 37
 	 */
38
-	protected function processUser( string $user, array $groups ) {
38
+	protected function processUser ( string $user, array $groups ) {
39 39
 		try {
40 40
 			$num = $this->getLastPageNum( $user ) + 1;
41 41
 		} catch ( TaskException $e ) {
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 	 * @return int
66 66
 	 * @throws TaskException
67 67
 	 */
68
-	protected function getLastPageNum( string $user ) : int {
68
+	protected function getLastPageNum ( string $user ) : int {
69 69
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
70
-		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1];
70
+		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ];
71 71
 		$params = [
72 72
 			'action' => 'query',
73 73
 			'list' => 'allpages',
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 	 * @param string $user
103 103
 	 * @param array $groups
104 104
 	 */
105
-	protected function createPage( string $title, string $user, array $groups ) {
105
+	protected function createPage ( string $title, string $user, array $groups ) {
106 106
 		$this->getLogger()->info( "Creating page $title" );
107 107
 		$text = $this->getConfig()->get( 'ric-page-text' );
108 108
 		$textParams = [
109 109
 			'$user' => $user,
110
-			'$date' => $groups['sysop'],
111
-			'$burocrate' => $groups['bureaucrat'] ?? '',
112
-			'$checkuser' => $groups['checkuser'] ?? ''
110
+			'$date' => $groups[ 'sysop' ],
111
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
112
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
113 113
 		];
114 114
 		$text = strtr( $text, $textParams );
115 115
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @param string $title
129 129
 	 * @param string $newText
130 130
 	 */
131
-	protected function createBasePage( string $title, string $newText ) {
131
+	protected function createBasePage ( string $title, string $newText ) {
132 132
 		$this->getLogger()->info( "Creating base page $title" );
133 133
 
134 134
 		$params = [
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $title
146 146
 	 * @param string $newText
147 147
 	 */
148
-	protected function updateBasePage( string $title, string $newText ) {
148
+	protected function updateBasePage ( string $title, string $newText ) {
149 149
 		$this->getLogger()->info( "Updating base page $title" );
150 150
 
151 151
 		$params = [
Please login to merge, or discard this patch.
includes/WikiController.php 1 patch
Spacing   +19 added lines, -19 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
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 	/** @var string[] */
20 20
 	private $tokens;
21 21
 
22
-	public function __construct() {
22
+	public function __construct () {
23 23
 		$this->logger = new Logger;
24 24
 	}
25 25
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @return string
32 32
 	 * @throws MissingPageException
33 33
 	 */
34
-	public function getPageContent( string $title, int $section = null ) : string {
34
+	public function getPageContent ( string $title, int $section = null ) : string {
35 35
 		$this->logger->debug( "Retrieving page $title" );
36 36
 		$params = [
37 37
 			'action' => 'query',
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 		];
43 43
 
44 44
 		if ( $section !== null ) {
45
-			$params['rvsection'] = $section;
45
+			$params[ 'rvsection' ] = $section;
46 46
 		}
47 47
 
48 48
 		$req = RequestBase::newFromParams( $params );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 			throw new MissingPageException( $title );
53 53
 		}
54 54
 
55
-		return $page->revisions[0]->slots->main->{ '*' };
55
+		return $page->revisions[ 0 ]->slots->main->{ '*' };
56 56
 	}
57 57
 
58 58
 	/**
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @param array $params
62 62
 	 * @throws EditException
63 63
 	 */
64
-	public function editPage( array $params ) {
64
+	public function editPage ( array $params ) {
65 65
 		$this->login();
66 66
 
67 67
 		$params = [
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return string
84 84
 	 * @fixme Not the right place for this
85 85
 	 */
86
-	public static function getTimeWithArticle( int $timestamp ) : string {
86
+	public static function getTimeWithArticle ( int $timestamp ) : string {
87 87
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
88 88
 		$timeString = strftime( '%e %B alle %R', $timestamp );
89 89
 		// Remove the left space if day has a single digit
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 	 * @fixme Not the right place for this
103 103
 	 * @todo Is there a better way?
104 104
 	 */
105
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
105
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
106 106
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
107 107
 		$bits = strptime( $timeString, '%e %m %Y alle %H:%M' );
108 108
 		$timestamp = mktime(
109
-			$bits['tm_hour'],
110
-			$bits['tm_min'],
109
+			$bits[ 'tm_hour' ],
110
+			$bits[ 'tm_min' ],
111 111
 			0,
112
-			$bits['tm_mon'] + 1,
113
-			$bits['tm_mday'],
114
-			$bits['tm_year'] + 1900
112
+			$bits[ 'tm_mon' ] + 1,
113
+			$bits[ 'tm_mday' ],
114
+			$bits[ 'tm_year' ] + 1900
115 115
 		);
116 116
 		setlocale( LC_TIME, $oldLoc );
117 117
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
122 122
 	 * @throws LoginException
123 123
 	 */
124
-	public function login() {
124
+	public function login () {
125 125
 		if ( self::$loggedIn ) {
126 126
 			$this->logger->debug( 'Already logged in' );
127 127
 			return;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 		self::$loggedIn = true;
150 150
 		// Clear tokens cache
151
-		$this->tokens = [];
151
+		$this->tokens = [ ];
152 152
 		$this->logger->info( 'Login succeeded' );
153 153
 	}
154 154
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @param string $type
159 159
 	 * @return string
160 160
 	 */
161
-	public function getToken( string $type ) : string {
161
+	public function getToken ( string $type ) : string {
162 162
 		if ( !isset( $this->tokens[ $type ] ) ) {
163 163
 			$params = [
164 164
 				'action' => 'query',
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 * @param string $title
182 182
 	 * @return int
183 183
 	 */
184
-	public function getPageCreationTS( string $title ) : int {
184
+	public function getPageCreationTS ( string $title ) : int {
185 185
 		$params = [
186 186
 			'action' => 'query',
187 187
 			'prop' => 'revisions',
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 		$res = ( RequestBase::newFromParams( $params ) )->execute();
196 196
 		$data = $res->query->pages;
197
-		return strtotime( reset( $data )->revisions[0]->timestamp );
197
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
198 198
 	}
199 199
 
200 200
 	/**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 * @param string $title
204 204
 	 * @param string $reason
205 205
 	 */
206
-	public function protectPage( string $title, string $reason ) {
206
+	public function protectPage ( string $title, string $reason ) {
207 207
 		$this->logger->info( "Protecting page $title" );
208 208
 		$this->login();
209 209
 
Please login to merge, or discard this patch.
includes/ContextSource.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	/** @var WikiController */
19 19
 	private $controller;
20 20
 
21
-	public function __construct() {
21
+	public function __construct () {
22 22
 		$this->setLogger( new Logger );
23 23
 		$this->setConfig( Config::getInstance() );
24 24
 		$this->setController( new WikiController );
@@ -27,42 +27,42 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @return LoggerInterface
29 29
 	 */
30
-	protected function getLogger() : LoggerInterface {
30
+	protected function getLogger () : LoggerInterface {
31 31
 		return $this->logger;
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * @inheritDoc
36 36
 	 */
37
-	public function setLogger( LoggerInterface $logger ) {
37
+	public function setLogger ( LoggerInterface $logger ) {
38 38
 		$this->logger = $logger;
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * @return Config
43 43
 	 */
44
-	protected function getConfig() : Config {
44
+	protected function getConfig () : Config {
45 45
 		return $this->config;
46 46
 	}
47 47
 
48 48
 	/**
49 49
 	 * @param Config $cfg
50 50
 	 */
51
-	protected function setConfig( Config $cfg ) {
51
+	protected function setConfig ( Config $cfg ) {
52 52
 		$this->config = $cfg;
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * @return WikiController
57 57
 	 */
58
-	protected function getController() : WikiController {
58
+	protected function getController () : WikiController {
59 59
 		return $this->controller;
60 60
 	}
61 61
 
62 62
 	/**
63 63
 	 * @param WikiController $controller
64 64
 	 */
65
-	protected function setController( WikiController $controller ) {
65
+	protected function setController ( WikiController $controller ) {
66 66
 		$this->controller = $controller;
67 67
 	}
68 68
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string $key
73 73
 	 * @return Message
74 74
 	 */
75
-	protected function msg( string $key ) : Message {
75
+	protected function msg ( string $key ) : Message {
76 76
 		return new Message( $key );
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
includes/Message.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;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @param string $key
16 16
 	 */
17
-	public function __construct( string $key ) {
17
+	public function __construct ( string $key ) {
18 18
 		$this->key = $key;
19 19
 		$this->value = Config::getInstance()->getWikiMessage( $key );
20 20
 	}
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param array $args
24 24
 	 * @return self
25 25
 	 */
26
-	public function params( array $args ) : self {
26
+	public function params ( array $args ) : self {
27 27
 		$this->value = strtr( $this->value, $args );
28 28
 		return $this;
29 29
 	}
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	/**
32 32
 	 * @return string
33 33
 	 */
34
-	public function text() : string {
34
+	public function text () : string {
35 35
 		$this->parsePlurals();
36 36
 		return $this->value;
37 37
 	}
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * Replace {{$plur|<amount>|sing|plur}}
41 41
 	 */
42
-	protected function parsePlurals() {
42
+	protected function parsePlurals () {
43 43
 		$this->value = preg_replace_callback(
44 44
 			'!\{\{$plur|(?P<amount>\d+)|(?P<sing>[^}|]+)|(?P<plur>[^|}]+)}}!',
45 45
 			function ( $matches ) {
46
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
46
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
47 47
 			},
48 48
 			$this->value
49 49
 		);
Please login to merge, or discard this patch.