Passed
Push — master ( ca2213...f473bb )
by Daimona
01:49
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
 			$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->getConfig()->get( '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,16 +109,16 @@  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
 		$msg = $this->msg( 'annunci-text' );
119 119
 		foreach ( $pages as $page ) {
120 120
 			$user = $page->getUser()->getName();
121
-			$names[] = $user;
121
+			$names[ ] = $user;
122 122
 			$text .= $msg->params( [ '$user' => $user ] )->text();
123 123
 		}
124 124
 
@@ -150,16 +150,16 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param PageRiconferma[] $pages
152 152
 	 */
153
-	protected function updateUltimeNotizie( array $pages ) {
153
+	protected function updateUltimeNotizie ( array $pages ) {
154 154
 		$this->getLogger()->info( 'Updating ultime notizie' );
155 155
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) );
156 156
 
157
-		$names = [];
157
+		$names = [ ];
158 158
 		$text = '';
159 159
 		$msg = $this->msg( 'ultimenotizie-text' );
160 160
 		foreach ( $pages as $page ) {
161 161
 			$user = $page->getUser()->getName();
162
-			$names[] = $user;
162
+			$names[ ] = $user;
163 163
 			$text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text();
164 164
 		}
165 165
 
@@ -188,12 +188,12 @@  discard block
 block discarded – undo
188 188
 	 * @param PageRiconferma[] $pages
189 189
 	 * @return User[]
190 190
 	 */
191
-	private function getFailedBureaucrats( array $pages ) : array {
192
-		$ret = [];
191
+	private function getFailedBureaucrats ( array $pages ) : array {
192
+		$ret = [ ];
193 193
 		foreach ( $pages as $page ) {
194 194
 			$user = $page->getUser();
195 195
 			if ( $user->inGroup( 'bureaucrat' ) ) {
196
-				$ret[] = $user;
196
+				$ret[ ] = $user;
197 197
 			}
198 198
 		}
199 199
 		return $ret;
Please login to merge, or discard this patch.
includes/Wiki/Element.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\Wiki;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	 *
12 12
 	 * @return string
13 13
 	 */
14
-	abstract public function getRegex() : string;
14
+	abstract public function getRegex () : string;
15 15
 
16 16
 	/**
17 17
 	 * Get a regex matching any element in the given array
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 	 * @return string
21 21
 	 * @todo Is this the right place?
22 22
 	 */
23
-	public static function regexFromArray( array $elements ) : string {
24
-		$bits = [];
23
+	public static function regexFromArray ( array $elements ) : string {
24
+		$bits = [ ];
25 25
 		foreach ( $elements as $el ) {
26
-			$bits[] = $el->getRegex();
26
+			$bits[ ] = $el->getRegex();
27 27
 		}
28 28
 		return '(?:' . implode( '|', $bits ) . ')';
29 29
 	}
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->getConfig()->get( '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/UpdatesAround.php 1 patch
Spacing   +7 added lines, -7 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
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function runInternal() : int {
18
+	public function runInternal () : int {
19 19
 		$pages = $this->getDataProvider()->getCreatedPages();
20 20
 
21 21
 		if ( !$pages ) {
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param PageRiconferma[] $pages
39 39
 	 */
40
-	protected function addToMainPage( array $pages ) {
40
+	protected function addToMainPage ( array $pages ) {
41 41
 		$this->getLogger()->info(
42 42
 			'Adding the following to main: ' . implode( ', ', $pages )
43 43
 		);
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param PageRiconferma[] $pages
66 66
 	 * @throws TaskException
67 67
 	 */
68
-	protected function addToVotazioni( array $pages ) {
68
+	protected function addToVotazioni ( array $pages ) {
69 69
 		$this->getLogger()->info(
70 70
 			'Adding the following to votes: ' . implode( ', ', $pages )
71 71
 		);
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
95 95
 			// Replace semicolon with full stop
96 96
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
97
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
97
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
98 98
 		}
99 99
 
100 100
 		$summary = $this->msg( 'vote-page-summary' )
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @param int $amount
115 115
 	 * @throws TaskException
116 116
 	 */
117
-	protected function addToNews( int $amount ) {
117
+	protected function addToNews ( int $amount ) {
118 118
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
119 119
 		$newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) );
120 120
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			throw new TaskException( 'Param not found in news page' );
128 128
 		}
129 129
 
130
-		$newNum = (int)$matches[2] + $amount;
130
+		$newNum = (int)$matches[ 2 ] + $amount;
131 131
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
132 132
 
133 133
 		$summary = $this->msg( 'news-page-summary' )
Please login to merge, or discard this patch.
includes/Task/TaskBase.php 1 patch
Spacing   +10 added lines, -10 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
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 abstract class TaskBase extends ContextSource {
13 13
 	/** @var string[] */
14
-	protected $errors = [];
14
+	protected $errors = [ ];
15 15
 	/** @var TaskDataProvider */
16 16
 	protected $dataProvider;
17 17
 
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param TaskDataProvider $dataProvider
22 22
 	 */
23
-	final public function __construct( TaskDataProvider $dataProvider ) {
23
+	final public function __construct ( TaskDataProvider $dataProvider ) {
24 24
 		set_exception_handler( [ $this, 'handleException' ] );
25 25
 		set_error_handler( [ $this, 'handleError' ] );
26 26
 		parent::__construct();
27 27
 		$this->dataProvider = $dataProvider;
28 28
 	}
29 29
 
30
-	public function __destruct() {
30
+	public function __destruct () {
31 31
 		restore_error_handler();
32 32
 		restore_exception_handler();
33 33
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return TaskResult
39 39
 	 */
40
-	final public function run() : TaskResult {
40
+	final public function run () : TaskResult {
41 41
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
42 42
 		$opName = $this->getOperationName();
43 43
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return int One of the STATUS_* constants
70 70
 	 */
71
-	abstract protected function runInternal() : int;
71
+	abstract protected function runInternal () : int;
72 72
 
73 73
 	/**
74 74
 	 * How this operation should be called in logs
75 75
 	 *
76 76
 	 * @return string
77 77
 	 */
78
-	abstract public function getOperationName() : string;
78
+	abstract public function getOperationName () : string;
79 79
 
80 80
 	/**
81 81
 	 * Exception handler.
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param \Throwable $ex
84 84
 	 * @protected
85 85
 	 */
86
-	public function handleException( \Throwable $ex ) {
86
+	public function handleException ( \Throwable $ex ) {
87 87
 		$this->getLogger()->error(
88 88
 			( new \ReflectionClass( $ex ) )->getShortName() . ': ' .
89 89
 			$ex->getMessage() . "\nin " . $ex->getFile() . ' line ' .
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
 	 * @throws \ErrorException
102 102
 	 * @protected
103 103
 	 */
104
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
104
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
105 105
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
106 106
 	}
107 107
 
108 108
 	/**
109 109
 	 * @return TaskDataProvider
110 110
 	 */
111
-	protected function getDataProvider() : TaskDataProvider {
111
+	protected function getDataProvider () : TaskDataProvider {
112 112
 		return $this->dataProvider;
113 113
 	}
114 114
 }
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
 
@@ -16,15 +16,15 @@  discard block
 block discarded – undo
16 16
 	/**
17 17
 	 * @inheritDoc
18 18
 	 */
19
-	protected function getSubtasksMap(): array {
19
+	protected function getSubtasksMap (): array {
20 20
 		// Everything is done here.
21
-		return [];
21
+		return [ ];
22 22
 	}
23 23
 
24 24
 	/**
25 25
 	 * @inheritDoc
26 26
 	 */
27
-	public function runInternal() : int {
27
+	public function runInternal () : int {
28 28
 		$pages = $this->getDataProvider()->getOpenPages();
29 29
 
30 30
 		if ( !$pages ) {
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	 * @param PageRiconferma[] $pages
39 39
 	 * @return int a STATUS_* constant
40 40
 	 */
41
-	protected function processPages( array $pages ) : int {
42
-		$actualPages = [];
41
+	protected function processPages ( array $pages ) : int {
42
+		$actualPages = [ ];
43 43
 		foreach ( $pages as $page ) {
44 44
 			if ( $page->hasOpposition() && !$page->isVote() ) {
45 45
 				$this->openVote( $page );
46
-				$actualPages[] = $page;
46
+				$actualPages[ ] = $page;
47 47
 			}
48 48
 		}
49 49
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @param PageRiconferma $page
63 63
 	 */
64
-	protected function openVote( PageRiconferma $page ) {
64
+	protected function openVote ( PageRiconferma $page ) {
65 65
 		$this->getLogger()->info( "Starting vote on $page" );
66 66
 
67 67
 		$content = $page->getContent();
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @see UpdatesAround::addToVotazioni()
102 102
 	 * @throws TaskException
103 103
 	 */
104
-	protected function updateVotePage( array $pages ) {
104
+	protected function updateVotePage ( array $pages ) {
105 105
 		$votePage = new Page( $this->getConfig()->get( 'vote-page-title' ) );
106 106
 		$content = $votePage->getContent();
107 107
 
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 );
129 129
 		} else {
130 130
 			// Start section
131
-			$matches = [];
131
+			$matches = [ ];
132 132
 			if ( preg_match( $introReg, $newContent, $matches ) === 0 ) {
133 133
 				throw new TaskException( 'Intro not found in vote page' );
134 134
 			}
135 135
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
136 136
 			// Replace semicolon with full stop
137 137
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
138
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 );
138
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 );
139 139
 		}
140 140
 
141 141
 		$summary = $this->msg( 'vote-start-vote-page-summary' )
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @see SimpleUpdates::updateNews()
159 159
 	 * @throws TaskException
160 160
 	 */
161
-	protected function updateNews( int $amount ) {
161
+	protected function updateNews ( int $amount ) {
162 162
 		$this->getLogger()->info( "Turning $amount pages into votes" );
163 163
 		$newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) );
164 164
 
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
 			throw new TaskException( 'Param "voto" not found in news page' );
174 174
 		}
175 175
 
176
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
177
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
176
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
177
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
178 178
 
179 179
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
180 180
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/Wiki/Controller.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Wiki;
4 4
 
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @param string $domain The URL of the wiki, if different from default
29 29
 	 */
30
-	public function __construct( string $domain = DEFAULT_URL ) {
30
+	public function __construct ( string $domain = DEFAULT_URL ) {
31 31
 		$this->logger = new Logger;
32 32
 		$this->domain = $domain;
33 33
 	}
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 * @throws MissingPageException
42 42
 	 * @throws MissingSectionException
43 43
 	 */
44
-	public function getPageContent( string $title, int $section = null ) : string {
44
+	public function getPageContent ( string $title, int $section = null ) : string {
45 45
 		$msg = "Retrieving content of page $title" . ( $section !== null ? ", section $section" : '' );
46 46
 		$this->logger->debug( $msg );
47 47
 		$params = [
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		];
54 54
 
55 55
 		if ( $section !== null ) {
56
-			$params['rvsection'] = $section;
56
+			$params[ 'rvsection' ] = $section;
57 57
 		}
58 58
 
59 59
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			throw new MissingPageException( $title );
64 64
 		}
65 65
 
66
-		$mainSlot = $page->revisions[0]->slots->main;
66
+		$mainSlot = $page->revisions[ 0 ]->slots->main;
67 67
 
68 68
 		if ( $section !== null && isset( $mainSlot->nosuchsection ) ) {
69 69
 			throw new MissingSectionException( $title, $section );
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param array $params
78 78
 	 * @throws EditException
79 79
 	 */
80
-	public function editPage( array $params ) {
80
+	public function editPage ( array $params ) {
81 81
 		$this->login();
82 82
 
83 83
 		$params = [
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
105 105
 	 * @throws LoginException
106 106
 	 */
107
-	public function login() {
107
+	public function login () {
108 108
 		if ( self::$loggedIn ) {
109 109
 			return;
110 110
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 
131 131
 		self::$loggedIn = true;
132 132
 		// Clear tokens cache
133
-		$this->tokens = [];
133
+		$this->tokens = [ ];
134 134
 		$this->logger->info( 'Login succeeded' );
135 135
 	}
136 136
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @param string $type
141 141
 	 * @return string
142 142
 	 */
143
-	public function getToken( string $type ) : string {
143
+	public function getToken ( string $type ) : string {
144 144
 		if ( !isset( $this->tokens[ $type ] ) ) {
145 145
 			$params = [
146 146
 				'action' => 'query',
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param string $title
164 164
 	 * @return int
165 165
 	 */
166
-	public function getPageCreationTS( string $title ) : int {
166
+	public function getPageCreationTS ( string $title ) : int {
167 167
 		$params = [
168 168
 			'action' => 'query',
169 169
 			'prop' => 'revisions',
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 
177 177
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
178 178
 		$data = $res->query->pages;
179
-		return strtotime( reset( $data )->revisions[0]->timestamp );
179
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
180 180
 	}
181 181
 
182 182
 	/**
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * @param string $title
186 186
 	 * @param string $reason
187 187
 	 */
188
-	public function protectPage( string $title, string $reason ) {
188
+	public function protectPage ( string $title, string $reason ) {
189 189
 		$this->logger->info( "Protecting page $title" );
190 190
 		$this->login();
191 191
 
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
 		// @phan-suppress-next-line PhanTypeMismatchReturn WTF? Why does phan thinks this is a string?
63 63
 		return strlen( $header );
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
 	 * Set a config value.
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @param string $key
78 78
 	 * @param mixed $value
79 79
 	 */
80
-	protected function set( string $key, $value ) {
80
+	protected function set ( string $key, $value ) {
81 81
 		$this->opts[ $key ] = $value;
82 82
 	}
83 83
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return self
88 88
 	 * @throws ConfigException
89 89
 	 */
90
-	public static function getInstance() : self {
90
+	public static function getInstance () : self {
91 91
 		if ( !self::$instance ) {
92 92
 			throw new ConfigException( 'Config not yet initialized' );
93 93
 		}
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return mixed
102 102
 	 * @throws ConfigException
103 103
 	 */
104
-	public function get( string $opt ) {
104
+	public function get ( string $opt ) {
105 105
 		if ( !isset( $this->opts[ $opt ] ) ) {
106 106
 			throw new ConfigException( "Config option '$opt' not set." );
107 107
 		}
Please login to merge, or discard this patch.