Passed
Push — master ( adc4b8...42aaff )
by Daimona
01:39
created
includes/Task/Subtask/UpdatesAround.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\Task\Subtask;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	public function run() : TaskResult {
18
+	public function run () : TaskResult {
19 19
 		$this->getLogger()->info( 'Starting task UpdatesAround' );
20 20
 
21 21
 		$pages = $this->getDataProvider()->getCreatedPages();
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 *
40 40
 	 * @param PageRiconferma[] $pages
41 41
 	 */
42
-	protected function addToMainPage( array $pages ) {
42
+	protected function addToMainPage ( array $pages ) {
43 43
 		$this->getLogger()->info(
44 44
 			'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) )
45 45
 		);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param PageRiconferma[] $pages
68 68
 	 */
69
-	protected function addVote( array $pages ) {
69
+	protected function addVote ( array $pages ) {
70 70
 		$this->getLogger()->info(
71 71
 			'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) )
72 72
 		);
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 			$newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 );
88 88
 		} else {
89 89
 			// Start section
90
-			$matches = [];
90
+			$matches = [ ];
91 91
 			if ( preg_match( $introReg, $content, $matches ) === false ) {
92 92
 				throw new TaskException( 'Intro not found in vote page' );
93 93
 			}
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( 'ric-vote-page-summary' )
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
 	 *
114 114
 	 * @param int $amount
115 115
 	 */
116
-	protected function addNews( int $amount ) {
116
+	protected function addNews ( int $amount ) {
117 117
 		$this->getLogger()->info( "Increasing the news counter by $amount" );
118 118
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) );
119 119
 
120 120
 		$content = $newsPage->getContent();
121 121
 		$reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!';
122 122
 
123
-		$matches = [];
123
+		$matches = [ ];
124 124
 		if ( preg_match( $reg, $content, $matches ) === false ) {
125 125
 			throw new TaskException( 'Param not found in news page' );
126 126
 		}
127 127
 
128
-		$newNum = (int)$matches[2] + $amount;
128
+		$newNum = (int)$matches[ 2 ] + $amount;
129 129
 		$newContent = preg_replace( $reg, '${1}' . $newNum, $content );
130 130
 
131 131
 		$summary = $this->msg( 'ric-news-page-summary' )
Please login to merge, or discard this patch.
includes/Task/Subtask/Subtask.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 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
 
Please login to merge, or discard this patch.
includes/Task/Subtask/CreatePages.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare( strict_types=1 );
1
+<?php declare(strict_types=1);
2 2
 
3 3
 namespace BotRiconferme\Task\Subtask;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function run() : TaskResult {
17
+	public function run () : TaskResult {
18 18
 		$this->getLogger()->info( 'Starting task CreatePages' );
19 19
 		$users = $this->getDataProvider()->getUsersToProcess();
20 20
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param string $user
37 37
 	 * @param array $groups
38 38
 	 */
39
-	protected function processUser( string $user, array $groups ) {
39
+	protected function processUser ( string $user, array $groups ) {
40 40
 		try {
41 41
 			$num = $this->getLastPageNum( $user ) + 1;
42 42
 		} catch ( TaskException $e ) {
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 	 * @return int
69 69
 	 * @throws TaskException
70 70
 	 */
71
-	protected function getLastPageNum( string $user ) : int {
71
+	protected function getLastPageNum ( string $user ) : int {
72 72
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
73
-		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1];
73
+		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ];
74 74
 		$params = [
75 75
 			'action' => 'query',
76 76
 			'list' => 'allpages',
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
 	 * @param string $user
106 106
 	 * @param array $groups
107 107
 	 */
108
-	protected function createPage( string $title, string $user, array $groups ) {
108
+	protected function createPage ( string $title, string $user, array $groups ) {
109 109
 		$this->getLogger()->info( "Creating page $title" );
110 110
 		$text = $this->getConfig()->get( 'ric-page-text' );
111 111
 		$textParams = [
112 112
 			'$user' => $user,
113
-			'$date' => $groups['sysop'],
114
-			'$burocrate' => $groups['bureaucrat'] ?? '',
115
-			'$checkuser' => $groups['checkuser'] ?? ''
113
+			'$date' => $groups[ 'sysop' ],
114
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
115
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
116 116
 		];
117 117
 		$text = strtr( $text, $textParams );
118 118
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @param string $title
132 132
 	 * @param string $newText
133 133
 	 */
134
-	protected function createBasePage( string $title, string $newText ) {
134
+	protected function createBasePage ( string $title, string $newText ) {
135 135
 		$this->getLogger()->info( "Creating base page $title" );
136 136
 
137 137
 		$params = [
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param string $title
149 149
 	 * @param string $newText
150 150
 	 */
151
-	protected function updateBasePage( string $title, string $newText ) {
151
+	protected function updateBasePage ( string $title, string $newText ) {
152 152
 		$this->getLogger()->info( "Updating base page $title" );
153 153
 
154 154
 		$params = [
Please login to merge, or discard this patch.
includes/Task/UpdateList.php 1 patch
Spacing   +19 added lines, -19 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,15 +18,15 @@  discard block
 block discarded – undo
18 18
 	/**
19 19
 	 * @inheritDoc
20 20
 	 */
21
-	protected function getSubtasksMap(): array {
21
+	protected function getSubtasksMap (): array {
22 22
 		// Everything is done here.
23
-		return [];
23
+		return [ ];
24 24
 	}
25 25
 
26 26
 	/**
27 27
 	 * @inheritDoc
28 28
 	 */
29
-	public function run() : TaskResult {
29
+	public function run () : TaskResult {
30 30
 		$this->getLogger()->info( 'Starting task UpdateList' );
31 31
 		$this->actualList = $this->getActualAdmins();
32 32
 		$this->botList = $this->getDataProvider()->getUsersList();
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	/**
62 62
 	 * @return array
63 63
 	 */
64
-	protected function getActualAdmins() : array {
64
+	protected function getActualAdmins () : array {
65 65
 		$this->getLogger()->debug( 'Retrieving admins - API' );
66 66
 		$params = [
67 67
 			'action' => 'query',
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 * @param \stdClass $data
80 80
 	 * @return array
81 81
 	 */
82
-	protected function extractAdmins( \stdClass $data ) : array {
83
-		$ret = [];
82
+	protected function extractAdmins ( \stdClass $data ) : array {
83
+		$ret = [ ];
84 84
 		$blacklist = $this->getConfig()->get( 'exclude-admins' );
85 85
 		foreach ( $data->query->allusers as $u ) {
86 86
 			if ( in_array( $u->name, $blacklist ) ) {
@@ -97,22 +97,22 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return array[]
99 99
 	 */
100
-	protected function getMissingGroups() : array {
101
-		$missing = [];
100
+	protected function getMissingGroups () : array {
101
+		$missing = [ ];
102 102
 		foreach ( $this->actualList as $adm => $groups ) {
103
-			$groupsList = [];
103
+			$groupsList = [ ];
104 104
 			if ( !isset( $this->botList[ $adm ] ) ) {
105 105
 				$groupsList = $groups;
106
-			} elseif ( count( $groups ) > count( $this->botList[$adm] ) ) {
106
+			} elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) {
107 107
 				// Only some groups are missing
108
-				$groupsList = array_diff_key( $groups, $this->botList[$adm] );
108
+				$groupsList = array_diff_key( $groups, $this->botList[ $adm ] );
109 109
 			}
110 110
 
111 111
 			foreach ( $groupsList as $group ) {
112 112
 				try {
113 113
 					$missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group );
114 114
 				} catch ( TaskException $e ) {
115
-					$this->errors[] = $e->getMessage();
115
+					$this->errors[ ] = $e->getMessage();
116 116
 				}
117 117
 			}
118 118
 		}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @return string
128 128
 	 * @throws TaskException
129 129
 	 */
130
-	protected function getFlagDate( string $admin, string $group ) : string {
130
+	protected function getFlagDate ( string $admin, string $group ) : string {
131 131
 		$this->getLogger()->info( "Retrieving $group flag date for $admin" );
132 132
 
133 133
 		$url = DEFAULT_URL;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @param string $group
163 163
 	 * @return string|null
164 164
 	 */
165
-	private function extractTimestamp( \stdClass $data, string $group ) : ?string {
165
+	private function extractTimestamp ( \stdClass $data, string $group ) : ?string {
166 166
 		$ts = null;
167 167
 		foreach ( $data->query->logevents as $entry ) {
168 168
 			if ( !isset( $entry->params ) ) {
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 *
185 185
 	 * @return array[]
186 186
 	 */
187
-	protected function getExtraGroups() : array {
188
-		$extra = [];
187
+	protected function getExtraGroups () : array {
188
+		$extra = [ ];
189 189
 		foreach ( $this->botList as $name => $groups ) {
190 190
 			if ( !isset( $this->actualList[ $name ] ) ) {
191 191
 				$extra[ $name ] = $groups;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @param array $newContent
203 203
 	 */
204
-	protected function doUpdateList( array $newContent ) {
204
+	protected function doUpdateList ( array $newContent ) {
205 205
 		$this->getLogger()->info( 'Updating admin list' );
206 206
 
207 207
 		$params = [
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @param array[] $extra
221 221
 	 * @return array[]
222 222
 	 */
223
-	protected function getNewContent( array $missing, array $extra ) : array {
223
+	protected function getNewContent ( array $missing, array $extra ) : array {
224 224
 		$newContent = $this->botList;
225 225
 		foreach ( $newContent as $user => $groups ) {
226 226
 			if ( isset( $missing[ $user ] ) ) {
Please login to merge, or discard this patch.
includes/Task/CloseOld.php 1 patch
Spacing   +3 added lines, -3 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
 		$orderedList = [
17 17
 			'close-pages'
18 18
 		];
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @inheritDoc
30 30
 	 */
31
-	protected function getSubtasksMap(): array {
31
+	protected function getSubtasksMap (): array {
32 32
 		return [
33 33
 			'close-pages' => ClosePages::class
34 34
 		];
Please login to merge, or discard this patch.
includes/Task/Task.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\Task;
4 4
 
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 	 *
15 15
 	 * @return string[]
16 16
 	 */
17
-	abstract protected function getSubtasksMap() : array;
17
+	abstract protected function getSubtasksMap () : array;
18 18
 
19 19
 	/**
20 20
 	 * @param string $subtask Defined in self::SUBTASKS_MAP
21 21
 	 * @return TaskResult
22 22
 	 */
23
-	protected function runSubtask( string $subtask ) : TaskResult {
23
+	protected function runSubtask ( string $subtask ) : TaskResult {
24 24
 		$map = $this->getSubtasksMap();
25 25
 		if ( !isset( $map[ $subtask ] ) ) {
26 26
 			throw new \InvalidArgumentException( "'$subtask' is not a valid task." );
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param string $class
37 37
 	 * @return Subtask
38 38
 	 */
39
-	private function getSubtaskInstance( string $class ) : Subtask {
39
+	private function getSubtaskInstance ( string $class ) : Subtask {
40 40
 		return new $class( $this->getDataProvider() );
41 41
 	}
42 42
 }
Please login to merge, or discard this patch.
includes/Task/StartNew.php 1 patch
Spacing   +3 added lines, -3 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
 	/**
15 15
 	 * @inheritDoc
16 16
 	 */
17
-	public function run() : TaskResult {
17
+	public function run () : TaskResult {
18 18
 		$orderedList = [
19 19
 			'update-list',
20 20
 			'create-pages',
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @inheritDoc
35 35
 	 */
36
-	protected function getSubtasksMap() : array {
36
+	protected function getSubtasksMap () : array {
37 37
 		return [
38 38
 			'create-pages' => CreatePages::class,
39 39
 			'update-list' => UpdateList::class,
Please login to merge, or discard this patch.
includes/Task/TaskBase.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
 	protected $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/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.