Passed
Push — master ( 1a35de...b3e686 )
by Daimona
01:36
created
includes/Task/Subtask/FailedUpdates.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\Task\Subtask;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$failed = $this->getFailures();
19 19
 		if ( $failed ) {
20 20
 			$this->updateBurList( $failed );
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @return PageRiconferma[]
33 33
 	 */
34
-	private function getFailures() : array {
35
-		$ret = [];
34
+	private function getFailures () : array {
35
+		$ret = [ ];
36 36
 		$allPages = $this->getDataProvider()->getPagesToClose();
37 37
 		foreach ( $allPages as $page ) {
38 38
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
39
-				$ret[] = $page;
39
+				$ret[ ] = $page;
40 40
 			}
41 41
 		}
42 42
 		return $ret;
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	/**
46 46
 	 * @param PageRiconferma[] $pages
47 47
 	 */
48
-	protected function updateBurList( array $pages ) {
48
+	protected function updateBurList ( array $pages ) {
49 49
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
50 50
 
51
-		$remove = [];
51
+		$remove = [ ];
52 52
 		foreach ( $pages as $page ) {
53 53
 			$user = $page->getUser();
54 54
 			if ( $user->inGroup( 'bureaucrat' ) &&
55 55
 				( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL )
56 56
 			) {
57
-				$remove[] = $user->getName();
57
+				$remove[ ] = $user->getName();
58 58
 			}
59 59
 		}
60 60
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param PageRiconferma[] $pages
86 86
 	 */
87
-	protected function requestRemoval( array $pages ) {
87
+	protected function requestRemoval ( array $pages ) {
88 88
 		$this->getLogger()->info(
89 89
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
90 90
 		);
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
 	 *
124 124
 	 * @param PageRiconferma[] $pages
125 125
 	 */
126
-	protected function updateAnnunci( array $pages ) {
126
+	protected function updateAnnunci ( array $pages ) {
127 127
 		$this->getLogger()->info( 'Updating annunci' );
128 128
 		$section = 1;
129 129
 
130
-		$names = [];
130
+		$names = [ ];
131 131
 		$text = '';
132 132
 		foreach ( $pages as $page ) {
133 133
 			$user = $page->getUser()->getName();
134
-			$names[] = $user;
134
+			$names[ ] = $user;
135 135
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
136 136
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
137 137
 		}
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @param PageRiconferma[] $pages
168 168
 	 */
169
-	protected function updateUltimeNotizie( array $pages ) {
169
+	protected function updateUltimeNotizie ( array $pages ) {
170 170
 		$this->getLogger()->info( 'Updating ultime notizie' );
171 171
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) );
172 172
 
173
-		$names = [];
173
+		$names = [ ];
174 174
 		$text = '';
175 175
 		foreach ( $pages as $page ) {
176 176
 			$user = $page->getUser()->getName();
177 177
 			$title = $page->getTitle();
178
-			$names[] = $user;
178
+			$names[ ] = $user;
179 179
 			$text .= "*'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
180 180
 				"[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{subst:NUMBEROFADMINS}} - 1}}.\n";
181 181
 		}
Please login to merge, or discard this patch.
includes/Wiki/Controller.php 1 patch
Spacing   +12 added lines, -12 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
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return string
41 41
 	 * @throws MissingPageException
42 42
 	 */
43
-	public function getPageContent( string $title, int $section = null ) : string {
43
+	public function getPageContent ( string $title, int $section = null ) : string {
44 44
 		$msg = "Retrieving content of page $title" . ( $section !== null ? ", section $section" : '' );
45 45
 		$this->logger->debug( $msg );
46 46
 		$params = [
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		];
53 53
 
54 54
 		if ( $section !== null ) {
55
-			$params['rvsection'] = $section;
55
+			$params[ 'rvsection' ] = $section;
56 56
 		}
57 57
 
58 58
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			throw new MissingPageException( $title );
63 63
 		}
64 64
 
65
-		$mainSlot = $page->revisions[0]->slots->main;
65
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
66 66
 
67 67
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
68 68
 			throw new MissingSectionException( $title, $section );
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param array $params
77 77
 	 * @throws EditException
78 78
 	 */
79
-	public function editPage( array $params ) {
79
+	public function editPage ( array $params ) {
80 80
 		$this->login();
81 81
 
82 82
 		$params = [
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
99 99
 	 * @throws LoginException
100 100
 	 */
101
-	public function login() {
101
+	public function login () {
102 102
 		if ( self::$loggedIn ) {
103 103
 			return;
104 104
 		}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 		self::$loggedIn = true;
126 126
 		// Clear tokens cache
127
-		$this->tokens = [];
127
+		$this->tokens = [ ];
128 128
 		$this->logger->info( 'Login succeeded' );
129 129
 	}
130 130
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @param string $type
135 135
 	 * @return string
136 136
 	 */
137
-	public function getToken( string $type ) : string {
137
+	public function getToken ( string $type ) : string {
138 138
 		if ( !isset( $this->tokens[ $type ] ) ) {
139 139
 			$params = [
140 140
 				'action' => 'query',
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @param string $title
158 158
 	 * @return int
159 159
 	 */
160
-	public function getPageCreationTS( string $title ) : int {
160
+	public function getPageCreationTS ( string $title ) : int {
161 161
 		$params = [
162 162
 			'action' => 'query',
163 163
 			'prop' => 'revisions',
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
172 172
 		$data = $res->query->pages;
173
-		return strtotime( reset( $data )->revisions[0]->timestamp );
173
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
174 174
 	}
175 175
 
176 176
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param string $title
180 180
 	 * @param string $reason
181 181
 	 */
182
-	public function protectPage( string $title, string $reason ) {
182
+	public function protectPage ( string $title, string $reason ) {
183 183
 		$this->logger->info( "Protecting page $title" );
184 184
 		$this->login();
185 185
 
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
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @param string $title
29 29
 	 */
30
-	public function __construct( string $title ) {
30
+	public function __construct ( string $title ) {
31 31
 		parent::__construct( $title );
32 32
 		$this->supportSection = $this->isVote() ? 3 : 0;
33 33
 		$this->opposeSection = $this->isVote() ? 4 : 3;
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return User
40 40
 	 */
41
-	public function getUser() : User {
42
-		$name = explode( '/', $this->title )[2];
41
+	public function getUser () : User {
42
+		$name = explode( '/', $this->title )[ 2 ];
43 43
 		return new User( $name );
44 44
 	}
45 45
 
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 *
49 49
 	 * @return int
50 50
 	 */
51
-	public function getNum() : int {
51
+	public function getNum () : int {
52 52
 		$bits = explode( '/', $this->getTitle() );
53 53
 		return intval( end( $bits ) );
54 54
 	}
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return string
60 60
 	 */
61
-	public function getUserNum() : string {
62
-		return explode( '/', $this->getTitle(), 3 )[2];
61
+	public function getUserNum () : string {
62
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
63 63
 	}
64 64
 
65 65
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string
69 69
 	 */
70
-	public function getBaseTitle() : string {
70
+	public function getBaseTitle () : string {
71 71
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
72 72
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
73 73
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 *
78 78
 	 * @return int
79 79
 	 */
80
-	public function getOpposingCount() : int {
80
+	public function getOpposingCount () : int {
81 81
 		return $this->getCountForSection( $this->opposeSection );
82 82
 	}
83 83
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return int
88 88
 	 * @throws \BadMethodCallException
89 89
 	 */
90
-	public function getSupportCount() : int {
90
+	public function getSupportCount () : int {
91 91
 		if ( !$this->isVote() ) {
92 92
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
93 93
 		}
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 * @param int $secNum
101 101
 	 * @return int
102 102
 	 */
103
-	protected function getCountForSection( int $secNum ) : int {
104
-		static $cache = [];
103
+	protected function getCountForSection ( int $secNum ) : int {
104
+		static $cache = [ ];
105 105
 		if ( !isset( $cache[ $secNum ] ) ) {
106 106
 			$content = $this->controller->getPageContent( $this->title, $secNum );
107 107
 			// Let's hope that this is good enough...
108
-			$cache[$secNum] = preg_match_all( "/^\# *(?![# *]|\.\.\.$)/m", $content );
108
+			$cache[ $secNum ] = preg_match_all( "/^\# *(?![# *]|\.\.\.$)/m", $content );
109 109
 		}
110
-		return $cache[$secNum];
110
+		return $cache[ $secNum ];
111 111
 	}
112 112
 
113 113
 	/**
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return int
117 117
 	 */
118
-	protected function getQuorum() : int {
118
+	protected function getQuorum () : int {
119 119
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
120
-		return intval( $this->getMatch( $reg )[1] );
120
+		return intval( $this->getMatch( $reg )[ 1 ] );
121 121
 	}
122 122
 
123 123
 	/**
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 *
126 126
 	 * @return bool
127 127
 	 */
128
-	public function hasOpposition() : bool {
128
+	public function hasOpposition () : bool {
129 129
 		return $this->getOpposingCount() >= self::REQUIRED_OPPOSE;
130 130
 	}
131 131
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return int One of the OUTCOME_* constants
136 136
 	 * @throws \BadMethodCallException
137 137
 	 */
138
-	public function getOutcome() : int {
138
+	public function getOutcome () : int {
139 139
 		if ( !$this->isVote() ) {
140 140
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
141 141
 		}
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 	 * @throws \BadMethodCallException
156 156
 	 * @throws \LogicException
157 157
 	 */
158
-	public function getOutcomeText() : string {
158
+	public function getOutcomeText () : string {
159 159
 		if ( !$this->isVote() ) {
160 160
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
161 161
 		}
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 *
190 190
 	 * @return bool
191 191
 	 */
192
-	public function isVote() : bool {
192
+	public function isVote () : bool {
193 193
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
194 194
 		return !$this->matches( $sectionReg );
195 195
 	}
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return int
201 201
 	 */
202
-	public function getCreationTimestamp() : int {
202
+	public function getCreationTimestamp () : int {
203 203
 		return $this->controller->getPageCreationTS( $this->title );
204 204
 	}
205 205
 	/**
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return int
209 209
 	 */
210
-	public function getEndTimestamp() : int {
210
+	public function getEndTimestamp () : int {
211 211
 		if ( $this->isVote() ) {
212 212
 			$reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!";
213 213
 			list( , $hours, $day ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.