Passed
Push — master ( 600746...5a5fd0 )
by Daimona
01:58
created
src/TaskHelper/TaskDataProvider.php 1 patch
Spacing   +15 added lines, -15 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\TaskHelper;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/** @var User[]|null */
16 16
 	private $processUsers;
17 17
 	/** @var PageRiconferma[] */
18
-	private $createdPages = [];
18
+	private $createdPages = [ ];
19 19
 	/** @var PageRiconferma[]|null */
20 20
 	private $openPages;
21 21
 	/** @var PageRiconferma[]|null */
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	 *
27 27
 	 * @return User[]
28 28
 	 */
29
-	public function getUsersToProcess(): array {
29
+	public function getUsersToProcess (): array {
30 30
 		if ( $this->processUsers === null ) {
31
-			$this->processUsers = [];
31
+			$this->processUsers = [ ];
32 32
 			foreach ( $this->getBotList()->getAdminsList() as $name => $userInfo ) {
33 33
 				if ( $this->shouldAddUser( $userInfo ) ) {
34 34
 					$this->processUsers[ $name ] = new User( $userInfo, $this->getWiki() );
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * @param UserInfo $ui
46 46
 	 * @return bool
47 47
 	 */
48
-	private function shouldAddUser( UserInfo $ui ): bool {
48
+	private function shouldAddUser ( UserInfo $ui ): bool {
49 49
 		$timestamp = $this->getBotList()->getOverrideTimestamp( $ui );
50 50
 		$override = $timestamp !== null;
51 51
 
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	 *
64 64
 	 * @return PageRiconferma[]
65 65
 	 */
66
-	public function getOpenPages(): array {
66
+	public function getOpenPages (): array {
67 67
 		if ( $this->openPages === null ) {
68
-			$this->openPages = [];
68
+			$this->openPages = [ ];
69 69
 			$mainTitle = $this->getOpt( 'main-page-title' );
70 70
 			$params = [
71 71
 				'action' => 'query',
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 			$pages = $this->getWiki()->getRequestFactory()->createStandaloneRequest( $params )->executeAsQuery();
80 80
 			foreach ( $pages->current()->templates as $page ) {
81 81
 				if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) {
82
-					$this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() );
82
+					$this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() );
83 83
 				}
84 84
 			}
85 85
 		}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return PageRiconferma[]
94 94
 	 */
95
-	public function getPagesToClose(): array {
95
+	public function getPagesToClose (): array {
96 96
 		if ( $this->pagesToClose === null ) {
97
-			$this->pagesToClose = [];
97
+			$this->pagesToClose = [ ];
98 98
 			foreach ( $this->getOpenPages() as $page ) {
99 99
 				if ( time() > $page->getEndTimestamp() ) {
100
-					$this->pagesToClose[] = $page;
100
+					$this->pagesToClose[ ] = $page;
101 101
 				}
102 102
 			}
103 103
 		}
@@ -109,21 +109,21 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @param string $name
111 111
 	 */
112
-	public function removeUser( string $name ): void {
112
+	public function removeUser ( string $name ): void {
113 113
 		unset( $this->processUsers[ $name ] );
114 114
 	}
115 115
 
116 116
 	/**
117 117
 	 * @return PageRiconferma[]
118 118
 	 */
119
-	public function getCreatedPages(): array {
119
+	public function getCreatedPages (): array {
120 120
 		return $this->createdPages;
121 121
 	}
122 122
 
123 123
 	/**
124 124
 	 * @param PageRiconferma $page
125 125
 	 */
126
-	public function addCreatedPage( PageRiconferma $page ): void {
127
-		$this->createdPages[] = $page;
126
+	public function addCreatedPage ( PageRiconferma $page ): void {
127
+		$this->createdPages[ ] = $page;
128 128
 	}
129 129
 }
Please login to merge, or discard this patch.
src/Task/Subtask/CreatePages.php 1 patch
Spacing   +13 added lines, -13 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\Subtask;
4 4
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @inheritDoc
19 19
 	 */
20
-	public function runInternal(): int {
20
+	public function runInternal (): int {
21 21
 		$users = $this->getDataProvider()->getUsersToProcess();
22 22
 
23 23
 		if ( !$users ) {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param User $user
38 38
 	 */
39
-	protected function processUser( User $user ): void {
39
+	protected function processUser ( User $user ): void {
40 40
 		$this->getLogger()->info( "Processing user $user" );
41 41
 		try {
42 42
 			$num = $this->getLastPageNum( $user ) + 1;
@@ -71,14 +71,14 @@  discard block
 block discarded – undo
71 71
 	 * @return int
72 72
 	 * @throws TaskException
73 73
 	 */
74
-	protected function getLastPageNum( User $user ): int {
74
+	protected function getLastPageNum ( User $user ): int {
75 75
 		$this->getLogger()->info( "Retrieving previous pages for $user" );
76 76
 
77
-		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1];
77
+		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ];
78 78
 
79 79
 		$prefixes = [ "$unprefixedTitle/$user/" ];
80 80
 		foreach ( $user->getAliases() as $alias ) {
81
-			$prefixes[] = "$unprefixedTitle/$alias/";
81
+			$prefixes[ ] = "$unprefixedTitle/$alias/";
82 82
 		}
83 83
 
84 84
 		$params = [
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		];
91 91
 		$pagesIterator = new AppendIterator();
92 92
 		foreach ( $prefixes as $prefix ) {
93
-			$params['apprefix'] = $prefix;
93
+			$params[ 'apprefix' ] = $prefix;
94 94
 			$res = $this->getWiki()->getRequestFactory()->createStandaloneRequest( $params )->executeAsQuery();
95 95
 			$pagesIterator->append( new NoRewindIterator( $res ) );
96 96
 		}
@@ -116,14 +116,14 @@  discard block
 block discarded – undo
116 116
 	 * @param string $title
117 117
 	 * @param User $user
118 118
 	 */
119
-	protected function createPage( string $title, User $user ): void {
119
+	protected function createPage ( string $title, User $user ): void {
120 120
 		$this->getLogger()->info( "Creating page $title" );
121 121
 		$groups = $user->getGroupsWithDates();
122 122
 		$textParams = [
123 123
 			'$user' => $user->getName(),
124
-			'$date' => $groups['sysop'],
125
-			'$burocrate' => $groups['bureaucrat'] ?? '',
126
-			'$checkuser' => $groups['checkuser'] ?? ''
124
+			'$date' => $groups[ 'sysop' ],
125
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
126
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
127 127
 		];
128 128
 
129 129
 		$params = [
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @param Page $basePage
142 142
 	 * @param string $newText
143 143
 	 */
144
-	protected function createBasePage( Page $basePage, string $newText ): void {
144
+	protected function createBasePage ( Page $basePage, string $newText ): void {
145 145
 		$this->getLogger()->info( "Creating base page $basePage" );
146 146
 
147 147
 		$params = [
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @param Page $basePage
158 158
 	 * @param string $newText
159 159
 	 */
160
-	protected function updateBasePage( Page $basePage, string $newText ): void {
160
+	protected function updateBasePage ( Page $basePage, string $newText ): void {
161 161
 		$this->getLogger()->info( "Updating base page $basePage" );
162 162
 
163 163
 		$params = [
Please login to merge, or discard this patch.
src/ContextSource.php 1 patch
Spacing   +16 added lines, -16 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
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param MessageProvider $mp
38 38
 	 * @param PageBotList $pbl
39 39
 	 */
40
-	public function __construct(
40
+	public function __construct (
41 41
 		LoggerInterface $logger,
42 42
 		WikiGroup $wikiGroup,
43 43
 		MessageProvider $mp,
@@ -53,14 +53,14 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * @return LoggerInterface
55 55
 	 */
56
-	protected function getLogger(): LoggerInterface {
56
+	protected function getLogger (): LoggerInterface {
57 57
 		return $this->logger;
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * @inheritDoc
62 62
 	 */
63
-	public function setLogger( LoggerInterface $logger ): void {
63
+	public function setLogger ( LoggerInterface $logger ): void {
64 64
 		$this->logger = $logger;
65 65
 	}
66 66
 
@@ -70,21 +70,21 @@  discard block
 block discarded – undo
70 70
 	 * @param string $optname
71 71
 	 * @return mixed
72 72
 	 */
73
-	protected function getOpt( string $optname ) {
73
+	protected function getOpt ( string $optname ) {
74 74
 		return $this->getConfig()->get( $optname );
75 75
 	}
76 76
 
77 77
 	/**
78 78
 	 * @return Config
79 79
 	 */
80
-	protected function getConfig(): Config {
80
+	protected function getConfig (): Config {
81 81
 		return $this->config;
82 82
 	}
83 83
 
84 84
 	/**
85 85
 	 * @param Config $cfg
86 86
 	 */
87
-	protected function setConfig( Config $cfg ): void {
87
+	protected function setConfig ( Config $cfg ): void {
88 88
 		$this->config = $cfg;
89 89
 	}
90 90
 
@@ -92,35 +92,35 @@  discard block
 block discarded – undo
92 92
 	 * Shorthand
93 93
 	 * @return Wiki
94 94
 	 */
95
-	protected function getWiki(): Wiki {
95
+	protected function getWiki (): Wiki {
96 96
 		return $this->getWikiGroup()->getMainWiki();
97 97
 	}
98 98
 
99 99
 	/**
100 100
 	 * @return WikiGroup
101 101
 	 */
102
-	protected function getWikiGroup(): WikiGroup {
102
+	protected function getWikiGroup (): WikiGroup {
103 103
 		return $this->wikiGroup;
104 104
 	}
105 105
 
106 106
 	/**
107 107
 	 * @param WikiGroup $wikiGroup
108 108
 	 */
109
-	protected function setWikiGroup( WikiGroup $wikiGroup ): void {
109
+	protected function setWikiGroup ( WikiGroup $wikiGroup ): void {
110 110
 		$this->wikiGroup = $wikiGroup;
111 111
 	}
112 112
 
113 113
 	/**
114 114
 	 * @return MessageProvider
115 115
 	 */
116
-	protected function getMessageProvider(): MessageProvider {
116
+	protected function getMessageProvider (): MessageProvider {
117 117
 		return $this->messageProvider;
118 118
 	}
119 119
 
120 120
 	/**
121 121
 	 * @param MessageProvider $mp
122 122
 	 */
123
-	protected function setMessageProvider( MessageProvider $mp ): void {
123
+	protected function setMessageProvider ( MessageProvider $mp ): void {
124 124
 		$this->messageProvider = $mp;
125 125
 	}
126 126
 
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 	 * @param string $key
131 131
 	 * @return Message
132 132
 	 */
133
-	protected function msg( string $key ): Message {
133
+	protected function msg ( string $key ): Message {
134 134
 		return $this->messageProvider->getMessage( $key );
135 135
 	}
136 136
 
137 137
 	/**
138 138
 	 * @return PageBotList
139 139
 	 */
140
-	public function getBotList(): PageBotList {
140
+	public function getBotList (): PageBotList {
141 141
 		return $this->pageBotList;
142 142
 	}
143 143
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @param string $title
148 148
 	 * @return Page
149 149
 	 */
150
-	protected function getPage( string $title ): Page {
150
+	protected function getPage ( string $title ): Page {
151 151
 		return new Page( $title, $this->getWiki() );
152 152
 	}
153 153
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @param string $name
158 158
 	 * @return User
159 159
 	 */
160
-	protected function getUser( string $name ): User {
160
+	protected function getUser ( string $name ): User {
161 161
 		$ui = $this->getBotList()->getUserInfo( $name );
162 162
 		return new User( $ui, $this->getWiki() );
163 163
 	}
Please login to merge, or discard this patch.
src/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
 		}
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
 		foreach ( $http_response_header as $header ) {
29 29
 			/** @var string[] $bits */
30 30
 			$bits = explode( ':', $header, 2 );
31
-			if ( trim( $bits[0] ) === 'Set-Cookie' ) {
32
-				$this->saveNewCookie( $bits[1] );
31
+			if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
32
+				$this->saveNewCookie( $bits[ 1 ] );
33 33
 			}
34 34
 		}
35 35
 
Please login to merge, or discard this patch.
src/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
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	 * @inheritDoc
14 14
 	 * @throws APIRequestException
15 15
 	 */
16
-	protected function reallyMakeRequest( string $params ): string {
16
+	protected function reallyMakeRequest ( string $params ): string {
17 17
 		$curl = curl_init();
18 18
 		if ( $curl === false ) {
19 19
 			throw new APIRequestException( 'Cannot open cURL handler.' );
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 	 * @internal Only used as CB for cURL (CURLOPT_HEADERFUNCTION)
60 60
 	 * @suppress PhanUnreferencedPublicMethod,PhanUnusedPublicNoOverrideMethodParameter
61 61
 	 */
62
-	public function headersHandler( $ch, string $header ): int {
62
+	public function headersHandler ( $ch, string $header ): int {
63 63
 		/** @var string[] $bits */
64 64
 		$bits = explode( ':', $header, 2 );
65
-		if ( trim( $bits[0] ) === 'Set-Cookie' ) {
66
-			$this->saveNewCookie( $bits[1] );
65
+		if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
66
+			$this->saveNewCookie( $bits[ 1 ] );
67 67
 		}
68 68
 
69 69
 		return strlen( $header );
Please login to merge, or discard this patch.
src/Request/RequestBase.php 1 patch
Spacing   +27 added lines, -27 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
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	/** @var string */
42 42
 	protected $method = self::METHOD_GET;
43 43
 	/** @var string[] */
44
-	protected $newCookies = [];
44
+	protected $newCookies = [ ];
45 45
 	/** @var callable|null */
46 46
 	private $cookiesHandlerCallback;
47 47
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param string $domain
58 58
 	 * @param callable $cookiesHandlerCallback
59 59
 	 */
60
-	public function __construct(
60
+	public function __construct (
61 61
 		LoggerInterface $logger,
62 62
 		array $params,
63 63
 		string $domain,
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return self For chaining
76 76
 	 */
77
-	public function setPost(): self {
77
+	public function setPost (): self {
78 78
 		$this->method = self::METHOD_POST;
79 79
 		return $this;
80 80
 	}
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param string[] $cookies
84 84
 	 * @return self For chaining
85 85
 	 */
86
-	public function setCookies( array $cookies ): self {
86
+	public function setCookies ( array $cookies ): self {
87 87
 		$this->cookiesToSet = $cookies;
88 88
 		return $this;
89 89
 	}
@@ -92,12 +92,12 @@  discard block
 block discarded – undo
92 92
 	 * Execute a query request
93 93
 	 * @return Generator
94 94
 	 */
95
-	public function executeAsQuery(): Generator {
96
-		if ( ( $this->params['action'] ?? false ) !== 'query' ) {
95
+	public function executeAsQuery (): Generator {
96
+		if ( ( $this->params[ 'action' ] ?? false ) !== 'query' ) {
97 97
 			throw new BadMethodCallException( 'Not an ApiQuery!' );
98 98
 		}
99 99
 		// TODO Is this always correct?
100
-		$key = $this->params['list'] ?? 'pages';
100
+		$key = $this->params[ 'list' ] ?? 'pages';
101 101
 		$curParams = $this->params;
102 102
 		$lim = $this->parseLimit();
103 103
 		do {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * Execute a request that doesn't need any continuation.
127 127
 	 * @return stdClass
128 128
 	 */
129
-	public function executeSingle(): stdClass {
129
+	public function executeSingle (): stdClass {
130 130
 		$curParams = $this->params;
131 131
 		$res = $this->makeRequestInternal( $curParams );
132 132
 		$this->handleErrorAndWarnings( $res );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	/**
137 137
 	 * @return int
138 138
 	 */
139
-	private function parseLimit(): int {
139
+	private function parseLimit (): int {
140 140
 		foreach ( $this->params as $name => $val ) {
141 141
 			if ( substr( $name, -strlen( 'limit' ) ) === 'limit' ) {
142 142
 				return $val === 'max' ? -1 : (int)$val;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param string $resKey
154 154
 	 * @return int|null
155 155
 	 */
156
-	private function countQueryResults( stdClass $res, string $resKey ): ?int {
156
+	private function countQueryResults ( stdClass $res, string $resKey ): ?int {
157 157
 		if ( !isset( $res->query->$resKey ) ) {
158 158
 			return null;
159 159
 		}
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 	 * @phan-param array<int|string|bool> $params
182 182
 	 * @return stdClass
183 183
 	 */
184
-	private function makeRequestInternal( array $params ): stdClass {
184
+	private function makeRequestInternal ( array $params ): stdClass {
185 185
 		if ( $this->method === self::METHOD_POST ) {
186
-			$params['maxlag'] = self::MAXLAG;
186
+			$params[ 'maxlag' ] = self::MAXLAG;
187 187
 		}
188
-		if ( !isset( $params['assert'] ) ) {
189
-			$params['assert'] = 'user';
188
+		if ( !isset( $params[ 'assert' ] ) ) {
189
+			$params[ 'assert' ] = 'user';
190 190
 		}
191 191
 		$query = http_build_query( $params );
192 192
 
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @param string $cookie "{key}={value}"
208 208
 	 */
209
-	protected function saveNewCookie( string $cookie ): void {
209
+	protected function saveNewCookie ( string $cookie ): void {
210 210
 		$bits = explode( ';', $cookie );
211
-		[ $name, $value ] = explode( '=', $bits[0] );
212
-		$this->newCookies[$name] = $value;
211
+		[ $name, $value ] = explode( '=', $bits[ 0 ] );
212
+		$this->newCookies[ $name ] = $value;
213 213
 	}
214 214
 
215 215
 	/**
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	 * @param string $params
219 219
 	 * @return string
220 220
 	 */
221
-	abstract protected function reallyMakeRequest( string $params ): string;
221
+	abstract protected function reallyMakeRequest ( string $params ): string;
222 222
 
223 223
 	/**
224 224
 	 * Get a specific exception class depending on the error code
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @param stdClass $res
227 227
 	 * @return APIRequestException
228 228
 	 */
229
-	private function getException( stdClass $res ): APIRequestException {
229
+	private function getException ( stdClass $res ): APIRequestException {
230 230
 		switch ( $res->error->code ) {
231 231
 			case 'missingtitle':
232 232
 				$ex = new MissingPageException;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @param stdClass $res
253 253
 	 * @throws APIRequestException
254 254
 	 */
255
-	protected function handleErrorAndWarnings( stdClass $res ): void {
255
+	protected function handleErrorAndWarnings ( stdClass $res ): void {
256 256
 		if ( isset( $res->error ) ) {
257 257
 			throw $this->getException( $res );
258 258
 		}
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @return string[]
270 270
 	 */
271
-	protected function getHeaders(): array {
271
+	protected function getHeaders (): array {
272 272
 		$ret = self::HEADERS;
273 273
 		if ( $this->cookiesToSet ) {
274
-			$cookies = [];
274
+			$cookies = [ ];
275 275
 			foreach ( $this->cookiesToSet as $cname => $cval ) {
276
-				$cookies[] = trim( "$cname=$cval" );
276
+				$cookies[ ] = trim( "$cname=$cval" );
277 277
 			}
278
-			$ret[] = 'Cookie: ' . implode( '; ', $cookies );
278
+			$ret[ ] = 'Cookie: ' . implode( '; ', $cookies );
279 279
 		}
280 280
 		return $ret;
281 281
 	}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * @param string[] $headers
287 287
 	 * @return string
288 288
 	 */
289
-	protected function buildHeadersString( array $headers ): string {
289
+	protected function buildHeadersString ( array $headers ): string {
290 290
 		$ret = '';
291 291
 		foreach ( $headers as $header ) {
292 292
 			$ret .= "$header\r\n";
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 * @param string $actualParams
299 299
 	 * @return string
300 300
 	 */
301
-	protected function getDebugURL( string $actualParams ): string {
301
+	protected function getDebugURL ( string $actualParams ): string {
302 302
 		return strpos( $this->url, 'login' ) !== false
303 303
 			? '[Login request]'
304 304
 			: "{$this->url}?$actualParams";
Please login to merge, or discard this patch.
src/Request/RequestFactory.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\Request;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	 * @param LoggerInterface $logger
15 15
 	 * @param string $domain
16 16
 	 */
17
-	public function __construct( LoggerInterface $logger, string $domain ) {
17
+	public function __construct ( LoggerInterface $logger, string $domain ) {
18 18
 		$this->logger = $logger;
19 19
 		$this->domain = $domain;
20 20
 	}
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param callable $cookiesCallback
27 27
 	 * @return RequestBase
28 28
 	 */
29
-	public function createRequest( array $params, array $cookies, callable $cookiesCallback ) {
29
+	public function createRequest ( array $params, array $cookies, callable $cookiesCallback ) {
30 30
 		$ret = extension_loaded( 'curl' )
31 31
 			? new CurlRequest( $this->logger, $params, $this->domain, $cookiesCallback )
32 32
 			: new NativeRequest( $this->logger, $params, $this->domain, $cookiesCallback );
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @phan-param array<int|string|bool> $params
42 42
 	 * @return RequestBase
43 43
 	 */
44
-	public function createStandaloneRequest( array $params ) {
44
+	public function createStandaloneRequest ( array $params ) {
45 45
 		/** @param string[] $newCookies */
46 46
 		$cookiesCallback = function ( array $newCookies ) {
47 47
 			$this->logger->warning(
Please login to merge, or discard this patch.
src/Wiki/Wiki.php 1 patch
Spacing   +22 added lines, -22 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\Wiki;
4 4
 
@@ -31,14 +31,14 @@  discard block
 block discarded – undo
31 31
 	/** @var string Used for logging */
32 32
 	private $pagePrefix = '';
33 33
 	/** @var string[] */
34
-	private $cookies = [];
34
+	private $cookies = [ ];
35 35
 
36 36
 	/**
37 37
 	 * @param LoginInfo $li
38 38
 	 * @param LoggerInterface $logger
39 39
 	 * @param RequestFactory $requestFactory
40 40
 	 */
41
-	public function __construct(
41
+	public function __construct (
42 42
 		LoginInfo $li,
43 43
 		LoggerInterface $logger,
44 44
 		RequestFactory $requestFactory
@@ -51,35 +51,35 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * @return LoginInfo
53 53
 	 */
54
-	public function getLoginInfo(): LoginInfo {
54
+	public function getLoginInfo (): LoginInfo {
55 55
 		return $this->loginInfo;
56 56
 	}
57 57
 
58 58
 	/**
59 59
 	 * @return RequestFactory
60 60
 	 */
61
-	public function getRequestFactory(): RequestFactory {
61
+	public function getRequestFactory (): RequestFactory {
62 62
 		return $this->requestFactory;
63 63
 	}
64 64
 
65 65
 	/**
66 66
 	 * @param string $prefix
67 67
 	 */
68
-	public function setPagePrefix( string $prefix ): void {
68
+	public function setPagePrefix ( string $prefix ): void {
69 69
 		$this->pagePrefix = $prefix;
70 70
 	}
71 71
 
72 72
 	/**
73 73
 	 * @param string $ident
74 74
 	 */
75
-	public function setLocalUserIdentifier( string $ident ): void {
75
+	public function setLocalUserIdentifier ( string $ident ): void {
76 76
 		$this->localUserIdentifier = $ident;
77 77
 	}
78 78
 
79 79
 	/**
80 80
 	 * @return string
81 81
 	 */
82
-	public function getLocalUserIdentifier(): string {
82
+	public function getLocalUserIdentifier (): string {
83 83
 		return $this->localUserIdentifier;
84 84
 	}
85 85
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @param string $title
88 88
 	 * @param int|null $section
89 89
 	 */
90
-	private function logRead( string $title, int $section = null ): void {
90
+	private function logRead ( string $title, int $section = null ): void {
91 91
 		$fullTitle = $this->pagePrefix . $title;
92 92
 		$msg = "Retrieving content of $fullTitle" . ( $section !== null ? ", section $section" : '' );
93 93
 		$this->logger->info( $msg );
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @throws MissingPageException
103 103
 	 * @throws MissingSectionException
104 104
 	 */
105
-	public function getPageContent( string $title, int $section = null ): string {
105
+	public function getPageContent ( string $title, int $section = null ): string {
106 106
 		$this->logRead( $title, $section );
107 107
 		$params = [
108 108
 			'action' => 'query',
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		];
114 114
 
115 115
 		if ( $section !== null ) {
116
-			$params['rvsection'] = $section;
116
+			$params[ 'rvsection' ] = $section;
117 117
 		}
118 118
 
119 119
 		$req = $this->buildRequest( $params );
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			throw new MissingPageException( $title );
123 123
 		}
124 124
 
125
-		$mainSlot = $page->revisions[0]->slots->main;
125
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
126 126
 
127 127
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
128 128
 			throw new MissingSectionException( $title, $section );
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * @phan-param array<int|string|bool> $params
138 138
 	 * @throws EditException
139 139
 	 */
140
-	public function editPage( array $params ): void {
140
+	public function editPage ( array $params ): void {
141 141
 		$this->login();
142 142
 
143 143
 		$params = [
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		] + $params;
147 147
 
148 148
 		if ( BOT_EDITS === true ) {
149
-			$params['bot'] = 1;
149
+			$params[ 'bot' ] = 1;
150 150
 		}
151 151
 
152 152
 		$res = $this->buildRequest( $params )->setPost()->executeSingle();
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
165 165
 	 * @throws LoginException
166 166
 	 */
167
-	public function login(): void {
167
+	public function login (): void {
168 168
 		if ( $this->loginInfo === null ) {
169 169
 			throw new CannotLoginException( 'Missing login data' );
170 170
 		}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 		$this->loggedIn = true;
196 196
 		// Clear tokens cache
197
-		$this->tokens = [];
197
+		$this->tokens = [ ];
198 198
 		$this->logger->info( 'Login succeeded' );
199 199
 	}
200 200
 
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $type
205 205
 	 * @return string
206 206
 	 */
207
-	public function getToken( string $type ): string {
207
+	public function getToken ( string $type ): string {
208 208
 		if ( !isset( $this->tokens[ $type ] ) ) {
209 209
 			$params = [
210 210
 				'action' => 'query',
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @param string $title
225 225
 	 * @return int
226 226
 	 */
227
-	public function getPageCreationTS( string $title ): int {
227
+	public function getPageCreationTS ( string $title ): int {
228 228
 		$params = [
229 229
 			'action' => 'query',
230 230
 			'prop' => 'revisions',
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		];
237 237
 
238 238
 		$page = $this->buildRequest( $params )->executeAsQuery()->current();
239
-		return strtotime( $page->revisions[0]->timestamp );
239
+		return strtotime( $page->revisions[ 0 ]->timestamp );
240 240
 	}
241 241
 
242 242
 	/**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @param string $title
246 246
 	 * @param string $reason
247 247
 	 */
248
-	public function protectPage( string $title, string $reason ): void {
248
+	public function protectPage ( string $title, string $reason ): void {
249 249
 		$fullTitle = $this->pagePrefix . $title;
250 250
 		$this->logger->info( "Protecting page $fullTitle" );
251 251
 		$this->login();
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 * @param string $username
269 269
 	 * @param string $reason
270 270
 	 */
271
-	public function blockUser( string $username, string $reason ): void {
271
+	public function blockUser ( string $username, string $reason ): void {
272 272
 		$this->logger->info( "Blocking user $username" );
273 273
 		$this->login();
274 274
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 	 * @phan-param array<int|string|bool> $params
296 296
 	 * @return RequestBase
297 297
 	 */
298
-	private function buildRequest( array $params ): RequestBase {
298
+	private function buildRequest ( array $params ): RequestBase {
299 299
 		return $this->requestFactory->createRequest(
300 300
 			$params,
301 301
 			$this->cookies,
Please login to merge, or discard this patch.