Passed
Push — master ( 6c474f...4deb8c )
by Daimona
01:38
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
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	 * @inheritDoc
13 13
 	 * @throws APIRequestException
14 14
 	 */
15
-	protected function reallyMakeRequest( string $params ) : string {
15
+	protected function reallyMakeRequest ( string $params ) : string {
16 16
 		$curl = curl_init();
17 17
 		if ( $curl === false ) {
18 18
 			throw new APIRequestException( 'Cannot open cURL handler.' );
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 	 * @return int
55 55
 	 * @internal Only used as CB for cURL
56 56
 	 */
57
-	public function headersHandler( $ch, string $header ) : int {
57
+	public function headersHandler ( $ch, string $header ) : int {
58 58
 		$bits = explode( ':', $header, 2 );
59
-		if ( trim( $bits[0] ) === 'Set-Cookie' ) {
60
-			$this->newCookies[] = $bits[1];
59
+		if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
60
+			$this->newCookies[ ] = $bits[ 1 ];
61 61
 		}
62 62
 
63 63
 		return strlen( $header );
Please login to merge, or discard this patch.
includes/Wiki/Page/PageRiconferma.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\Page;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	private $supportSection;
14 14
 	private $opposeSection;
15 15
 	/** @var array Counts of votes for each section */
16
-	private $sectionCounts = [];
16
+	private $sectionCounts = [ ];
17 17
 
18 18
 	// Possible outcomes of a vote
19 19
 	public const OUTCOME_OK = 0;
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * because they can vary depending on whether the page is a vote, which is relatively
33 33
 	 * expensive to know since it requires parsing the content of the page.
34 34
 	 */
35
-	private function defineSections() {
35
+	private function defineSections () {
36 36
 		$this->supportSection = $this->isVote() ? 3 : 0;
37 37
 		$this->opposeSection = $this->isVote() ? 4 : 3;
38 38
 	}
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return User
44 44
 	 */
45
-	public function getUser() : User {
46
-		$name = explode( '/', $this->title )[2];
45
+	public function getUser () : User {
46
+		$name = explode( '/', $this->title )[ 2 ];
47 47
 		return new User( $name );
48 48
 	}
49 49
 
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @return int
54 54
 	 */
55
-	public function getNum() : int {
55
+	public function getNum () : int {
56 56
 		$bits = explode( '/', $this->getTitle() );
57 57
 		return intval( end( $bits ) );
58 58
 	}
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 *
63 63
 	 * @return string
64 64
 	 */
65
-	public function getUserNum() : string {
66
-		return explode( '/', $this->getTitle(), 3 )[2];
65
+	public function getUserNum () : string {
66
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
67 67
 	}
68 68
 
69 69
 	/**
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string
73 73
 	 */
74
-	public function getBaseTitle() : string {
74
+	public function getBaseTitle () : string {
75 75
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
76 76
 	}
77 77
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @return int
82 82
 	 */
83
-	public function getOpposingCount() : int {
83
+	public function getOpposingCount () : int {
84 84
 		$this->defineSections();
85 85
 		return $this->getCountForSection( $this->opposeSection );
86 86
 	}
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return int
92 92
 	 * @throws \BadMethodCallException
93 93
 	 */
94
-	public function getSupportCount() : int {
94
+	public function getSupportCount () : int {
95 95
 		if ( !$this->isVote() ) {
96 96
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
97 97
 		}
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
 	 * @param int $secNum
106 106
 	 * @return int
107 107
 	 */
108
-	protected function getCountForSection( int $secNum ) : int {
108
+	protected function getCountForSection ( int $secNum ) : int {
109 109
 		if ( !isset( $this->sectionCounts[ $secNum ] ) ) {
110 110
 			$content = $this->controller->getPageContent( $this->title, $secNum );
111 111
 			// Let's hope that this is good enough...
112
-			$this->sectionCounts[$secNum] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content );
112
+			$this->sectionCounts[ $secNum ] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content );
113 113
 		}
114
-		return $this->sectionCounts[$secNum];
114
+		return $this->sectionCounts[ $secNum ];
115 115
 	}
116 116
 
117 117
 	/**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 *
120 120
 	 * @return int
121 121
 	 */
122
-	protected function getQuorum() : int {
122
+	protected function getQuorum () : int {
123 123
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
124
-		return intval( $this->getMatch( $reg )[1] );
124
+		return intval( $this->getMatch( $reg )[ 1 ] );
125 125
 	}
126 126
 
127 127
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return bool
131 131
 	 */
132
-	public function hasOpposition() : bool {
132
+	public function hasOpposition () : bool {
133 133
 		return $this->getOpposingCount() >= self::REQUIRED_OPPOSE;
134 134
 	}
135 135
 
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 *
139 139
 	 * @return int One of the OUTCOME_* constants
140 140
 	 */
141
-	public function getOutcome() : int {
141
+	public function getOutcome () : int {
142 142
 		if ( !$this->isVote() ) {
143 143
 			return self::OUTCOME_OK;
144 144
 		}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @throws \BadMethodCallException
162 162
 	 * @throws \LogicException
163 163
 	 */
164
-	public function getOutcomeText() : string {
164
+	public function getOutcomeText () : string {
165 165
 		if ( !$this->isVote() ) {
166 166
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
167 167
 		}
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 *
196 196
 	 * @return bool
197 197
 	 */
198
-	public function isVote() : bool {
198
+	public function isVote () : bool {
199 199
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
200 200
 		return !$this->matches( $sectionReg );
201 201
 	}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @return int
207 207
 	 */
208
-	public function getCreationTimestamp() : int {
208
+	public function getCreationTimestamp () : int {
209 209
 		return $this->controller->getPageCreationTS( $this->title );
210 210
 	}
211 211
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	 *
215 215
 	 * @return int
216 216
 	 */
217
-	public function getEndTimestamp() : int {
217
+	public function getEndTimestamp () : int {
218 218
 		if ( $this->isVote() ) {
219 219
 			$reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!";
220 220
 			list( , $hours, $day ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.
includes/Wiki/Controller.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\Wiki;
4 4
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @param string $domain The URL of the wiki, if different from default
29 29
 	 */
30
-	public function __construct( string $domain = DEFAULT_URL ) {
30
+	public function __construct ( string $domain = DEFAULT_URL ) {
31 31
 		$this->logger = new Logger;
32 32
 		$this->domain = $domain;
33 33
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @throws MissingPageException
42 42
 	 * @throws MissingSectionException
43 43
 	 */
44
-	public function getPageContent( string $title, int $section = null ) : string {
44
+	public function getPageContent ( string $title, int $section = null ) : string {
45 45
 		$msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' );
46 46
 		$this->logger->debug( $msg );
47 47
 		$params = [
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		];
54 54
 
55 55
 		if ( $section !== null ) {
56
-			$params['rvsection'] = $section;
56
+			$params[ 'rvsection' ] = $section;
57 57
 		}
58 58
 
59 59
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			throw new MissingPageException( $title );
64 64
 		}
65 65
 
66
-		$mainSlot = $page->revisions[0]->slots->main;
66
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
67 67
 
68 68
 		// @phan-suppress-next-line PhanImpossibleTypeComparison $section can be null
69 69
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param array $params
79 79
 	 * @throws EditException
80 80
 	 */
81
-	public function editPage( array $params ) {
81
+	public function editPage ( array $params ) {
82 82
 		$this->login();
83 83
 
84 84
 		$params = [
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 		] + $params;
88 88
 
89 89
 		if ( Config::getInstance()->get( 'bot-edits' ) ) {
90
-			$params['bot'] = 1;
90
+			$params[ 'bot' ] = 1;
91 91
 		}
92 92
 
93 93
 		$res = RequestBase::newFromParams( $params )
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
109 109
 	 * @throws LoginException
110 110
 	 */
111
-	public function login() {
111
+	public function login () {
112 112
 		if ( self::$loggedIn ) {
113 113
 			return;
114 114
 		}
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
 		self::$loggedIn = true;
137 137
 		// Clear tokens cache
138
-		$this->tokens = [];
138
+		$this->tokens = [ ];
139 139
 		$this->logger->info( 'Login succeeded' );
140 140
 	}
141 141
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @param string $type
146 146
 	 * @return string
147 147
 	 */
148
-	public function getToken( string $type ) : string {
148
+	public function getToken ( string $type ) : string {
149 149
 		if ( !isset( $this->tokens[ $type ] ) ) {
150 150
 			$params = [
151 151
 				'action' => 'query',
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param string $title
169 169
 	 * @return int
170 170
 	 */
171
-	public function getPageCreationTS( string $title ) : int {
171
+	public function getPageCreationTS ( string $title ) : int {
172 172
 		$params = [
173 173
 			'action' => 'query',
174 174
 			'prop' => 'revisions',
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 
182 182
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
183 183
 		$data = $res->query->pages;
184
-		return strtotime( reset( $data )->revisions[0]->timestamp );
184
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
185 185
 	}
186 186
 
187 187
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @param string $title
191 191
 	 * @param string $reason
192 192
 	 */
193
-	public function protectPage( string $title, string $reason ) {
193
+	public function protectPage ( string $title, string $reason ) {
194 194
 		$this->logger->info( "Protecting page $title" );
195 195
 		$this->login();
196 196
 
Please login to merge, or discard this patch.