Passed
Push — master ( a45d4a...1801c5 )
by Daimona
01:34
created
includes/Request/RequestBase.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\Request;
4 4
 
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	/** @var string */
30 30
 	protected $method = 'GET';
31 31
 	/** @var string[] */
32
-	protected $newCookies = [];
32
+	protected $newCookies = [ ];
33 33
 
34 34
 	/**
35 35
 	 * Use self::newFromParams, which will provide the right class to use
36 36
 	 *
37 37
 	 * @param array $params
38 38
 	 */
39
-	protected function __construct( array $params ) {
39
+	protected function __construct ( array $params ) {
40 40
 		$this->params = [ 'format' => 'json' ] + $params;
41 41
 		$this->url = DEFAULT_URL;
42 42
 	}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param array $params
48 48
 	 * @return self
49 49
 	 */
50
-	public static function newFromParams( array $params ) : self {
50
+	public static function newFromParams ( array $params ) : self {
51 51
 		if ( extension_loaded( 'curl' ) ) {
52 52
 			$ret = new CurlRequest( $params );
53 53
 		} else {
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return self For chaining
63 63
 	 */
64
-	public function setPost() : self {
64
+	public function setPost () : self {
65 65
 		$this->method = 'POST';
66 66
 		return $this;
67 67
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string $url
73 73
 	 * @return self for chaining
74 74
 	 */
75
-	public function setUrl( string $url ) : self {
75
+	public function setUrl ( string $url ) : self {
76 76
 		$this->url = $url;
77 77
 		return $this;
78 78
 	}
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @return \stdClass
84 84
 	 */
85
-	public function execute() : \stdClass {
85
+	public function execute () : \stdClass {
86 86
 		$curParams = $this->params;
87
-		$sets = [];
87
+		$sets = [ ];
88 88
 		do {
89 89
 			$res = $this->makeRequestInternal( $curParams );
90 90
 
91 91
 			$this->handleErrorAndWarnings( $res );
92
-			$sets[] = $res;
92
+			$sets[ ] = $res;
93 93
 
94 94
 			$finished = true;
95 95
 			if ( isset( $res->continue ) ) {
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * @param array $params
108 108
 	 * @return \stdClass
109 109
 	 */
110
-	private function makeRequestInternal( array $params ) : \stdClass {
110
+	private function makeRequestInternal ( array $params ) : \stdClass {
111 111
 		if ( $this->method === 'POST' ) {
112
-			$params['maxlag'] = self::MAXLAG;
112
+			$params[ 'maxlag' ] = self::MAXLAG;
113 113
 		}
114 114
 		$params = http_build_query( $params );
115 115
 
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
 	 * @param string $params
126 126
 	 * @return string
127 127
 	 */
128
-	abstract protected function reallyMakeRequest( string $params ) : string;
128
+	abstract protected function reallyMakeRequest ( string $params ) : string;
129 129
 
130 130
 	/**
131 131
 	 * After a request, set cookies for the next ones
132 132
 	 *
133 133
 	 * @param array $cookies
134 134
 	 */
135
-	protected function setCookies( array $cookies ) {
135
+	protected function setCookies ( array $cookies ) {
136 136
 		foreach ( $cookies as $cookie ) {
137 137
 			$bits = explode( ';', $cookie );
138
-			list( $name, $value ) = explode( '=', $bits[0] );
138
+			list( $name, $value ) = explode( '=', $bits[ 0 ] );
139 139
 			self::$cookiesToSet[ $name ] = $value;
140 140
 		}
141 141
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param \stdClass $res
147 147
 	 * @throws APIRequestException
148 148
 	 */
149
-	protected function handleErrorAndWarnings( $res ) {
149
+	protected function handleErrorAndWarnings ( $res ) {
150 150
 		if ( isset( $res->error ) ) {
151 151
 			switch ( $res->error->code ) {
152 152
 				case 'missingtitle':
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @param \stdClass[] $sets
173 173
 	 * @return \stdClass
174 174
 	 */
175
-	private function mergeSets( array $sets ) : \stdClass {
175
+	private function mergeSets ( array $sets ) : \stdClass {
176 176
 		// Use the first set as template
177 177
 		$ret = array_shift( $sets );
178 178
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param array|\stdClass $second
190 190
 	 * @return array|\stdClass array
191 191
 	 */
192
-	private function recursiveMerge( $first, $second ) {
192
+	private function recursiveMerge ( $first, $second ) {
193 193
 		$ret = $first;
194 194
 		if ( is_array( $second ) ) {
195 195
 			$ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second;
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return array
209 209
 	 */
210
-	protected function getHeaders() :array {
210
+	protected function getHeaders () :array {
211 211
 		$ret = self::HEADERS;
212 212
 		if ( self::$cookiesToSet ) {
213
-			$cookies = [];
213
+			$cookies = [ ];
214 214
 			foreach ( self::$cookiesToSet as $cname => $cval ) {
215
-				$cookies[] = trim( "$cname=$cval" );
215
+				$cookies[ ] = trim( "$cname=$cval" );
216 216
 			}
217
-			$ret[] = 'Cookie: ' . implode( '; ', $cookies );
217
+			$ret[ ] = 'Cookie: ' . implode( '; ', $cookies );
218 218
 		}
219 219
 		return $ret;
220 220
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param array $headers
226 226
 	 * @return string
227 227
 	 */
228
-	protected function buildHeadersString( array $headers ) : string {
228
+	protected function buildHeadersString ( array $headers ) : string {
229 229
 		$ret = '';
230 230
 		foreach ( $headers as $header ) {
231 231
 			$ret .= "$header\r\n";
Please login to merge, or discard this patch.
includes/Request/NativeRequest.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
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * @inheritDoc
11 11
 	 */
12
-	protected function reallyMakeRequest( string $params ) : string {
12
+	protected function reallyMakeRequest ( string $params ) : string {
13 13
 		$context = [
14 14
 			'http' => [
15 15
 				'method' => $this->method,
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		];
19 19
 		$url = $this->url;
20 20
 		if ( $this->method === 'POST' ) {
21
-			$context['http']['content'] = $params;
21
+			$context[ 'http' ][ 'content' ] = $params;
22 22
 		} else {
23 23
 			$url = "$url?$params";
24 24
 		}
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 
28 28
 		foreach ( $http_response_header as $header ) {
29 29
 			$bits = explode( ':', $header, 2 );
30
-			if ( trim( $bits[0] ) === 'Set-Cookie' ) {
31
-				$this->newCookies[] = $bits[1];
30
+			if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
31
+				$this->newCookies[ ] = $bits[ 1 ];
32 32
 			}
33 33
 		}
34 34
 
Please login to merge, or discard this patch.
includes/Bot.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;
4 4
 
@@ -11,14 +11,14 @@  discard block
 block discarded – undo
11 11
 
12 12
 	const VERSION = 1.0;
13 13
 
14
-	public function __construct() {
14
+	public function __construct () {
15 15
 		$this->logger = new Logger;
16 16
 	}
17 17
 
18 18
 	/**
19 19
 	 * Entry point for the whole process
20 20
 	 */
21
-	public function run() {
21
+	public function run () {
22 22
 		$this->logger->info( 'Starting full process.' );
23 23
 		$manager = new TaskManager;
24 24
 		$res = $manager->run( TaskManager::MODE_COMPLETE );
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param string $task
37 37
 	 */
38
-	public function runTask( string $task ) {
38
+	public function runTask ( string $task ) {
39 39
 		$this->logger->info( "Starting single task $task." );
40 40
 		$manager = new TaskManager;
41 41
 		$res = $manager->run( TaskManager::MODE_TASK, $task );
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @param string $subtask
54 54
 	 */
55
-	public function runSubtask( string $subtask ) {
55
+	public function runSubtask ( string $subtask ) {
56 56
 		$this->logger->info( "Starting single subtask $subtask." );
57 57
 		$manager = new TaskManager;
58 58
 		$res = $manager->run( TaskManager::MODE_SUBTASK, $subtask );
Please login to merge, or discard this patch.
includes/TaskManager.php 1 patch
Spacing   +9 added lines, -9 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
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK
48 48
 	 * @return TaskResult
49 49
 	 */
50
-	public function run( int $mode, string $name = null ) : TaskResult {
50
+	public function run ( int $mode, string $name = null ) : TaskResult {
51 51
 		$this->provider = new TaskDataProvider;
52 52
 
53 53
 		if ( $mode === self::MODE_COMPLETE ) {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return TaskResult
66 66
 	 */
67
-	protected function runAllTasks() : TaskResult {
67
+	protected function runAllTasks () : TaskResult {
68 68
 		if ( self::getLastFullRunDate() === date( 'd/m/Y' ) ) {
69 69
 			// Really avoid executing twice the same day
70 70
 			return new TaskResult( TaskResult::STATUS_ERROR, [ 'A full run was already executed today.' ] );
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @param string $name
96 96
 	 * @return TaskResult
97 97
 	 */
98
-	protected function runTask( string $name ) : TaskResult {
98
+	protected function runTask ( string $name ) : TaskResult {
99 99
 		if ( !isset( self::TASKS_MAP[ $name ] ) ) {
100 100
 			throw new \InvalidArgumentException( "'$name' is not a valid task." );
101 101
 		}
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	 * @param string $name
111 111
 	 * @return TaskResult
112 112
 	 */
113
-	protected function runSubtask( string $name ) : TaskResult {
113
+	protected function runSubtask ( string $name ) : TaskResult {
114 114
 		if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) {
115 115
 			throw new \InvalidArgumentException( "'$name' is not a valid subtask." );
116 116
 		}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return string|null d/m/Y or null if no last run registered
125 125
 	 * @fixme Is this even necessary?
126 126
 	 */
127
-	public static function getLastFullRunDate() : ?string {
127
+	public static function getLastFullRunDate () : ?string {
128 128
 		if ( file_exists( self::LOG_FILE ) ) {
129 129
 			return file_get_contents( self::LOG_FILE ) ?: null;
130 130
 		} else {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 * @param string $class
139 139
 	 * @return Task
140 140
 	 */
141
-	private function getTaskInstance( string $class ) : Task {
141
+	private function getTaskInstance ( string $class ) : Task {
142 142
 		return new $class( $this->provider );
143 143
 	}
144 144
 
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 	 * @param string $class
149 149
 	 * @return Subtask
150 150
 	 */
151
-	private function getSubtaskInstance( string $class ) : Subtask {
151
+	private function getSubtaskInstance ( string $class ) : Subtask {
152 152
 		return new $class( $this->provider );
153 153
 	}
154 154
 
155
-	public static function setLastFullRunDate() {
155
+	public static function setLastFullRunDate () {
156 156
 		file_put_contents( self::LOG_FILE, date( 'd/m/Y' ) );
157 157
 	}
158 158
 }
Please login to merge, or discard this patch.
run.php 1 patch
Spacing   +4 added lines, -4 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
  * Entry point for the bot, called by CLI
4 4
  */
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 /* URL (for debugging purpose) */
39 39
 $urlParam = getopt( '', [ 'force-url:' ] );
40
-$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php';
40
+$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php';
41 41
 
42 42
 define( 'DEFAULT_URL', $url );
43 43
 
@@ -87,9 +87,9 @@  discard block
 block discarded – undo
87 87
 
88 88
 if ( count( $taskOpts ) === 2 ) {
89 89
 	throw new InvalidArgumentException( 'Cannot specify both task and subtask.' );
90
-} elseif ( isset( $taskOpts['task'] ) ) {
90
+} elseif ( isset( $taskOpts[ 'task' ] ) ) {
91 91
 	$bot->runTask( $taskOpts[ 'task' ] );
92
-} elseif ( isset( $taskOpts['subtask'] ) ) {
92
+} elseif ( isset( $taskOpts[ 'subtask' ] ) ) {
93 93
 	$bot->runSubtask( $taskOpts[ 'subtask' ] );
94 94
 } else {
95 95
 	$bot->run();
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +18 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;
4 4
 
@@ -15,14 +15,14 @@  discard block
 block discarded – undo
15 15
 	/** @var array[] */
16 16
 	private $allUsers;
17 17
 	/** @var PageRiconferma[] */
18
-	private $createdPages = [];
18
+	private $createdPages = [ ];
19 19
 
20 20
 	/**
21 21
 	 * Get the full content of the JSON users list
22 22
 	 *
23 23
 	 * @return array[]
24 24
 	 */
25
-	public function getUsersList() : array {
25
+	public function getUsersList () : array {
26 26
 		if ( $this->allUsers === null ) {
27 27
 			$this->getLogger()->debug( 'Retrieving users list' );
28 28
 			$this->allUsers = PageBotList::get()->getAdminsList();
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return array[]
38 38
 	 */
39
-	public function getUsersToProcess() : array {
39
+	public function getUsersToProcess () : array {
40 40
 		if ( $this->processUsers === null ) {
41
-			$this->processUsers = [];
41
+			$this->processUsers = [ ];
42 42
 			foreach ( $this->getUsersList() as $user => $groups ) {
43 43
 				$timestamp = $this->getValidTimestamp( $groups );
44 44
 
@@ -60,13 +60,11 @@  discard block
 block discarded – undo
60 60
 	 * @param array $groups
61 61
 	 * @return int
62 62
 	 */
63
-	private function getValidTimestamp( array $groups ) : int {
63
+	private function getValidTimestamp ( array $groups ) : int {
64 64
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
65
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
66
-			0;
65
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
67 66
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
68
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
69
-			0;
67
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
70 68
 
71 69
 		$timestamp = max( $bureaucrat, $checkuser );
72 70
 		if ( $timestamp === 0 ) {
@@ -80,7 +78,7 @@  discard block
 block discarded – undo
80 78
 	 *
81 79
 	 * @return PageRiconferma[]
82 80
 	 */
83
-	public function getOpenPages() : array {
81
+	public function getOpenPages () : array {
84 82
 		static $list = null;
85 83
 		if ( $list === null ) {
86 84
 			$baseTitle = $this->getConfig()->get( 'ric-main-page' );
@@ -94,10 +92,10 @@  discard block
 block discarded – undo
94 92
 
95 93
 			$res = RequestBase::newFromParams( $params )->execute();
96 94
 			$pages = $res->query->pages;
97
-			$list = [];
95
+			$list = [ ];
98 96
 			foreach ( reset( $pages )->templates as $page ) {
99 97
 				if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
100
-					$list[] = new PageRiconferma( $page->title );
98
+					$list[ ] = new PageRiconferma( $page->title );
101 99
 				}
102 100
 			}
103 101
 		}
@@ -110,14 +108,14 @@  discard block
 block discarded – undo
110 108
 	 *
111 109
 	 * @return PageRiconferma[]
112 110
 	 */
113
-	public function getPagesToClose() : array {
111
+	public function getPagesToClose () : array {
114 112
 		static $list = null;
115 113
 		if ( $list === null ) {
116 114
 			$allPages = $this->getOpenPages();
117
-			$list = [];
115
+			$list = [ ];
118 116
 			foreach ( $allPages as $page ) {
119 117
 				if ( time() > $page->getEndTimestamp() ) {
120
-					$list[] = $page;
118
+					$list[ ] = $page;
121 119
 				}
122 120
 			}
123 121
 		}
@@ -129,21 +127,21 @@  discard block
 block discarded – undo
129 127
 	 *
130 128
 	 * @param string $name
131 129
 	 */
132
-	public function removeUser( string $name ) {
130
+	public function removeUser ( string $name ) {
133 131
 		unset( $this->processUsers[ $name ] );
134 132
 	}
135 133
 
136 134
 	/**
137 135
 	 * @return PageRiconferma[]
138 136
 	 */
139
-	public function getCreatedPages() : array {
137
+	public function getCreatedPages () : array {
140 138
 		return $this->createdPages;
141 139
 	}
142 140
 
143 141
 	/**
144 142
 	 * @param PageRiconferma $page
145 143
 	 */
146
-	public function addCreatedPages( PageRiconferma $page ) {
147
-		$this->createdPages[] = $page;
144
+	public function addCreatedPages ( PageRiconferma $page ) {
145
+		$this->createdPages[ ] = $page;
148 146
 	}
149 147
 }
Please login to merge, or discard this patch.
includes/Page/PageBotList.php 1 patch
Spacing   +4 added lines, -4 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\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;
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 *
34 34
 	 * @return array[]
35 35
 	 */
36
-	public function getAdminsList() : array {
36
+	public function getAdminsList () : array {
37 37
 		return json_decode( $this->getContent(), true );
38 38
 	}
39 39
 }
Please login to merge, or discard this patch.
includes/Page/Page.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\Page;
4 4
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param string $title
21 21
 	 * @param string $domain The site where the page lives, if different from default
22 22
 	 */
23
-	public function __construct( string $title, string $domain = DEFAULT_URL ) {
23
+	public function __construct ( string $title, string $domain = DEFAULT_URL ) {
24 24
 		$this->title = $title;
25 25
 		$this->controller = new WikiController( $domain );
26 26
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @return string
30 30
 	 */
31
-	public function getTitle() : string {
31
+	public function getTitle () : string {
32 32
 		return $this->title;
33 33
 	}
34 34
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @param int|null $section A section number to retrieve the content of that section
39 39
 	 * @return string
40 40
 	 */
41
-	public function getContent( int $section = null ) : string {
41
+	public function getContent ( int $section = null ) : string {
42 42
 		if ( $this->content === null ) {
43 43
 			$this->content = $this->controller->getPageContent( $this->title, $section );
44 44
 		}
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param array $params
52 52
 	 */
53
-	public function edit( array $params ) {
53
+	public function edit ( array $params ) {
54 54
 		$params = [
55 55
 			'title' => $this->getTitle()
56 56
 		] + $params;
57 57
 
58 58
 		$this->controller->editPage( $params );
59
-		if ( isset( $params['text'] ) ) {
60
-			$this->content = $params['text'];
61
-		} elseif ( isset( $params['appendtext'] ) ) {
62
-			$this->content .= $params['appendtext'];
59
+		if ( isset( $params[ 'text' ] ) ) {
60
+			$this->content = $params[ 'text' ];
61
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
62
+			$this->content .= $params[ 'appendtext' ];
63 63
 		} else {
64 64
 			// Clear the cache anyway
65 65
 			( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) );
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $regex
74 74
 	 * @return bool
75 75
 	 */
76
-	public function matches( string $regex ) : bool {
76
+	public function matches ( string $regex ) : bool {
77 77
 		return preg_match( $regex, $this->getContent() ) !== false;
78 78
 	}
79 79
 
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
 	 * @return string[]
86 86
 	 * @throws \Exception
87 87
 	 */
88
-	public function getMatch( string $regex ) : array {
89
-		$ret = [];
88
+	public function getMatch ( string $regex ) : array {
89
+		$ret = [ ];
90 90
 		if ( preg_match( $regex, $this->getContent(), $ret ) === false ) {
91 91
 			throw new \Exception;
92 92
 		}
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return string
100 100
 	 */
101
-	public function __toString() {
101
+	public function __toString () {
102 102
 		return $this->getTitle();
103 103
 	}
104 104
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/FailedUpdates.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	/**
14 14
 	 * @inheritDoc
15 15
 	 */
16
-	public function runInternal() : int {
16
+	public function runInternal () : int {
17 17
 		$failed = $this->getFailures();
18 18
 		if ( $failed ) {
19 19
 			$this->updateBurList( $failed );
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return PageRiconferma[]
32 32
 	 */
33
-	private function getFailures() : array {
34
-		$ret = [];
33
+	private function getFailures () : array {
34
+		$ret = [ ];
35 35
 		$allPages = $this->getDataProvider()->getPagesToClose();
36 36
 		foreach ( $allPages as $page ) {
37 37
 			if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) {
38
-				$ret[] = $page;
38
+				$ret[ ] = $page;
39 39
 			}
40 40
 		}
41 41
 		return $ret;
@@ -44,17 +44,17 @@  discard block
 block discarded – undo
44 44
 	/**
45 45
 	 * @param PageRiconferma[] $pages
46 46
 	 */
47
-	protected function updateBurList( array $pages ) {
47
+	protected function updateBurList ( array $pages ) {
48 48
 		$this->getLogger()->info( 'Checking if bur list needs updating.' );
49 49
 		$admins = $this->getDataProvider()->getUsersList();
50 50
 
51
-		$remove = [];
51
+		$remove = [ ];
52 52
 		foreach ( $pages as $page ) {
53 53
 			$user = $page->getUser();
54 54
 			if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) &&
55 55
 				$page->getOutcome() & PageRiconferma::OUTCOME_FAIL
56 56
 			) {
57
-				$remove[] = $user;
57
+				$remove[ ] = $user;
58 58
 			}
59 59
 		}
60 60
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 *
85 85
 	 * @param PageRiconferma[] $pages
86 86
 	 */
87
-	protected function requestRemoval( array $pages ) {
87
+	protected function requestRemoval ( array $pages ) {
88 88
 		$this->getLogger()->info(
89 89
 			'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) )
90 90
 		);
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @param PageRiconferma[] $pages
128 128
 	 */
129
-	protected function updateAnnunci( array $pages ) {
129
+	protected function updateAnnunci ( array $pages ) {
130 130
 		$this->getLogger()->info( 'Updating annunci' );
131 131
 
132
-		$names = [];
132
+		$names = [ ];
133 133
 		$text = '';
134 134
 		foreach ( $pages as $page ) {
135 135
 			$user = $page->getUser();
136
-			$names[] = $user;
136
+			$names[ ] = $user;
137 137
 			$text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " .
138 138
 				"non è stato riconfermato [[WP:A|amministratore]].}}\n";
139 139
 		}
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 	 *
168 168
 	 * @param PageRiconferma[] $pages
169 169
 	 */
170
-	protected function updateUltimeNotizie( array $pages ) {
170
+	protected function updateUltimeNotizie ( array $pages ) {
171 171
 		$this->getLogger()->info( 'Updating ultime notizie' );
172 172
 		$notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-title' ) );
173 173
 
174
-		$names = [];
174
+		$names = [ ];
175 175
 		$text = '';
176 176
 		foreach ( $pages as $page ) {
177 177
 			$user = $page->getUser();
178 178
 			$title = $page->getTitle();
179
-			$names[] = $user;
179
+			$names[ ] = $user;
180 180
 			$text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " .
181 181
 				'[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.';
182 182
 		}
Please login to merge, or discard this patch.