Passed
Push — master ( 4deb8c...54b834 )
by Daimona
01:42
created
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
 			return TaskResult::STATUS_NOTHING;
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return PageRiconferma[]
40 40
 	 */
41
-	private function getFailures() : array {
42
-		$ret = [];
41
+	private function getFailures () : array {
42
+		$ret = [ ];
43 43
 		$allPages = $this->getDataProvider()->getPagesToClose();
44 44
 		foreach ( $allPages as $page ) {
45 45
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
46
-				$ret[] = $page;
46
+				$ret[ ] = $page;
47 47
 			}
48 48
 		}
49 49
 		return $ret;
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	/**
53 53
 	 * @param User[] $users
54 54
 	 */
55
-	protected function updateBurList( array $users ) {
55
+	protected function updateBurList ( array $users ) {
56 56
 		$this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) );
57 57
 		$remList = Element::regexFromArray( $users );
58 58
 		$burList = new Page( $this->getOpt( 'bur-list-title' ) );
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @param PageRiconferma[] $pages
77 77
 	 */
78
-	protected function requestRemoval( array $pages ) {
78
+	protected function requestRemoval ( array $pages ) {
79 79
 		$this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) );
80 80
 
81 81
 		$flagRemPage = new Page(
@@ -111,15 +111,15 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @param PageRiconferma[] $pages
113 113
 	 */
114
-	protected function updateAnnunci( array $pages ) {
114
+	protected function updateAnnunci ( array $pages ) {
115 115
 		$this->getLogger()->info( 'Updating annunci' );
116 116
 		$section = 1;
117 117
 
118
-		$names = [];
118
+		$names = [ ];
119 119
 		$text = '';
120 120
 		foreach ( $pages as $page ) {
121 121
 			$user = $page->getUser()->getName();
122
-			$names[] = $user;
122
+			$names[ ] = $user;
123 123
 			$text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text();
124 124
 		}
125 125
 
@@ -151,16 +151,16 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param PageRiconferma[] $pages
153 153
 	 */
154
-	protected function updateUltimeNotizie( array $pages ) {
154
+	protected function updateUltimeNotizie ( array $pages ) {
155 155
 		$this->getLogger()->info( 'Updating ultime notizie' );
156 156
 		$notiziePage = new Page( $this->getOpt( 'ultimenotizie-page-title' ) );
157 157
 
158
-		$names = [];
158
+		$names = [ ];
159 159
 		$text = '';
160 160
 		$msg = $this->msg( 'ultimenotizie-text' );
161 161
 		foreach ( $pages as $page ) {
162 162
 			$user = $page->getUser()->getName();
163
-			$names[] = $user;
163
+			$names[ ] = $user;
164 164
 			$text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text();
165 165
 		}
166 166
 
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 	 * @param PageRiconferma[] $pages
190 190
 	 * @return User[]
191 191
 	 */
192
-	private function getFailedBureaucrats( array $pages ) : array {
193
-		$ret = [];
192
+	private function getFailedBureaucrats ( array $pages ) : array {
193
+		$ret = [ ];
194 194
 		foreach ( $pages as $page ) {
195 195
 			$user = $page->getUser();
196 196
 			if ( $user->inGroup( 'bureaucrat' ) ) {
197
-				$ret[] = $user;
197
+				$ret[ ] = $user;
198 198
 			}
199 199
 		}
200 200
 		return $ret;
Please login to merge, or discard this patch.
includes/Wiki/User.php 1 patch
Spacing   +8 added lines, -8 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
 
@@ -16,14 +16,14 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @param string $name
18 18
 	 */
19
-	public function __construct( string $name ) {
19
+	public function __construct ( string $name ) {
20 20
 		$this->name = $name;
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @return string
25 25
 	 */
26
-	public function getName() : string {
26
+	public function getName () : string {
27 27
 		return $this->name;
28 28
 	}
29 29
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return string[]
34 34
 	 */
35
-	public function getGroups() : array {
35
+	public function getGroups () : array {
36 36
 		return array_keys( $this->getGroupsWithDates() );
37 37
 	}
38 38
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @return string[]
44 44
 	 */
45
-	public function getGroupsWithDates() : array {
45
+	public function getGroupsWithDates () : array {
46 46
 		if ( $this->groups === null ) {
47 47
 			$usersList = PageBotList::get()->getAdminsList();
48 48
 			$this->groups = $usersList[ $this->name ];
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @param string $groupName
57 57
 	 * @return bool
58 58
 	 */
59
-	public function inGroup( string $groupName ) : bool {
59
+	public function inGroup ( string $groupName ) : bool {
60 60
 		return in_array( $groupName, $this->getGroups() );
61 61
 	}
62 62
 
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	 *
66 66
 	 * @inheritDoc
67 67
 	 */
68
-	public function getRegex() : string {
68
+	public function getRegex () : string {
69 69
 		return str_replace( ' ', '[ _]', preg_quote( $this->name ) );
70 70
 	}
71 71
 
72 72
 	/**
73 73
 	 * @return string
74 74
 	 */
75
-	public function __toString() {
75
+	public function __toString () {
76 76
 		return $this->name;
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
includes/Config.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;
4 4
 
@@ -13,12 +13,12 @@  discard block
 block discarded – undo
13 13
 	/** @var self */
14 14
 	private static $instance;
15 15
 	/** @var array */
16
-	private $opts = [];
16
+	private $opts = [ ];
17 17
 
18 18
 	/**
19 19
 	 * Use self::init() and self::getInstance()
20 20
 	 */
21
-	private function __construct() {
21
+	private function __construct () {
22 22
 	}
23 23
 
24 24
 	/**
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 	 * @param array $defaults
28 28
 	 * @throws ConfigException
29 29
 	 */
30
-	public static function init( array $defaults ) {
30
+	public static function init ( array $defaults ) {
31 31
 		if ( self::$instance ) {
32 32
 			throw new ConfigException( 'Config was already initialized' );
33 33
 		}
34 34
 
35 35
 		$inst = new self;
36
-		$inst->set( 'list-title', $defaults['list-title'] );
37
-		$inst->set( 'msg-title', $defaults['msg-title'] );
38
-		$inst->set( 'username', $defaults['username'] );
39
-		$inst->set( 'password', $defaults['password'] );
36
+		$inst->set( 'list-title', $defaults[ 'list-title' ] );
37
+		$inst->set( 'msg-title', $defaults[ 'msg-title' ] );
38
+		$inst->set( 'username', $defaults[ 'username' ] );
39
+		$inst->set( 'password', $defaults[ 'password' ] );
40 40
 		self::$instance = $inst;
41 41
 
42 42
 		// On-wiki values
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 * @return string
57 57
 	 * @throws ConfigException
58 58
 	 */
59
-	public function getWikiMessage( string $key ) : string {
59
+	public function getWikiMessage ( string $key ) : string {
60 60
 		static $messages = null;
61 61
 		if ( $messages === null ) {
62 62
 			try {
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		if ( !isset( $messages[ $key ] ) ) {
70 70
 			throw new ConfigException( "Message '$key' does not exist." );
71 71
 		}
72
-		return $messages[$key];
72
+		return $messages[ $key ];
73 73
 	}
74 74
 
75 75
 	/**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param string $key
79 79
 	 * @param mixed $value
80 80
 	 */
81
-	protected function set( string $key, $value ) {
81
+	protected function set ( string $key, $value ) {
82 82
 		$this->opts[ $key ] = $value;
83 83
 	}
84 84
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @return self
89 89
 	 * @throws ConfigException
90 90
 	 */
91
-	public static function getInstance() : self {
91
+	public static function getInstance () : self {
92 92
 		if ( !self::$instance ) {
93 93
 			throw new ConfigException( 'Config not yet initialized' );
94 94
 		}
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @return mixed
103 103
 	 * @throws ConfigException
104 104
 	 */
105
-	public function get( string $opt ) {
105
+	public function get ( string $opt ) {
106 106
 		if ( !isset( $this->opts[ $opt ] ) ) {
107 107
 			throw new ConfigException( "Config option '$opt' not set." );
108 108
 		}
Please login to merge, or discard this patch.
includes/Wiki/Page/PageBotList.php 1 patch
Spacing   +13 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\Wiki\Page;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @private Use self::get()
13 13
 	 */
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		parent::__construct( Config::getInstance()->get( 'list-title' ) );
16 16
 	}
17 17
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @return self
22 22
 	 */
23
-	public static function get() : self {
23
+	public static function get () : self {
24 24
 		static $instance = null;
25 25
 		if ( $instance === null ) {
26 26
 			$instance = new self;
@@ -32,16 +32,16 @@  discard block
 block discarded – undo
32 32
 	 * @param string[] $groups
33 33
 	 * @return int|null
34 34
 	 */
35
-	public static function getOverrideTimestamp( array $groups ) : ?int {
35
+	public static function getOverrideTimestamp ( array $groups ) : ?int {
36 36
 		if ( !array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) {
37 37
 			return null;
38 38
 		}
39 39
 
40 40
 		// A one-time override takes precedence
41 41
 		if ( array_key_exists( 'override', $groups ) ) {
42
-			$date = $groups['override'];
42
+			$date = $groups[ 'override' ];
43 43
 		} else {
44
-			$date = $groups['override-prem'] . '/' . date( 'Y' );
44
+			$date = $groups[ 'override-prem' ] . '/' . date( 'Y' );
45 45
 		}
46 46
 		return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp();
47 47
 	}
@@ -52,17 +52,15 @@  discard block
 block discarded – undo
52 52
 	 * @param array $groups
53 53
 	 * @return int
54 54
 	 */
55
-	public static function getValidFlagTimestamp( array $groups ): int {
56
-		$checkuser = isset( $groups['checkuser'] ) ?
57
-			\DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() :
58
-			0;
59
-		$bureaucrat = isset( $groups['bureaucrat'] ) ?
60
-			\DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() :
61
-			0;
55
+	public static function getValidFlagTimestamp ( array $groups ): int {
56
+		$checkuser = isset( $groups[ 'checkuser' ] ) ?
57
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
58
+		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
59
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
62 60
 
63 61
 		$timestamp = max( $bureaucrat, $checkuser );
64 62
 		if ( $timestamp === 0 ) {
65
-			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp();
63
+			$timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp();
66 64
 		}
67 65
 		return $timestamp;
68 66
 	}
@@ -72,7 +70,7 @@  discard block
 block discarded – undo
72 70
 	 *
73 71
 	 * @return array[]
74 72
 	 */
75
-	public function getAdminsList() : array {
73
+	public function getAdminsList () : array {
76 74
 		return json_decode( $this->getContent(), true );
77 75
 	}
78 76
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/SimpleUpdates.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	/**
18 18
 	 * @inheritDoc
19 19
 	 */
20
-	public function runInternal() : int {
20
+	public function runInternal () : int {
21 21
 		$pages = $this->getDataProvider()->getPagesToClose();
22 22
 
23 23
 		if ( !$pages ) {
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 	 * @param PageRiconferma[] $pages
40 40
 	 * @see OpenUpdates::addToVotazioni()
41 41
 	 */
42
-	protected function updateVotazioni( array $pages ) {
42
+	protected function updateVotazioni ( array $pages ) {
43 43
 		$this->getLogger()->info(
44 44
 			'Updating votazioni: ' . implode( ', ', $pages )
45 45
 		);
46 46
 		$votePage = new Page( $this->getOpt( 'vote-page-title' ) );
47 47
 
48
-		$users = [];
48
+		$users = [ ];
49 49
 		foreach ( $pages as $page ) {
50
-			$users[] = $page->getUser();
50
+			$users[ ] = $page->getUser();
51 51
 		}
52 52
 		$usersReg = Element::regexFromArray( $users );
53 53
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param array $pages
69 69
 	 * @see OpenUpdates::addToNews()
70 70
 	 */
71
-	protected function updateNews( array $pages ) {
71
+	protected function updateNews ( array $pages ) {
72 72
 		$simpleAmount = $voteAmount = 0;
73 73
 		foreach ( $pages as $page ) {
74 74
 			if ( $page->isVote() ) {
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 		$simpleMatches = $newsPage->getMatch( $simpleReg );
89 89
 		$voteMatches = $newsPage->getMatch( $voteReg );
90 90
 
91
-		$newSimp = (int)$simpleMatches[2] - $simpleAmount ?: '';
92
-		$newVote = (int)$voteMatches[2] - $voteAmount ?: '';
91
+		$newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: '';
92
+		$newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: '';
93 93
 		$newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() );
94 94
 		$newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent );
95 95
 
@@ -107,12 +107,12 @@  discard block
 block discarded – undo
107 107
 	 *
108 108
 	 * @param bool[] $outcomes
109 109
 	 */
110
-	protected function updateAdminList( array $outcomes ) {
110
+	protected function updateAdminList ( array $outcomes ) {
111 111
 		$this->getLogger()->info( 'Updating admin list' );
112 112
 		$adminsPage = new Page( $this->getOpt( 'admins-list-title' ) );
113 113
 		$newContent = $adminsPage->getContent();
114 114
 
115
-		$riconfNames = $removeNames = [];
115
+		$riconfNames = $removeNames = [ ];
116 116
 		foreach ( $outcomes as $username => $confirmed ) {
117 117
 			$user = new User( $username );
118 118
 			$userReg = $user->getRegex();
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 					'${1}' . date( 'Ymd' ) . '|' . $nextDate . '$2',
125 125
 					$newContent
126 126
 				);
127
-				$riconfNames[] = $username;
127
+				$riconfNames[ ] = $username;
128 128
 			} else {
129 129
 				$newContent = preg_replace( $reg, '', $newContent );
130
-				$removeNames[] = $username;
130
+				$removeNames[ ] = $username;
131 131
 			}
132 132
 		}
133 133
 
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 	 * @param User $user
151 151
 	 * @return int
152 152
 	 */
153
-	private function getNextTs( User $user ) : int {
153
+	private function getNextTs ( User $user ) : int {
154 154
 		$groups = $user->getGroupsWithDates();
155
-		if ( isset( $groups['override-perm'] ) ) {
155
+		if ( isset( $groups[ 'override-perm' ] ) ) {
156 156
 			$date = \DateTime::createFromFormat(
157 157
 				'd/m/Y',
158
-				$groups['override-perm'] . '/' . date( 'Y' )
158
+				$groups[ 'override-perm' ] . '/' . date( 'Y' )
159 159
 			);
160 160
 			if ( $date < new \DateTime ) {
161 161
 				$date->modify( '+1 year' );
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 		} else {
165 165
 			$ts = PageBotList::getValidFlagTimestamp( $groups );
166 166
 			$res = strtotime( date( 'Y', strtotime( '+1 year' ) ) . date( '-m-d', $ts ) );
167
-			if ( isset( $groups['override'] ) ) {
168
-				$date = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] );
167
+			if ( isset( $groups[ 'override' ] ) ) {
168
+				$date = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] );
169 169
 				if ( $date > new \DateTime ) {
170 170
 					$res = $date->getTimestamp();
171 171
 				}
@@ -177,21 +177,21 @@  discard block
 block discarded – undo
177 177
 	/**
178 178
 	 * @param bool[] $outcomes
179 179
 	 */
180
-	protected function updateCUList( array $outcomes ) {
180
+	protected function updateCUList ( array $outcomes ) {
181 181
 		$this->getLogger()->info( 'Updating CU list.' );
182 182
 		$cuList = new Page( $this->getOpt( 'cu-list-title' ) );
183 183
 		$newContent = $cuList->getContent();
184 184
 
185
-		$riconfNames = $removeNames = [];
185
+		$riconfNames = $removeNames = [ ];
186 186
 		foreach ( $outcomes as $user => $confirmed ) {
187 187
 			$userReg = ( new User( $user ) )->getRegex();
188 188
 			$reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!";
189 189
 			if ( $confirmed ) {
190 190
 				$newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent );
191
-				$riconfNames[] = $user;
191
+				$riconfNames[ ] = $user;
192 192
 			} else {
193 193
 				$newContent = preg_replace( $reg, '', $newContent );
194
-				$removeNames[] = $user;
194
+				$removeNames[ ] = $user;
195 195
 			}
196 196
 		}
197 197
 
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param PageRiconferma[] $pages
216 216
 	 * @return bool[]
217 217
 	 */
218
-	private function getGroupOutcomes( string $group, array $pages ) : array {
219
-		$ret = [];
218
+	private function getGroupOutcomes ( string $group, array $pages ) : array {
219
+		$ret = [ ];
220 220
 		foreach ( $pages as $page ) {
221 221
 			$user = $page->getUser();
222 222
 			if ( $user->inGroup( $group ) ) {
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
 
@@ -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,18 +33,18 @@  discard block
 block discarded – undo
33 33
 	 * @param PageRiconferma[] $pages
34 34
 	 * @see OpenUpdates::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 44
 			// Order matters here. It's not guaranteed that there'll be a newline, but avoid
45 45
 			// regexps for that single character.
46
-			$remove[] = '{{' . $page->getTitle() . "}}\n";
47
-			$remove[] = '{{' . $page->getTitle() . '}}';
46
+			$remove[ ] = '{{' . $page->getTitle() . "}}\n";
47
+			$remove[ ] = '{{' . $page->getTitle() . '}}';
48 48
 		}
49 49
 
50 50
 		$newContent = str_replace( $remove, '', $mainPage->getContent() );
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @param PageRiconferma[] $pages
75 75
 	 */
76
-	protected function addToArchive( array $pages ) {
76
+	protected function addToArchive ( array $pages ) {
77 77
 		$this->getLogger()->info(
78 78
 			'Adding to archive: ' . implode( ', ', $pages )
79 79
 		);
80 80
 
81
-		$simple = $votes = [];
81
+		$simple = $votes = [ ];
82 82
 		foreach ( $pages as $page ) {
83 83
 			if ( $page->isVote() ) {
84
-				$votes[] = $page;
84
+				$votes[ ] = $page;
85 85
 			} else {
86
-				$simple[] = $page;
86
+				$simple[ ] = $page;
87 87
 			}
88 88
 		}
89 89
 
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 	 * @param string $archiveTitle
105 105
 	 * @param array $pages
106 106
 	 */
107
-	private function reallyAddToArchive( string $archiveTitle, array $pages ) {
107
+	private function reallyAddToArchive ( string $archiveTitle, array $pages ) {
108 108
 		$archivePage = new Page( "$archiveTitle/" . date( 'Y' ) );
109 109
 		$exists = $archivePage->exists();
110 110
 
111 111
 		$append = "\n";
112
-		$archivedList = [];
112
+		$archivedList = [ ];
113 113
 		foreach ( $pages as $page ) {
114 114
 			$append .= '{{' . $page->getTitle() . "}}\n";
115
-			$archivedList[] = $page->getUserNum();
115
+			$archivedList[ ] = $page->getUserNum();
116 116
 		}
117 117
 
118 118
 		$summary = $this->msg( 'close-archive-summary' )
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param string $archiveTitle
135 135
 	 */
136
-	private function addArchiveYear( string $archiveTitle ) {
136
+	private function addArchiveYear ( string $archiveTitle ) {
137 137
 		$page = new Page( $archiveTitle );
138 138
 		$year = date( 'Y' );
139 139
 
Please login to merge, or discard this patch.
includes/Task/UpdateList.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\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
 		$params = [
58 58
 			'action' => 'query',
59 59
 			'list' => 'allusers',
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 	 * @param \stdClass $data
71 71
 	 * @return array
72 72
 	 */
73
-	protected function extractAdmins( \stdClass $data ) : array {
74
-		$ret = [];
73
+	protected function extractAdmins ( \stdClass $data ) : array {
74
+		$ret = [ ];
75 75
 		$blacklist = $this->getOpt( 'exclude-admins' );
76 76
 		foreach ( $data->query->allusers as $u ) {
77 77
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return array[]
90 90
 	 */
91
-	protected function getMissingGroups() : array {
92
-		$missing = [];
91
+	protected function getMissingGroups () : array {
92
+		$missing = [ ];
93 93
 		foreach ( $this->actualList as $adm => $groups ) {
94
-			$curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) );
94
+			$curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) );
95 95
 
96 96
 			foreach ( $curMissing as $group ) {
97 97
 				try {
98 98
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
99 99
 				} catch ( TaskException $e ) {
100
-					$this->errors[] = $e->getMessage();
100
+					$this->errors[ ] = $e->getMessage();
101 101
 				}
102 102
 			}
103 103
 		}
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @return string
113 113
 	 * @throws TaskException
114 114
 	 */
115
-	protected function getFlagDate( string $admin, string $group ) : string {
115
+	protected function getFlagDate ( string $admin, string $group ) : string {
116 116
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
117 117
 
118 118
 		$url = DEFAULT_URL;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @param string $group
148 148
 	 * @return string|null
149 149
 	 */
150
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
150
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
151 151
 		$ts = null;
152 152
 		foreach ( $data->query->logevents as $entry ) {
153 153
 			if ( isset( $entry->params ) ) {
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 	 *
167 167
 	 * @return array[]
168 168
 	 */
169
-	protected function getExtraGroups() : array {
170
-		$extra = [];
169
+	protected function getExtraGroups () : array {
170
+		$extra = [ ];
171 171
 		foreach ( $this->botList as $name => $groups ) {
172 172
 			// These are not groups
173 173
 			unset( $groups[ 'override' ], $groups[ 'override-perm' ] );
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @param array[] $extra
188 188
 	 * @return array[]
189 189
 	 */
190
-	protected function getNewContent( array $missing, array $extra ) : array {
190
+	protected function getNewContent ( array $missing, array $extra ) : array {
191 191
 		$newContent = $this->botList;
192 192
 		foreach ( $newContent as $user => $groups ) {
193 193
 			if ( isset( $missing[ $user ] ) ) {
@@ -211,21 +211,21 @@  discard block
 block discarded – undo
211 211
 	 * @param array[] $newContent
212 212
 	 * @return array[]
213 213
 	 */
214
-	protected function removeOverrides( array $newContent ) : array {
215
-		$removed = [];
214
+	protected function removeOverrides ( array $newContent ) : array {
215
+		$removed = [ ];
216 216
 		foreach ( $newContent as $user => $groups ) {
217
-			if ( !isset( $groups['override'] ) ) {
217
+			if ( !isset( $groups[ 'override' ] ) ) {
218 218
 				continue;
219 219
 			}
220 220
 
221 221
 			$flagTS = PageBotList::getValidFlagTimestamp( $groups );
222 222
 			$usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) );
223
-			$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp();
223
+			$overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp();
224 224
 			$delay = 60 * 60 * 24 * 3;
225 225
 
226 226
 			if ( time() > $usualTS + $delay && time() > $overrideTS + $delay ) {
227 227
 				unset( $newContent[ $user ][ 'override' ] );
228
-				$removed[] = $user;
228
+				$removed[ ] = $user;
229 229
 			}
230 230
 		}
231 231
 
Please login to merge, or discard this patch.
includes/Bot.php 1 patch
Spacing   +7 added lines, -8 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 	public const VERSION = '1.0';
13 13
 
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		$this->logger = new Logger;
16 16
 	}
17 17
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param string $mode
22 22
 	 * @param string|null $name
23 23
 	 */
24
-	private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
24
+	private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) {
25 25
 		$activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name";
26 26
 		$this->logger->info( "Running $activity" );
27 27
 		$manager = new TaskManager;
@@ -30,8 +30,7 @@  discard block
 block discarded – undo
30 30
 		$base = "Execution of $activity";
31 31
 		if ( $res->isOK() ) {
32 32
 			$msg = $res->getStatus() === TaskResult::STATUS_NOTHING ?
33
-				': nothing to do' :
34
-				' completed successfully';
33
+				': nothing to do' : ' completed successfully';
35 34
 			$this->logger->info( $base . $msg . ".\n$line\n\n" );
36 35
 		} else {
37 36
 			$this->logger->error( "$base failed.\n$res\n$line\n\n" );
@@ -41,7 +40,7 @@  discard block
 block discarded – undo
41 40
 	/**
42 41
 	 * Entry point for the whole process
43 42
 	 */
44
-	public function runAll() {
43
+	public function runAll () {
45 44
 		$this->run();
46 45
 	}
47 46
 
@@ -50,7 +49,7 @@  discard block
 block discarded – undo
50 49
 	 *
51 50
 	 * @param string $task
52 51
 	 */
53
-	public function runTask( string $task ) {
52
+	public function runTask ( string $task ) {
54 53
 		$this->run( TaskManager::MODE_TASK, $task );
55 54
 	}
56 55
 
@@ -59,7 +58,7 @@  discard block
 block discarded – undo
59 58
 	 *
60 59
 	 * @param string $subtask
61 60
 	 */
62
-	public function runSubtask( string $subtask ) {
61
+	public function runSubtask ( string $subtask ) {
63 62
 		$this->run( TaskManager::MODE_SUBTASK, $subtask );
64 63
 	}
65 64
 }
Please login to merge, or discard this patch.
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.