Passed
Push — master ( 393b08...0ea8f2 )
by Daimona
08:52
created
includes/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;
4 4
 
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
 	/** @var array[] */
15 15
 	private $processUsers;
16 16
 	/** @var PageRiconferma[] */
17
-	private $createdPages = [];
17
+	private $createdPages = [ ];
18 18
 
19 19
 	/**
20 20
 	 * Get a list of users to execute tasks on.
21 21
 	 *
22 22
 	 * @return array[]
23 23
 	 */
24
-	public function getUsersToProcess() : array {
24
+	public function getUsersToProcess () : array {
25 25
 		if ( $this->processUsers === null ) {
26
-			$this->processUsers = [];
26
+			$this->processUsers = [ ];
27 27
 			foreach ( PageBotList::get()->getAdminsList() as $user => $groups ) {
28 28
 				if ( $this->shouldAddUser( $groups ) ) {
29 29
 					$this->processUsers[ $user ] = $groups;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @param string[] $groups
41 41
 	 * @return bool
42 42
 	 */
43
-	private function shouldAddUser( array $groups ) : bool {
43
+	private function shouldAddUser ( array $groups ) : bool {
44 44
 		$override = true;
45 45
 		$timestamp = PageBotList::getOverrideTimestamp( $groups );
46 46
 
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return PageRiconferma[]
61 61
 	 */
62
-	public function getOpenPages() : array {
62
+	public function getOpenPages () : array {
63 63
 		static $list = null;
64 64
 		if ( $list === null ) {
65
-			$list = [];
65
+			$list = [ ];
66 66
 			$mainTitle = $this->getOpt( 'main-page-title' );
67 67
 			$params = [
68 68
 				'action' => 'query',
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 			$pages = RequestBase::newFromParams( $params )->execute()->query->pages;
77 77
 			foreach ( reset( $pages )->templates as $page ) {
78 78
 				if ( preg_match( "!$titleReg\/[^\/]+\/\d!", $page->title ) ) {
79
-					$list[] = new PageRiconferma( $page->title );
79
+					$list[ ] = new PageRiconferma( $page->title );
80 80
 				}
81 81
 			}
82 82
 		}
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return PageRiconferma[]
91 91
 	 */
92
-	public function getPagesToClose() : array {
92
+	public function getPagesToClose () : array {
93 93
 		static $list = null;
94 94
 		if ( $list === null ) {
95
-			$list = [];
95
+			$list = [ ];
96 96
 			foreach ( $this->getOpenPages() as $page ) {
97 97
 				if ( time() > $page->getEndTimestamp() ) {
98
-					$list[] = $page;
98
+					$list[ ] = $page;
99 99
 				}
100 100
 			}
101 101
 		}
@@ -107,21 +107,21 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @param string $name
109 109
 	 */
110
-	public function removeUser( string $name ) {
110
+	public function removeUser ( string $name ) {
111 111
 		unset( $this->processUsers[ $name ] );
112 112
 	}
113 113
 
114 114
 	/**
115 115
 	 * @return PageRiconferma[]
116 116
 	 */
117
-	public function getCreatedPages() : array {
117
+	public function getCreatedPages () : array {
118 118
 		return $this->createdPages;
119 119
 	}
120 120
 
121 121
 	/**
122 122
 	 * @param PageRiconferma $page
123 123
 	 */
124
-	public function addCreatedPages( PageRiconferma $page ) {
125
-		$this->createdPages[] = $page;
124
+	public function addCreatedPages ( PageRiconferma $page ) {
125
+		$this->createdPages[ ] = $page;
126 126
 	}
127 127
 }
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
 
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	protected function getSubtasksMap(): array {
18
+	protected function getSubtasksMap (): array {
19 19
 		// Everything is done here.
20
-		return [];
20
+		return [ ];
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	public function runInternal() : int {
26
+	public function runInternal () : int {
27 27
 		$pages = $this->getDataProvider()->getOpenPages();
28 28
 
29 29
 		if ( !$pages ) {
@@ -37,12 +37,12 @@  discard block
 block discarded – undo
37 37
 	 * @param PageRiconferma[] $pages
38 38
 	 * @return int a STATUS_* constant
39 39
 	 */
40
-	protected function processPages( array $pages ) : int {
41
-		$donePages = [];
40
+	protected function processPages ( array $pages ) : int {
41
+		$donePages = [ ];
42 42
 		foreach ( $pages as $page ) {
43 43
 			if ( $page->hasOpposition() && !$page->isVote() ) {
44 44
 				$this->openVote( $page );
45
-				$donePages[] = $page;
45
+				$donePages[ ] = $page;
46 46
 			}
47 47
 		}
48 48
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param PageRiconferma $page
62 62
 	 */
63
-	protected function openVote( PageRiconferma $page ) {
63
+	protected function openVote ( PageRiconferma $page ) {
64 64
 		$this->getLogger()->info( "Starting vote on $page" );
65 65
 
66 66
 		$content = $page->getContent();
@@ -99,12 +99,12 @@  discard block
 block discarded – undo
99 99
 	 * @see SimpleUpdates::updateVotazioni()
100 100
 	 * @see UpdatesAround::addToVotazioni()
101 101
 	 */
102
-	protected function updateVotazioni( array $pages ) {
102
+	protected function updateVotazioni ( array $pages ) {
103 103
 		$votePage = new Page( $this->getOpt( 'vote-page-title' ) );
104 104
 
105
-		$users = [];
105
+		$users = [ ];
106 106
 		foreach ( $pages as $page ) {
107
-			$users[] = $page->getUser();
107
+			$users[ ] = $page->getUser();
108 108
 		}
109 109
 		$usersReg = Element::regexFromArray( $users );
110 110
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @see SimpleUpdates::updateNews()
143 143
 	 * @throws TaskException
144 144
 	 */
145
-	protected function updateNews( int $amount ) {
145
+	protected function updateNews ( int $amount ) {
146 146
 		$this->getLogger()->info( "Turning $amount pages into votes" );
147 147
 		$newsPage = new Page( $this->getOpt( 'news-page-title' ) );
148 148
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 			throw new TaskException( 'Param "voto" not found in news page' );
158 158
 		}
159 159
 
160
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
161
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
160
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
161
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
162 162
 
163 163
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
164 164
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Task/UpdateList.php 1 patch
Spacing   +20 added lines, -20 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
 		$this->botList = PageBotList::get()->getAdminsList();
33 33
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	/**
54 54
 	 * @return array
55 55
 	 */
56
-	protected function getActualAdmins() : array {
56
+	protected function getActualAdmins () : array {
57 57
 		$this->getLogger()->debug( 'Retrieving admins - API' );
58 58
 		$params = [
59 59
 			'action' => 'query',
@@ -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 ) ) {
@@ -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;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param string $group
149 149
 	 * @return string|null
150 150
 	 */
151
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
151
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
152 152
 		$ts = null;
153 153
 		foreach ( $data->query->logevents as $entry ) {
154 154
 			if ( isset( $entry->params ) ) {
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @return array[]
169 169
 	 */
170
-	protected function getExtraGroups() : array {
171
-		$extra = [];
170
+	protected function getExtraGroups () : array {
171
+		$extra = [ ];
172 172
 		foreach ( $this->botList as $name => $groups ) {
173 173
 			// These are not groups
174 174
 			unset( $groups[ 'override' ], $groups[ 'override-perm' ] );
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @param array[] $extra
189 189
 	 * @return array[]
190 190
 	 */
191
-	protected function getNewContent( array $missing, array $extra ) : array {
191
+	protected function getNewContent ( array $missing, array $extra ) : array {
192 192
 		$newContent = $this->botList;
193 193
 		foreach ( $newContent as $user => $groups ) {
194 194
 			if ( isset( $missing[ $user ] ) ) {
@@ -213,15 +213,15 @@  discard block
 block discarded – undo
213 213
 	 * @param array[] $newContent
214 214
 	 * @return array[]
215 215
 	 */
216
-	protected function removeOverrides( array $newContent ) : array {
217
-		$removed = [];
216
+	protected function removeOverrides ( array $newContent ) : array {
217
+		$removed = [ ];
218 218
 		foreach ( $newContent as $user => $groups ) {
219 219
 			$ts = PageBotList::getValidFlagTimestamp( $groups );
220
-			if ( isset( $groups['override'] ) && ( date( 'd/m', $ts ) ===
220
+			if ( isset( $groups[ 'override' ] ) && ( date( 'd/m', $ts ) ===
221 221
 				date( 'd/m', strtotime( '- 1 days' ) ) )
222 222
 			) {
223 223
 				unset( $newContent[ $user ][ 'override' ] );
224
-				$removed[] = $user;
224
+				$removed[ ] = $user;
225 225
 			}
226 226
 		}
227 227
 
Please login to merge, or discard this patch.
includes/Task/Subtask/CreatePages.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\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
 		$users = $this->getDataProvider()->getUsersToProcess();
19 19
 
20 20
 		if ( !$users ) {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param string $user
35 35
 	 * @param array $groups
36 36
 	 */
37
-	protected function processUser( string $user, array $groups ) {
37
+	protected function processUser ( string $user, array $groups ) {
38 38
 		try {
39 39
 			$num = $this->getLastPageNum( $user ) + 1;
40 40
 		} catch ( TaskException $e ) {
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @return int
67 67
 	 * @throws TaskException
68 68
 	 */
69
-	protected function getLastPageNum( string $user ) : int {
69
+	protected function getLastPageNum ( string $user ) : int {
70 70
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
71
-		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1];
71
+		$unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ];
72 72
 		$params = [
73 73
 			'action' => 'query',
74 74
 			'list' => 'allpages',
@@ -103,13 +103,13 @@  discard block
 block discarded – undo
103 103
 	 * @param string $user
104 104
 	 * @param array $groups
105 105
 	 */
106
-	protected function createPage( string $title, string $user, array $groups ) {
106
+	protected function createPage ( string $title, string $user, array $groups ) {
107 107
 		$this->getLogger()->info( "Creating page $title" );
108 108
 		$textParams = [
109 109
 			'$user' => $user,
110
-			'$date' => $groups['sysop'],
111
-			'$burocrate' => $groups['bureaucrat'] ?? '',
112
-			'$checkuser' => $groups['checkuser'] ?? ''
110
+			'$date' => $groups[ 'sysop' ],
111
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
112
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
113 113
 		];
114 114
 
115 115
 		$params = [
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @param string $title
128 128
 	 * @param string $newText
129 129
 	 */
130
-	protected function createBasePage( string $title, string $newText ) {
130
+	protected function createBasePage ( string $title, string $newText ) {
131 131
 		$this->getLogger()->info( "Creating base page $title" );
132 132
 
133 133
 		$params = [
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @param string $title
145 145
 	 * @param string $newText
146 146
 	 */
147
-	protected function updateBasePage( string $title, string $newText ) {
147
+	protected function updateBasePage ( string $title, string $newText ) {
148 148
 		$this->getLogger()->info( "Updating base page $title" );
149 149
 
150 150
 		$params = [
Please login to merge, or discard this patch.
includes/Task/Subtask/FailedUpdates.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\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
 		$failed = $this->getFailures();
21 21
 		if ( $failed ) {
22 22
 			$bureaucrats = $this->getFailedBureaucrats( $failed );
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return PageRiconferma[]
38 38
 	 */
39
-	private function getFailures() : array {
40
-		$ret = [];
39
+	private function getFailures () : array {
40
+		$ret = [ ];
41 41
 		$allPages = $this->getDataProvider()->getPagesToClose();
42 42
 		foreach ( $allPages as $page ) {
43 43
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
44
-				$ret[] = $page;
44
+				$ret[ ] = $page;
45 45
 			}
46 46
 		}
47 47
 		return $ret;
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	/**
51 51
 	 * @param User[] $users
52 52
 	 */
53
-	protected function updateBurList( array $users ) {
53
+	protected function updateBurList ( array $users ) {
54 54
 		$this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) );
55 55
 		$remList = Element::regexFromArray( $users );
56 56
 		$burList = new Page( $this->getOpt( 'bur-list-title' ) );
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @param PageRiconferma[] $pages
75 75
 	 */
76
-	protected function requestRemoval( array $pages ) {
76
+	protected function requestRemoval ( array $pages ) {
77 77
 		$this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) );
78 78
 
79 79
 		$flagRemPage = new Page(
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
 	 *
110 110
 	 * @param PageRiconferma[] $pages
111 111
 	 */
112
-	protected function updateAnnunci( array $pages ) {
112
+	protected function updateAnnunci ( array $pages ) {
113 113
 		$this->getLogger()->info( 'Updating annunci' );
114 114
 		$section = 1;
115 115
 
116
-		$names = [];
116
+		$names = [ ];
117 117
 		$text = '';
118 118
 		foreach ( $pages as $page ) {
119 119
 			$user = $page->getUser()->getName();
120
-			$names[] = $user;
120
+			$names[ ] = $user;
121 121
 			$text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text();
122 122
 		}
123 123
 
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param PageRiconferma[] $pages
151 151
 	 */
152
-	protected function updateUltimeNotizie( array $pages ) {
152
+	protected function updateUltimeNotizie ( array $pages ) {
153 153
 		$this->getLogger()->info( 'Updating ultime notizie' );
154 154
 		$notiziePage = new Page( $this->getOpt( 'ultimenotizie-page-title' ) );
155 155
 
156
-		$names = [];
156
+		$names = [ ];
157 157
 		$text = '';
158 158
 		$msg = $this->msg( 'ultimenotizie-text' );
159 159
 		foreach ( $pages as $page ) {
160 160
 			$user = $page->getUser()->getName();
161
-			$names[] = $user;
161
+			$names[ ] = $user;
162 162
 			$text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text();
163 163
 		}
164 164
 
@@ -187,12 +187,12 @@  discard block
 block discarded – undo
187 187
 	 * @param PageRiconferma[] $pages
188 188
 	 * @return User[]
189 189
 	 */
190
-	private function getFailedBureaucrats( array $pages ) : array {
191
-		$ret = [];
190
+	private function getFailedBureaucrats ( array $pages ) : array {
191
+		$ret = [ ];
192 192
 		foreach ( $pages as $page ) {
193 193
 			$user = $page->getUser();
194 194
 			if ( $user->inGroup( 'bureaucrat' ) ) {
195
-				$ret[] = $user;
195
+				$ret[ ] = $user;
196 196
 			}
197 197
 		}
198 198
 		return $ret;
Please login to merge, or discard this patch.
includes/Task/Subtask/UpdatesAround.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\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
 		$pages = $this->getDataProvider()->getCreatedPages();
19 19
 
20 20
 		if ( !$pages ) {
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @param PageRiconferma[] $pages
38 38
 	 */
39
-	protected function addToMainPage( array $pages ) {
39
+	protected function addToMainPage ( array $pages ) {
40 40
 		$this->getLogger()->info(
41 41
 			'Adding the following to main: ' . implode( ', ', $pages )
42 42
 		);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @param PageRiconferma[] $pages
71 71
 	 */
72
-	protected function addToVotazioni( array $pages ) {
72
+	protected function addToVotazioni ( array $pages ) {
73 73
 		$this->getLogger()->info(
74 74
 			'Adding the following to votes: ' . implode( ', ', $pages )
75 75
 		);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @param int $amount
107 107
 	 * @throws TaskException
108 108
 	 */
109
-	protected function addToNews( int $amount ) {
109
+	protected function addToNews ( int $amount ) {
110 110
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
111 111
 		$newsPage = new Page( $this->getOpt( 'news-page-title' ) );
112 112
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 			throw new TaskException( 'Param not found in news page' );
120 120
 		}
121 121
 
122
-		$newNum = (int)$matches[2] + $amount;
122
+		$newNum = (int)$matches[ 2 ] + $amount;
123 123
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
124 124
 
125 125
 		$summary = $this->msg( 'news-page-summary' )
Please login to merge, or discard this patch.
includes/Task/Subtask/SimpleUpdates.php 1 patch
Spacing   +18 added lines, -18 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
 		$pages = $this->getDataProvider()->getPagesToClose();
21 21
 
22 22
 		if ( !$pages ) {
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 	 * @param PageRiconferma[] $pages
39 39
 	 * @see UpdatesAround::addToVotazioni()
40 40
 	 */
41
-	protected function updateVotazioni( array $pages ) {
41
+	protected function updateVotazioni ( array $pages ) {
42 42
 		$this->getLogger()->info(
43 43
 			'Updating votazioni: ' . implode( ', ', $pages )
44 44
 		);
45 45
 		$votePage = new Page( $this->getOpt( 'vote-page-title' ) );
46 46
 
47
-		$users = [];
47
+		$users = [ ];
48 48
 		foreach ( $pages as $page ) {
49
-			$users[] = $page->getUser();
49
+			$users[ ] = $page->getUser();
50 50
 		}
51 51
 		$usersReg = Element::regexFromArray( $users );
52 52
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param array $pages
68 68
 	 * @see UpdatesAround::addToNews()
69 69
 	 */
70
-	protected function updateNews( array $pages ) {
70
+	protected function updateNews ( array $pages ) {
71 71
 		$simpleAmount = $voteAmount = 0;
72 72
 		foreach ( $pages as $page ) {
73 73
 			if ( $page->isVote() ) {
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
88 88
 		$voteMatches = $newsPage->getMatch( $voteReg );
89 89
 
90
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
91
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
90
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
91
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
92 92
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() );
93 93
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
94 94
 
@@ -106,21 +106,21 @@  discard block
 block discarded – undo
106 106
 	 *
107 107
 	 * @param bool[] $outcomes
108 108
 	 */
109
-	protected function updateAdminList( array $outcomes ) {
109
+	protected function updateAdminList ( array $outcomes ) {
110 110
 		$this->getLogger()->info( 'Updating admin list' );
111 111
 		$adminsPage = new Page( $this->getOpt( 'admins-list-title' ) );
112 112
 		$newContent = $adminsPage->getContent();
113 113
 
114
-		$riconfNames = $removeNames = [];
114
+		$riconfNames = $removeNames = [ ];
115 115
 		foreach ( $outcomes as $user => $confirmed ) {
116 116
 			$userReg = ( new User( $user ) )->getRegex();
117 117
 			$reg = "!(\{\{Amministratore\/riga\|$userReg.+\| *)\d+( *\|[ \w]*\}\}.*\n)!";
118 118
 			if ( $confirmed ) {
119 119
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:Ymd|+1 year}}$2', $newContent );
120
-				$riconfNames[] = $user;
120
+				$riconfNames[ ] = $user;
121 121
 			} else {
122 122
 				$newContent = preg_replace( $reg, '', $newContent );
123
-				$removeNames[] = $user;
123
+				$removeNames[ ] = $user;
124 124
 			}
125 125
 		}
126 126
 
@@ -140,21 +140,21 @@  discard block
 block discarded – undo
140 140
 	/**
141 141
 	 * @param bool[] $outcomes
142 142
 	 */
143
-	protected function updateCUList( array $outcomes ) {
143
+	protected function updateCUList ( array $outcomes ) {
144 144
 		$this->getLogger()->info( 'Updating CU list.' );
145 145
 		$cuList = new Page( $this->getOpt( 'cu-list-title' ) );
146 146
 		$newContent = $cuList->getContent();
147 147
 
148
-		$riconfNames = $removeNames = [];
148
+		$riconfNames = $removeNames = [ ];
149 149
 		foreach ( $outcomes as $user => $confirmed ) {
150 150
 			$userReg = ( new User( $user ) )->getRegex();
151 151
 			$reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
152 152
 			if ( $confirmed ) {
153 153
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent );
154
-				$riconfNames[] = $user;
154
+				$riconfNames[ ] = $user;
155 155
 			} else {
156 156
 				$newContent = preg_replace( $reg, '', $newContent );
157
-				$removeNames[] = $user;
157
+				$removeNames[ ] = $user;
158 158
 			}
159 159
 		}
160 160
 
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
 	 * @param PageRiconferma[] $pages
179 179
 	 * @return bool[]
180 180
 	 */
181
-	private function getGroupOutcomes( string $group, array $pages ) : array {
182
-		$ret = [];
181
+	private function getGroupOutcomes ( string $group, array $pages ) : array {
182
+		$ret = [ ];
183 183
 		foreach ( $pages as $page ) {
184 184
 			$user = $page->getUser();
185 185
 			if ( $user->inGroup( $group ) ) {
Please login to merge, or discard this patch.
includes/Task/Subtask/ArchivePages.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
 
@@ -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
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 
20 20
 		if ( !$pages ) {
@@ -33,15 +33,15 @@  discard block
 block discarded – undo
33 33
 	 * @param PageRiconferma[] $pages
34 34
 	 * @see UpdatesAround::addToMainPage()
35 35
 	 */
36
-	protected function removeFromMainPage( array $pages ) {
36
+	protected function removeFromMainPage ( array $pages ) {
37 37
 		$this->getLogger()->info(
38 38
 			'Removing from main: ' . implode( ', ', $pages )
39 39
 		);
40 40
 
41 41
 		$mainPage = new Page( $this->getOpt( 'main-page-title' ) );
42
-		$remove = [];
42
+		$remove = [ ];
43 43
 		foreach ( $pages as $page ) {
44
-			$remove[] = '{{' . $page->getTitle() . '}}';
44
+			$remove[ ] = '{{' . $page->getTitle() . '}}';
45 45
 		}
46 46
 
47 47
 		$newContent = str_replace( $remove, '', $mainPage->getContent() );
@@ -70,17 +70,17 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param PageRiconferma[] $pages
72 72
 	 */
73
-	protected function addToArchive( array $pages ) {
73
+	protected function addToArchive ( array $pages ) {
74 74
 		$this->getLogger()->info(
75 75
 			'Adding to archive: ' . implode( ', ', $pages )
76 76
 		);
77 77
 
78
-		$simple = $votes = [];
78
+		$simple = $votes = [ ];
79 79
 		foreach ( $pages as $page ) {
80 80
 			if ( $page->isVote() ) {
81
-				$votes[] = $page;
81
+				$votes[ ] = $page;
82 82
 			} else {
83
-				$simple[] = $page;
83
+				$simple[ ] = $page;
84 84
 			}
85 85
 		}
86 86
 
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 	 * @param string $archiveTitle
102 102
 	 * @param array $pages
103 103
 	 */
104
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
104
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
105 105
 		$archivePage = new Page( "$archiveTitle/" . date( 'Y' ) );
106 106
 		$exists = $archivePage->exists();
107 107
 
108 108
 		$append = "\n";
109
-		$archivedList = [];
109
+		$archivedList = [ ];
110 110
 		foreach ( $pages as $page ) {
111 111
 			$append .= '{{' . $page->getTitle() . "}}\n";
112
-			$archivedList[] = $page->getUserNum();
112
+			$archivedList[ ] = $page->getUserNum();
113 113
 		}
114 114
 
115 115
 		$summary = $this->msg( 'close-archive-summary' )
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @param string $archiveTitle
132 132
 	 */
133
-	private function addArchiveYear( string $archiveTitle ) {
133
+	private function addArchiveYear ( string $archiveTitle ) {
134 134
 		$page = new Page( $archiveTitle );
135 135
 		$year = date( 'Y' );
136 136
 
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
 	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
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
76 76
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
77 77
 	}
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 *
82 82
 	 * @return int
83 83
 	 */
84
-	public function getOpposingCount() : int {
84
+	public function getOpposingCount () : int {
85 85
 		$this->defineSections();
86 86
 		return $this->getCountForSection( $this->opposeSection );
87 87
 	}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @return int
93 93
 	 * @throws \BadMethodCallException
94 94
 	 */
95
-	public function getSupportCount() : int {
95
+	public function getSupportCount () : int {
96 96
 		if ( !$this->isVote() ) {
97 97
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
98 98
 		}
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 * @param int $secNum
107 107
 	 * @return int
108 108
 	 */
109
-	protected function getCountForSection( int $secNum ) : int {
109
+	protected function getCountForSection ( int $secNum ) : int {
110 110
 		if ( !isset( $this->sectionCounts[ $secNum ] ) ) {
111 111
 			$content = $this->controller->getPageContent( $this->title, $secNum );
112 112
 			// Let's hope that this is good enough...
113
-			$this->sectionCounts[$secNum] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content );
113
+			$this->sectionCounts[ $secNum ] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content );
114 114
 		}
115
-		return $this->sectionCounts[$secNum];
115
+		return $this->sectionCounts[ $secNum ];
116 116
 	}
117 117
 
118 118
 	/**
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @return int
122 122
 	 */
123
-	protected function getQuorum() : int {
123
+	protected function getQuorum () : int {
124 124
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
125
-		return intval( $this->getMatch( $reg )[1] );
125
+		return intval( $this->getMatch( $reg )[ 1 ] );
126 126
 	}
127 127
 
128 128
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 *
131 131
 	 * @return bool
132 132
 	 */
133
-	public function hasOpposition() : bool {
133
+	public function hasOpposition () : bool {
134 134
 		return $this->getOpposingCount() >= self::REQUIRED_OPPOSE;
135 135
 	}
136 136
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 	 *
140 140
 	 * @return int One of the OUTCOME_* constants
141 141
 	 */
142
-	public function getOutcome() : int {
142
+	public function getOutcome () : int {
143 143
 		if ( !$this->isVote() ) {
144 144
 			return self::OUTCOME_OK;
145 145
 		}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @throws \BadMethodCallException
163 163
 	 * @throws \LogicException
164 164
 	 */
165
-	public function getOutcomeText() : string {
165
+	public function getOutcomeText () : string {
166 166
 		if ( !$this->isVote() ) {
167 167
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
168 168
 		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	 *
197 197
 	 * @return bool
198 198
 	 */
199
-	public function isVote() : bool {
199
+	public function isVote () : bool {
200 200
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
201 201
 		return !$this->matches( $sectionReg );
202 202
 	}
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 *
207 207
 	 * @return int
208 208
 	 */
209
-	public function getCreationTimestamp() : int {
209
+	public function getCreationTimestamp () : int {
210 210
 		return $this->controller->getPageCreationTS( $this->title );
211 211
 	}
212 212
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *
216 216
 	 * @return int
217 217
 	 */
218
-	public function getEndTimestamp() : int {
218
+	public function getEndTimestamp () : int {
219 219
 		if ( $this->isVote() ) {
220 220
 			$reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!";
221 221
 			list( , $hours, $day ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.