Passed
Push — master ( 3e94dc...02246d )
by Daimona
02:15
created
includes/Task/UpdateList.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task;
4 4
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	/**
19 19
 	 * @inheritDoc
20 20
 	 */
21
-	public function run() : TaskResult {
21
+	public function run () : TaskResult {
22 22
 		$this->getLogger()->info( 'Starting task UpdateList' );
23 23
 		$this->actualList = $this->getActualAdmins();
24 24
 		$this->botList = $this->getList();
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * @return array
48 48
 	 */
49
-	protected function getActualAdmins() : array {
49
+	protected function getActualAdmins () : array {
50 50
 		$this->getLogger()->debug( 'Retrieving admins - API' );
51 51
 		$params = [
52 52
 			'action' => 'query',
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 * @param \stdClass $data
65 65
 	 * @return array
66 66
 	 */
67
-	protected function extractAdmins( \stdClass $data ) : array {
68
-		$ret = [];
67
+	protected function extractAdmins ( \stdClass $data ) : array {
68
+		$ret = [ ];
69 69
 		$blacklist = $this->getConfig()->get( 'exclude-admins' );
70 70
 		foreach ( $data->query->allusers as $u ) {
71 71
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	/**
81 81
 	 * @return array
82 82
 	 */
83
-	protected function getList() : array {
83
+	protected function getList () : array {
84 84
 		$this->getLogger()->debug( 'Retrieving admins - JSON list' );
85 85
 		$content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) );
86 86
 
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
 	 *
93 93
 	 * @return array[]
94 94
 	 */
95
-	protected function getMissingGroups() : array {
96
-		$missing = [];
95
+	protected function getMissingGroups () : array {
96
+		$missing = [ ];
97 97
 		foreach ( $this->actualList as $adm => $groups ) {
98 98
 			if ( !isset( $this->botList[ $adm ] ) ) {
99 99
 				$groupsList = $groups;
100
-			} elseif ( count( $groups ) > count( $this->botList[$adm] ) ) {
100
+			} elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) {
101 101
 				// Only some groups are missing
102
-				$groupsList = array_diff_key( $groups, $this->botList[$adm] );
102
+				$groupsList = array_diff_key( $groups, $this->botList[ $adm ] );
103 103
 			} else {
104 104
 				continue;
105 105
 			}
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 				try {
109 109
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
110 110
 				} catch ( TaskException $e ) {
111
-					$this->errors[] = $e->getMessage();
111
+					$this->errors[ ] = $e->getMessage();
112 112
 				}
113 113
 			}
114 114
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @return string
124 124
 	 * @throws TaskException
125 125
 	 */
126
-	protected function getFlagDate( string $admin, string $group ) : string {
126
+	protected function getFlagDate ( string $admin, string $group ) : string {
127 127
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
128 128
 
129 129
 		if ( $group === 'checkuser' ) {
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	 * @param string $group
165 165
 	 * @return string|null
166 166
 	 */
167
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
167
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
168 168
 		$ts = null;
169 169
 		foreach ( $data->query->logevents as $entry ) {
170 170
 			if ( !isset( $entry->params ) ) {
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 *
187 187
 	 * @return array[]
188 188
 	 */
189
-	protected function getExtraGroups() : array {
190
-		$extra = [];
189
+	protected function getExtraGroups () : array {
190
+		$extra = [ ];
191 191
 		foreach ( $this->botList as $name => $groups ) {
192 192
 			if ( !isset( $this->actualList[ $name ] ) ) {
193 193
 				$extra[ $name ] = $groups;
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @param array $newContent
205 205
 	 */
206
-	protected function doUpdateList( array $newContent ) {
206
+	protected function doUpdateList ( array $newContent ) {
207 207
 		ksort( $newContent );
208 208
 
209 209
 		if ( $newContent !== $this->botList ) {
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	 * @param array[] $extra
232 232
 	 * @return array[]
233 233
 	 */
234
-	protected function getNewContent( array $missing, array $extra ) : array {
234
+	protected function getNewContent ( array $missing, array $extra ) : array {
235 235
 		$newContent = $this->botList;
236 236
 		foreach ( $newContent as $user => $groups ) {
237 237
 			if ( isset( $missing[ $user ] ) ) {
Please login to merge, or discard this patch.
includes/Task/Task.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\Task;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	const STATUS_OK = 0;
15 15
 	const STATUS_ERROR = 1;
16 16
 	/** @var string[] */
17
-	protected $errors = [];
17
+	protected $errors = [ ];
18 18
 	/** @var TaskDataProvider */
19 19
 	private $dataProvider;
20 20
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	 *
24 24
 	 * @param TaskDataProvider $dataProvider
25 25
 	 */
26
-	final public function __construct( TaskDataProvider $dataProvider ) {
26
+	final public function __construct ( TaskDataProvider $dataProvider ) {
27 27
 		set_exception_handler( [ $this, 'handleException' ] );
28 28
 		set_error_handler( [ $this, 'handleError' ] );
29 29
 		parent::__construct();
30 30
 		$this->dataProvider = $dataProvider;
31 31
 	}
32 32
 
33
-	public function __destruct() {
33
+	public function __destruct () {
34 34
 		restore_error_handler();
35 35
 		restore_exception_handler();
36 36
 	}
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return TaskResult
42 42
 	 */
43
-	abstract public function run() : TaskResult;
43
+	abstract public function run () : TaskResult;
44 44
 
45 45
 	/**
46 46
 	 * Exception handler.
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 	 * @param \Throwable $ex
49 49
 	 * @protected
50 50
 	 */
51
-	public function handleException( \Throwable $ex ) {
51
+	public function handleException ( \Throwable $ex ) {
52 52
 		$this->getLogger()->error(
53 53
 			get_class( $ex ) . ': ' .
54 54
 			$ex->getMessage() . "\nTrace:\n" .
@@ -65,14 +65,14 @@  discard block
 block discarded – undo
65 65
 	 * @param int $errline
66 66
 	 * @protected
67 67
 	 */
68
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
68
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
69 69
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
70 70
 	}
71 71
 
72 72
 	/**
73 73
 	 * @return TaskDataProvider
74 74
 	 */
75
-	protected function getDataProvider() : TaskDataProvider {
75
+	protected function getDataProvider () : TaskDataProvider {
76 76
 		return $this->dataProvider;
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
includes/Task/UpdatesAround.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;
4 4
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	/**
13 13
 	 * @inheritDoc
14 14
 	 */
15
-	public function run() : TaskResult {
15
+	public function run () : TaskResult {
16 16
 		$this->getLogger()->info( 'Starting task UpdatesAround' );
17 17
 
18 18
 		$pages = $this->getDataProvider()->getCreatedPages();
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @param string[] $pages
34 34
 	 */
35
-	protected function addToMainPage( array $pages ) {
35
+	protected function addToMainPage ( array $pages ) {
36 36
 		$this->getLogger()->info(
37 37
 			'Adding the following to main: ' . implode( ', ', $pages )
38 38
 		);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @param string[] $pages
58 58
 	 */
59
-	protected function addVote( array $pages ) {
59
+	protected function addVote ( array $pages ) {
60 60
 		$this->getLogger()->info(
61 61
 			'Adding the following to votes: ' . implode( ', ', $pages )
62 62
 		);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$time = $this->getTimeWithArticle();
70 70
 		$newLines = '';
71 71
 		foreach ( $pages as $page ) {
72
-			$user = explode( '/', $page )[2];
72
+			$user = explode( '/', $page )[ 2 ];
73 73
 			$newLines .= "*[[Utente:$user|]]. La [[$page|procedura]] termina $time;\n";
74 74
 		}
75 75
 
@@ -79,14 +79,14 @@  discard block
 block discarded – undo
79 79
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
80 80
 		} else {
81 81
 			// Start section
82
-			$matches = [];
82
+			$matches = [ ];
83 83
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
84 84
 				throw new TaskException( 'Intro not found in vote page' );
85 85
 			}
86 86
 			$beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m';
87 87
 			// Replace semicolon with full stop
88 88
 			$newLines = substr( $newLines, 0, -2 ) . ".\n";
89
-			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 );
89
+			$newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 );
90 90
 		}
91 91
 
92 92
 		$params = [
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return string
105 105
 	 */
106
-	private function getTimeWithArticle() : string {
106
+	private function getTimeWithArticle () : string {
107 107
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
108 108
 		$endTS = time() + ( 60 * 60 * 24 * 7 );
109 109
 		$endTime = strftime( '%e %B alle %R', $endTS );
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @param int $amount
122 122
 	 */
123
-	protected function addNews( int $amount ) {
123
+	protected function addNews ( int $amount ) {
124 124
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
125 125
 		$newsPage = $this->getConfig()->get( 'ric-news-page' );
126 126
 
127 127
 		$content = $this->getController()->getPageContent( $newsPage );
128 128
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
129 129
 
130
-		$matches = [];
130
+		$matches = [ ];
131 131
 		if ( preg_match( $reg, $content, $matches ) === false ) {
132 132
 			throw new TaskException( 'Param not found in news page' );
133 133
 		}
134 134
 
135
-		$newNum = (int)$matches[2] + $amount;
135
+		$newNum = (int)$matches[ 2 ] + $amount;
136 136
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
137 137
 
138 138
 		$params = [
Please login to merge, or discard this patch.