Passed
Push — master ( a192f6...3a1f1a )
by Daimona
02:01
created
includes/Task/Subtask/CreatePages.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\Task\Subtask;
4 4
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @inheritDoc
18 18
 	 */
19
-	public function runInternal() : int {
19
+	public function runInternal () : int {
20 20
 		$users = $this->getDataProvider()->getUsersToProcess();
21 21
 
22 22
 		if ( !$users ) {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param User $user
37 37
 	 */
38
-	protected function processUser( User $user ) : void {
38
+	protected function processUser ( User $user ) : void {
39 39
 		$this->getLogger()->info( "Processing user $user" );
40 40
 		try {
41 41
 			$num = $this->getLastPageNum( $user ) + 1;
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 	 * @return int
71 71
 	 * @throws TaskException
72 72
 	 */
73
-	protected function getLastPageNum( User $user ) : int {
73
+	protected function getLastPageNum ( User $user ) : int {
74 74
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
75 75
 
76
-		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1];
76
+		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ];
77 77
 
78 78
 		$prefixes = [ "$unprefixedTitle/$user/" ];
79 79
 		foreach ( $user->getAliases() as $alias ) {
80
-			$prefixes[] = "$unprefixedTitle/$alias/";
80
+			$prefixes[ ] = "$unprefixedTitle/$alias/";
81 81
 		}
82 82
 
83 83
 		$params = [
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 	 * @param string $title
112 112
 	 * @param User $user
113 113
 	 */
114
-	protected function createPage( string $title, User $user ) : void {
114
+	protected function createPage ( string $title, User $user ) : void {
115 115
 		$this->getLogger()->info( "Creating page $title" );
116 116
 		$groups = $user->getGroupsWithDates();
117 117
 		$textParams = [
118 118
 			'$user' => $user->getName(),
119
-			'$date' => $groups['sysop'],
120
-			'$burocrate' => $groups['bureaucrat'] ?? '',
121
-			'$checkuser' => $groups['checkuser'] ?? ''
119
+			'$date' => $groups[ 'sysop' ],
120
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
121
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
122 122
 		];
123 123
 
124 124
 		$params = [
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @param Page $basePage
137 137
 	 * @param string $newText
138 138
 	 */
139
-	protected function createBasePage( Page $basePage, string $newText ) : void {
139
+	protected function createBasePage ( Page $basePage, string $newText ) : void {
140 140
 		$this->getLogger()->info( "Creating base page $basePage" );
141 141
 
142 142
 		$params = [
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @param Page $basePage
153 153
 	 * @param string $newText
154 154
 	 */
155
-	protected function updateBasePage( Page $basePage, string $newText ) : void {
155
+	protected function updateBasePage ( Page $basePage, string $newText ) : void {
156 156
 		$this->getLogger()->info( "Updating base page $basePage" );
157 157
 
158 158
 		$params = [
Please login to merge, or discard this patch.
includes/Task/Subtask/ArchivePages.php 1 patch
Spacing   +14 added lines, -14 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
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @inheritDoc
15 15
 	 */
16
-	public function runInternal() : int {
16
+	public function runInternal () : int {
17 17
 		$pages = $this->getDataProvider()->getPagesToClose();
18 18
 
19 19
 		if ( !$pages ) {
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
 	 * @param PageRiconferma[] $pages
33 33
 	 * @see OpenUpdates::addToMainPage()
34 34
 	 */
35
-	protected function removeFromMainPage( array $pages ) : void {
35
+	protected function removeFromMainPage ( array $pages ) : void {
36 36
 		$this->getLogger()->info(
37 37
 			'Removing from main: ' . implode( ', ', $pages )
38 38
 		);
39 39
 
40 40
 		$mainPage = $this->getPage( $this->getOpt( 'main-page-title' ) );
41
-		$remove = [];
41
+		$remove = [ ];
42 42
 		foreach ( $pages as $page ) {
43 43
 			// Order matters here. It's not guaranteed that there'll be a newline, but avoid
44 44
 			// regexps for that single character.
45
-			$remove[] = '{{' . $page->getTitle() . "}}\n";
46
-			$remove[] = '{{' . $page->getTitle() . '}}';
45
+			$remove[ ] = '{{' . $page->getTitle() . "}}\n";
46
+			$remove[ ] = '{{' . $page->getTitle() . '}}';
47 47
 		}
48 48
 
49 49
 		$newContent = str_replace( $remove, '', $mainPage->getContent() );
@@ -72,17 +72,17 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @param PageRiconferma[] $pages
74 74
 	 */
75
-	protected function addToArchive( array $pages ) : void {
75
+	protected function addToArchive ( array $pages ) : void {
76 76
 		$this->getLogger()->info(
77 77
 			'Adding to archive: ' . implode( ', ', $pages )
78 78
 		);
79 79
 
80
-		$simple = $votes = [];
80
+		$simple = $votes = [ ];
81 81
 		foreach ( $pages as $page ) {
82 82
 			if ( $page->isVote() ) {
83
-				$votes[] = $page;
83
+				$votes[ ] = $page;
84 84
 			} else {
85
-				$simple[] = $page;
85
+				$simple[ ] = $page;
86 86
 			}
87 87
 		}
88 88
 
@@ -103,15 +103,15 @@  discard block
 block discarded – undo
103 103
 	 * @param string $archiveTitle
104 104
 	 * @param PageRiconferma[] $pages
105 105
 	 */
106
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) : void {
106
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) : void {
107 107
 		$archivePage = $this->getPage( "$archiveTitle/" . date( 'Y' ) );
108 108
 		$existed = $archivePage->exists();
109 109
 
110 110
 		$append = "\n";
111
-		$archivedList = [];
111
+		$archivedList = [ ];
112 112
 		foreach ( $pages as $page ) {
113 113
 			$append .= '{{' . $page->getTitle() . "}}\n";
114
-			$archivedList[] = $page->getUserNum();
114
+			$archivedList[ ] = $page->getUserNum();
115 115
 		}
116 116
 
117 117
 		$summary = $this->msg( 'close-archive-summary' )
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param string $archiveTitle
134 134
 	 */
135
-	private function addArchiveYear( string $archiveTitle ) : void {
135
+	private function addArchiveYear ( string $archiveTitle ) : void {
136 136
 		$page = $this->getPage( $archiveTitle );
137 137
 		$year = date( 'Y' );
138 138
 
Please login to merge, or discard this patch.
includes/Task/Subtask/ClosePages.php 1 patch
Spacing   +5 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\Task\Subtask;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @inheritDoc
15 15
 	 */
16
-	public function runInternal() : int {
16
+	public function runInternal () : int {
17 17
 		$pages = $this->getDataProvider()->getPagesToClose();
18 18
 
19 19
 		if ( !$pages ) {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	/**
36 36
 	 * @param PageRiconferma $page
37 37
 	 */
38
-	protected function addVoteCloseText( PageRiconferma $page ) : void {
38
+	protected function addVoteCloseText ( PageRiconferma $page ) : void {
39 39
 		$content = $page->getContent();
40 40
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!u';
41 41
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param PageRiconferma $page
51 51
 	 * @see CreatePages::updateBasePage()
52 52
 	 */
53
-	protected function updateBasePage( PageRiconferma $page ) : void {
53
+	protected function updateBasePage ( PageRiconferma $page ) : void {
54 54
 		$this->getLogger()->info( "Updating base page for $page" );
55 55
 
56 56
 		if ( $page->getNum() === 1 ) {
@@ -62,8 +62,7 @@  discard block
 block discarded – undo
62 62
 		$current = $basePage->getContent();
63 63
 
64 64
 		$outcomeText = ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) ?
65
-			'non riconfermato' :
66
-			'riconfermato';
65
+			'non riconfermato' : 'riconfermato';
67 66
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
68 67
 
69 68
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
Please login to merge, or discard this patch.
includes/Task/UpdateList.php 1 patch
Spacing   +30 added lines, -30 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
 
@@ -19,15 +19,15 @@  discard block
 block discarded – undo
19 19
 	/**
20 20
 	 * @inheritDoc
21 21
 	 */
22
-	protected function getSubtasksMap(): array {
22
+	protected function getSubtasksMap (): array {
23 23
 		// Everything is done here.
24
-		return [];
24
+		return [ ];
25 25
 	}
26 26
 
27 27
 	/**
28 28
 	 * @inheritDoc
29 29
 	 */
30
-	public function runInternal() : int {
30
+	public function runInternal () : int {
31 31
 		$this->actualList = $this->getActualAdmins();
32 32
 		$pageBotList = PageBotList::get( $this->getWiki() );
33 33
 		$this->botList = $pageBotList->getDecodedContent();
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	/**
55 55
 	 * @return array
56 56
 	 */
57
-	protected function getActualAdmins() : array {
57
+	protected function getActualAdmins () : array {
58 58
 		$params = [
59 59
 			'action' => 'query',
60 60
 			'list' => 'allusers',
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param \stdClass $data
72 72
 	 * @return array
73 73
 	 */
74
-	protected function extractAdmins( \stdClass $data ) : array {
75
-		$ret = [];
74
+	protected function extractAdmins ( \stdClass $data ) : array {
75
+		$ret = [ ];
76 76
 		$blacklist = $this->getOpt( 'exclude-admins' );
77 77
 		foreach ( $data->query->allusers as $u ) {
78 78
 			if ( in_array( $u->name, $blacklist, true ) ) {
@@ -89,16 +89,16 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return array[]
91 91
 	 */
92
-	protected function getMissingGroups() : array {
93
-		$missing = [];
92
+	protected function getMissingGroups () : array {
93
+		$missing = [ ];
94 94
 		foreach ( $this->actualList as $adm => $groups ) {
95
-			$curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) );
95
+			$curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) );
96 96
 
97 97
 			foreach ( $curMissing as $group ) {
98 98
 				try {
99 99
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
100 100
 				} catch ( TaskException $e ) {
101
-					$this->errors[] = $e->getMessage();
101
+					$this->errors[ ] = $e->getMessage();
102 102
 				}
103 103
 			}
104 104
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @return string
114 114
 	 * @throws TaskException
115 115
 	 */
116
-	protected function getFlagDate( string $admin, string $group ) : string {
116
+	protected function getFlagDate ( string $admin, string $group ) : string {
117 117
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
118 118
 
119 119
 		$url = DEFAULT_URL;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @param string $group
150 150
 	 * @return string|null
151 151
 	 */
152
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
152
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
153 153
 		$ts = null;
154 154
 		foreach ( $data->query->logevents as $entry ) {
155 155
 			if (
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return array[]
170 170
 	 */
171
-	protected function getExtraGroups() : array {
172
-		$extra = [];
171
+	protected function getExtraGroups () : array {
172
+		$extra = [ ];
173 173
 		foreach ( $this->botList as $name => $groups ) {
174 174
 			$groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) );
175 175
 			if ( !isset( $this->actualList[ $name ] ) ) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * @param string[] $names
186 186
 	 * @return \stdClass
187 187
 	 */
188
-	private function getRenameEntries( array $names ) : \stdClass {
188
+	private function getRenameEntries ( array $names ) : \stdClass {
189 189
 		$titles = array_map( static function ( $x ) {
190 190
 			return "Utente:$x";
191 191
 		}, $names );
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 	 * @param string[] $names
210 210
 	 * @return string[] [ old_name => new_name ]
211 211
 	 */
212
-	protected function getRenamedUsers( array $names ) : array {
212
+	protected function getRenamedUsers ( array $names ) : array {
213 213
 		if ( !$names ) {
214
-			return [];
214
+			return [ ];
215 215
 		}
216 216
 		$this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) );
217 217
 
218 218
 		$data = $this->getRenameEntries( $names );
219
-		$ret = [];
219
+		$ret = [ ];
220 220
 		foreach ( $data->query->logevents as $entry ) {
221 221
 			// 1 month is arbitrary
222 222
 			if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) {
@@ -234,18 +234,18 @@  discard block
 block discarded – undo
234 234
 	 * @param array &$newContent
235 235
 	 * @param array $removed
236 236
 	 */
237
-	private function handleRenames( array &$newContent, array $removed ) : void {
237
+	private function handleRenames ( array &$newContent, array $removed ) : void {
238 238
 		$renameMap = $this->getRenamedUsers( array_keys( $removed ) );
239 239
 		foreach ( $removed as $oldName => $info ) {
240 240
 			if (
241 241
 				array_key_exists( $oldName, $renameMap ) &&
242
-				array_key_exists( $renameMap[$oldName], $newContent )
242
+				array_key_exists( $renameMap[ $oldName ], $newContent )
243 243
 			) {
244 244
 				// This user was renamed! Add this name as alias, if they're still listed
245 245
 				$newName = $renameMap[ $oldName ];
246 246
 				$this->getLogger()->info( "Found rename $oldName -> $newName" );
247
-				$aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) );
248
-				$newContent[ $newName ]['aliases'] = $aliases;
247
+				$aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) );
248
+				$newContent[ $newName ][ 'aliases' ] = $aliases;
249 249
 				// Transfer overrides to the new name.
250 250
 				$overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] );
251 251
 				$newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides );
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
 	 * @param array[] $extra
260 260
 	 * @return string[] Removed users
261 261
 	 */
262
-	private function handleExtraAndMissing(
262
+	private function handleExtraAndMissing (
263 263
 		array &$newContent,
264 264
 		array $missing,
265 265
 		array $extra
266 266
 	) : array {
267
-		$removed = [];
267
+		$removed = [ ];
268 268
 		foreach ( $newContent as $user => $groups ) {
269 269
 			if ( isset( $missing[ $user ] ) ) {
270 270
 				$newContent[ $user ] = array_merge( $groups, $missing[ $user ] );
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 				if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) {
275 275
 					$newContent[ $user ] = $newGroups;
276 276
 				} else {
277
-					$removed[$user] = $newContent[$user];
277
+					$removed[ $user ] = $newContent[ $user ];
278 278
 					unset( $newContent[ $user ] );
279 279
 				}
280 280
 			}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @param array[] $extra
292 292
 	 * @return array[]
293 293
 	 */
294
-	protected function getNewContent( array $missing, array $extra ) : array {
294
+	protected function getNewContent ( array $missing, array $extra ) : array {
295 295
 		$newContent = $this->botList;
296 296
 
297 297
 		$removed = $this->handleExtraAndMissing( $newContent, $missing, $extra );
@@ -311,12 +311,12 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * @param array[] &$newContent
313 313
 	 */
314
-	protected function removeOverrides( array &$newContent ) : void {
315
-		$removed = [];
314
+	protected function removeOverrides ( array &$newContent ) : void {
315
+		$removed = [ ];
316 316
 		foreach ( $newContent as $user => $groups ) {
317 317
 			if ( PageBotList::isOverrideExpired( $groups ) ) {
318 318
 				unset( $newContent[ $user ][ 'override' ] );
319
-				$removed[] = $user;
319
+				$removed[ ] = $user;
320 320
 			}
321 321
 		}
322 322
 
Please login to merge, or discard this patch.
includes/Task/StartVote.php 1 patch
Spacing   +14 added lines, -14 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,15 +14,15 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	protected function getSubtasksMap(): array {
17
+	protected function getSubtasksMap (): array {
18 18
 		// Everything is done here.
19
-		return [];
19
+		return [ ];
20 20
 	}
21 21
 
22 22
 	/**
23 23
 	 * @inheritDoc
24 24
 	 */
25
-	public function runInternal() : int {
25
+	public function runInternal () : int {
26 26
 		$pages = $this->getDataProvider()->getOpenPages();
27 27
 
28 28
 		if ( !$pages ) {
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	 * @param PageRiconferma[] $pages
37 37
 	 * @return int a STATUS_* constant
38 38
 	 */
39
-	protected function processPages( array $pages ) : int {
40
-		$donePages = [];
39
+	protected function processPages ( array $pages ) : int {
40
+		$donePages = [ ];
41 41
 		foreach ( $pages as $page ) {
42 42
 			if ( $page->hasOpposition() && !$page->isVote() ) {
43 43
 				$this->openVote( $page );
44
-				$donePages[] = $page;
44
+				$donePages[ ] = $page;
45 45
 			}
46 46
 		}
47 47
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @param PageRiconferma $page
61 61
 	 */
62
-	protected function openVote( PageRiconferma $page ) : void {
62
+	protected function openVote ( PageRiconferma $page ) : void {
63 63
 		$this->getLogger()->info( "Starting vote on $page" );
64 64
 
65 65
 		$content = $page->getContent();
@@ -98,12 +98,12 @@  discard block
 block discarded – undo
98 98
 	 * @see SimpleUpdates::updateVotazioni()
99 99
 	 * @see OpenUpdates::addToVotazioni()
100 100
 	 */
101
-	protected function updateVotazioni( array $pages ) : void {
101
+	protected function updateVotazioni ( array $pages ) : void {
102 102
 		$votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) );
103 103
 
104
-		$users = [];
104
+		$users = [ ];
105 105
 		foreach ( $pages as $page ) {
106
-			$users[] = $page->getUser();
106
+			$users[ ] = $page->getUser();
107 107
 		}
108 108
 		$usersReg = Element::regexFromArray( $users, '!' );
109 109
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * @see SimpleUpdates::updateNews()
142 142
 	 * @see OpenUpdates::addToNews()
143 143
 	 */
144
-	protected function updateNews( int $amount ) : void {
144
+	protected function updateNews ( int $amount ) : void {
145 145
 		$this->getLogger()->info( "Turning $amount pages into votes" );
146 146
 		$newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) );
147 147
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 			throw new TaskException( 'Param "voto" not found in news page' );
157 157
 		}
158 158
 
159
-		$newTac = ( (int)$newsPage->getMatch( $regTac )[2] - $amount ) ?: '';
160
-		$newVot = ( (int)$newsPage->getMatch( $regVot )[2] + $amount ) ?: '';
159
+		$newTac = ( (int)$newsPage->getMatch( $regTac )[ 2 ] - $amount ) ?: '';
160
+		$newVot = ( (int)$newsPage->getMatch( $regVot )[ 2 ] + $amount ) ?: '';
161 161
 
162 162
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
163 163
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Wiki/Page/Page.php 1 patch
Spacing   +17 added lines, -17 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
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param string $title
21 21
 	 * @param Wiki $wiki For the site where the page lives
22 22
 	 */
23
-	public function __construct( string $title, Wiki $wiki ) {
23
+	public function __construct ( string $title, Wiki $wiki ) {
24 24
 		parent::__construct( $wiki );
25 25
 		$this->title = $title;
26 26
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @return string
30 30
 	 */
31
-	public function getTitle() : string {
31
+	public function getTitle () : string {
32 32
 		return $this->title;
33 33
 	}
34 34
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param int|null $section A section number to retrieve the content of that section
39 39
 	 * @return string
40 40
 	 */
41
-	public function getContent( int $section = null ) : string {
41
+	public function getContent ( int $section = null ) : string {
42 42
 		if ( $this->content === null ) {
43 43
 			$this->content = $this->wiki->getPageContent( $this->title, $section );
44 44
 		}
@@ -51,18 +51,18 @@  discard block
 block discarded – undo
51 51
 	 * @param array $params
52 52
 	 * @throws \LogicException
53 53
 	 */
54
-	public function edit( array $params ) : void {
54
+	public function edit ( array $params ) : void {
55 55
 		$params = [
56 56
 			'title' => $this->getTitle()
57 57
 		] + $params;
58 58
 
59 59
 		$this->wiki->editPage( $params );
60
-		if ( isset( $params['text'] ) ) {
61
-			$this->content = $params['text'];
62
-		} elseif ( isset( $params['appendtext'] ) ) {
63
-			$this->content .= $params['appendtext'];
64
-		} elseif ( isset( $params['prependtext'] ) ) {
65
-			$this->content = $params['prependtext'] . $this->content;
60
+		if ( isset( $params[ 'text' ] ) ) {
61
+			$this->content = $params[ 'text' ];
62
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
63
+			$this->content .= $params[ 'appendtext' ];
64
+		} elseif ( isset( $params[ 'prependtext' ] ) ) {
65
+			$this->content = $params[ 'prependtext' ] . $this->content;
66 66
 		} else {
67 67
 			throw new \LogicException(
68 68
 				'Unrecognized text param for edit. Params: ' . var_export( $params, true )
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return bool
77 77
 	 */
78
-	public function exists() : bool {
78
+	public function exists () : bool {
79 79
 		$res = RequestBase::newFromParams( [
80 80
 			'action' => 'query',
81 81
 			'titles' => $this->getTitle()
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $regex
91 91
 	 * @return bool
92 92
 	 */
93
-	public function matches( string $regex ) : bool {
93
+	public function matches ( string $regex ) : bool {
94 94
 		return (bool)preg_match( $regex, $this->getContent() );
95 95
 	}
96 96
 
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	 * @return string[]
103 103
 	 * @throws MissingMatchException
104 104
 	 */
105
-	public function getMatch( string $regex ) : array {
106
-		$ret = [];
105
+	public function getMatch ( string $regex ) : array {
106
+		$ret = [ ];
107 107
 		if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) {
108 108
 			throw new MissingMatchException( "The content of $this does not match the given regex $regex" );
109 109
 		}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @inheritDoc
117 117
 	 */
118
-	public function getRegex( string $delimiter = '/' ) : string {
118
+	public function getRegex ( string $delimiter = '/' ) : string {
119 119
 		return str_replace( ' ', '[ _]', preg_quote( $this->title, $delimiter ) );
120 120
 	}
121 121
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @return string
126 126
 	 */
127
-	public function __toString() {
127
+	public function __toString () {
128 128
 		return $this->getTitle();
129 129
 	}
130 130
 }
Please login to merge, or discard this patch.
includes/Wiki/Page/PageRiconferma.php 1 patch
Spacing   +21 added lines, -21 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() : void {
35
+	private function defineSections () : void {
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, $this->wiki );
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 (int)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 int
73 73
 	 */
74
-	public function getOpposingCount() : int {
74
+	public function getOpposingCount () : int {
75 75
 		$this->defineSections();
76 76
 		return $this->getCountForSection( $this->opposeSection );
77 77
 	}
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 	 * @return int
83 83
 	 * @throws \BadMethodCallException
84 84
 	 */
85
-	public function getSupportCount() : int {
85
+	public function getSupportCount () : int {
86 86
 		if ( !$this->isVote() ) {
87 87
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
88 88
 		}
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
 	 * @param int $secNum
97 97
 	 * @return int
98 98
 	 */
99
-	protected function getCountForSection( int $secNum ) : int {
99
+	protected function getCountForSection ( int $secNum ) : int {
100 100
 		if ( !isset( $this->sectionCounts[ $secNum ] ) ) {
101 101
 			$content = $this->wiki->getPageContent( $this->title, $secNum );
102 102
 			// Let's hope that this is good enough...
103
-			$this->sectionCounts[$secNum] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content );
103
+			$this->sectionCounts[ $secNum ] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content );
104 104
 		}
105
-		return $this->sectionCounts[$secNum];
105
+		return $this->sectionCounts[ $secNum ];
106 106
 	}
107 107
 
108 108
 	/**
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 	 *
111 111
 	 * @return int
112 112
 	 */
113
-	protected function getQuorum() : int {
113
+	protected function getQuorum () : int {
114 114
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
115
-		return (int)$this->getMatch( $reg )[1];
115
+		return (int)$this->getMatch( $reg )[ 1 ];
116 116
 	}
117 117
 
118 118
 	/**
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @return bool
122 122
 	 */
123
-	public function hasOpposition() : bool {
123
+	public function hasOpposition () : bool {
124 124
 		return $this->getOpposingCount() >= self::REQUIRED_OPPOSE;
125 125
 	}
126 126
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return int One of the OUTCOME_* constants
131 131
 	 */
132
-	public function getOutcome() : int {
132
+	public function getOutcome () : int {
133 133
 		if ( !$this->isVote() ) {
134 134
 			return self::OUTCOME_OK;
135 135
 		}
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 	 * @throws \BadMethodCallException
153 153
 	 * @throws \LogicException
154 154
 	 */
155
-	public function getOutcomeText() : string {
155
+	public function getOutcomeText () : string {
156 156
 		if ( !$this->isVote() ) {
157 157
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
158 158
 		}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return bool
188 188
 	 */
189
-	public function isVote() : bool {
189
+	public function isVote () : bool {
190 190
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
191 191
 		return !$this->matches( $sectionReg );
192 192
 	}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return int
198 198
 	 */
199
-	public function getCreationTimestamp() : int {
199
+	public function getCreationTimestamp () : int {
200 200
 		return $this->wiki->getPageCreationTS( $this->title );
201 201
 	}
202 202
 
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	 *
206 206
 	 * @return int
207 207
 	 */
208
-	public function getEndTimestamp() : int {
208
+	public function getEndTimestamp () : int {
209 209
 		if ( $this->isVote() ) {
210 210
 			$reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!";
211 211
 			[ , $hours, $day ] = $this->getMatch( $reg );
Please login to merge, or discard this patch.
includes/Wiki/User.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\Wiki;
4 4
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param string $name
21 21
 	 * @param Wiki $wiki
22 22
 	 */
23
-	public function __construct( string $name, Wiki $wiki ) {
23
+	public function __construct ( string $name, Wiki $wiki ) {
24 24
 		parent::__construct( $wiki );
25 25
 		$this->name = $name;
26 26
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @return string
30 30
 	 */
31
-	public function getName() : string {
31
+	public function getName () : string {
32 32
 		return $this->name;
33 33
 	}
34 34
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return string[]
39 39
 	 */
40
-	public function getGroups() : array {
40
+	public function getGroups () : array {
41 41
 		return array_diff( array_keys( $this->getUserInfo() ), PageBotList::NON_GROUP_KEYS );
42 42
 	}
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 *
47 47
 	 * @return string[] [ group => date ]
48 48
 	 */
49
-	public function getGroupsWithDates() : array {
49
+	public function getGroupsWithDates () : array {
50 50
 		return array_intersect_key( $this->getUserInfo(), array_fill_keys( $this->getGroups(), 1 ) );
51 51
 	}
52 52
 
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return string[]
57 57
 	 */
58
-	public function getUserInfo() : array {
58
+	public function getUserInfo () : array {
59 59
 		if ( $this->info === null ) {
60 60
 			$usersList = PageBotList::get( $this->wiki )->getAdminsList();
61 61
 			$this->info = $usersList[ $this->name ]->getUserInfo();
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	/**
67 67
 	 * @param array|null $info
68 68
 	 */
69
-	public function setInfo( ?array $info ) : void {
69
+	public function setInfo ( ?array $info ) : void {
70 70
 		$this->info = $info;
71 71
 	}
72 72
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $groupName
77 77
 	 * @return bool
78 78
 	 */
79
-	public function inGroup( string $groupName ) : bool {
79
+	public function inGroup ( string $groupName ) : bool {
80 80
 		return in_array( $groupName, $this->getGroups(), true );
81 81
 	}
82 82
 
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @inheritDoc
87 87
 	 */
88
-	public function getRegex( string $delimiter = '/' ) : string {
88
+	public function getRegex ( string $delimiter = '/' ) : string {
89 89
 		$bits = $this->getAliases();
90
-		$bits[] = $this->name;
90
+		$bits[ ] = $this->name;
91 91
 		$regexify = static function ( $el ) use ( $delimiter ) {
92 92
 			return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) );
93 93
 		};
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return string[]
101 101
 	 */
102
-	public function getAliases() : array {
103
-		return $this->getUserInfo()['aliases'] ?? [];
102
+	public function getAliases () : array {
103
+		return $this->getUserInfo()[ 'aliases' ] ?? [ ];
104 104
 	}
105 105
 
106 106
 	/**
107 107
 	 * @return Page
108 108
 	 */
109
-	public function getTalkPage() : Page {
109
+	public function getTalkPage () : Page {
110 110
 		return new Page( "User talk:{$this->name}", $this->wiki );
111 111
 	}
112 112
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * Get the default base page, e.g. WP:A/Riconferma annuale/XXX
115 115
 	 * @return Page
116 116
 	 */
117
-	public function getBasePage() : Page {
117
+	public function getBasePage () : Page {
118 118
 		$prefix = Config::getInstance()->get( 'main-page-title' );
119 119
 		return new Page( "$prefix/$this", $this->wiki );
120 120
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @throws MissingPageException
127 127
 	 * @return Page
128 128
 	 */
129
-	public function getExistingBasePage() : Page {
129
+	public function getExistingBasePage () : Page {
130 130
 		$basePage = $this->getBasePage();
131 131
 		if ( !$basePage->exists() ) {
132 132
 			$basePage = null;
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	/**
151 151
 	 * @return string
152 152
 	 */
153
-	public function __toString() {
153
+	public function __toString () {
154 154
 		return $this->name;
155 155
 	}
156 156
 }
Please login to merge, or discard this patch.
includes/Wiki/Element.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\Wiki;
4 4
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	/**
13 13
 	 * @param Wiki $wiki
14 14
 	 */
15
-	public function __construct( Wiki $wiki ) {
15
+	public function __construct ( Wiki $wiki ) {
16 16
 		$this->wiki = $wiki;
17 17
 	}
18 18
 
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * @param string $delimiter
23 23
 	 * @return string
24 24
 	 */
25
-	abstract public function getRegex( string $delimiter = '/' ) : string;
25
+	abstract public function getRegex ( string $delimiter = '/' ) : string;
26 26
 
27 27
 	/**
28 28
 	 * Get a regex matching any element in the given array
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 	 * @return string
33 33
 	 * @todo Is this the right place?
34 34
 	 */
35
-	public static function regexFromArray( array $elements, string $delimiter = '/' ) : string {
36
-		$bits = [];
35
+	public static function regexFromArray ( array $elements, string $delimiter = '/' ) : string {
36
+		$bits = [ ];
37 37
 		foreach ( $elements as $el ) {
38
-			$bits[] = $el->getRegex( $delimiter );
38
+			$bits[ ] = $el->getRegex( $delimiter );
39 39
 		}
40 40
 		return '(?:' . implode( '|', $bits ) . ')';
41 41
 	}
Please login to merge, or discard this patch.