Passed
Push — master ( a4e902...e5c8bb )
by Daimona
01:38
created
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 runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$users = $this->getDataProvider()->getUsersToProcess();
19 19
 
20 20
 		if ( !$users ) {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param string $user
35 35
 	 * @param array $groups
36 36
 	 */
37
-	protected function processUser( string $user, array $groups ) {
37
+	protected function processUser ( string $user, array $groups ) {
38 38
 		try {
39 39
 			$num = $this->getLastPageNum( $user ) + 1;
40 40
 		} catch ( TaskException $e ) {
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @return int
67 67
 	 * @throws TaskException
68 68
 	 */
69
-	protected function getLastPageNum( string $user ) : int {
69
+	protected function getLastPageNum ( string $user ) : int {
70 70
 		$this->getLogger()->debug( "Retrieving previous pages for $user" );
71
-		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1];
71
+		$unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ];
72 72
 		$params = [
73 73
 			'action' => 'query',
74 74
 			'list' => 'allpages',
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 	 * @param string $user
104 104
 	 * @param array $groups
105 105
 	 */
106
-	protected function createPage( string $title, string $user, array $groups ) {
106
+	protected function createPage ( string $title, string $user, array $groups ) {
107 107
 		$this->getLogger()->info( "Creating page $title" );
108 108
 		$text = $this->getConfig()->get( 'ric-page-text' );
109 109
 		$textParams = [
110 110
 			'$user' => $user,
111
-			'$date' => $groups['sysop'],
112
-			'$burocrate' => $groups['bureaucrat'] ?? '',
113
-			'$checkuser' => $groups['checkuser'] ?? ''
111
+			'$date' => $groups[ 'sysop' ],
112
+			'$burocrate' => $groups[ 'bureaucrat' ] ?? '',
113
+			'$checkuser' => $groups[ 'checkuser' ] ?? ''
114 114
 		];
115 115
 		$text = strtr( $text, $textParams );
116 116
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @param string $title
130 130
 	 * @param string $newText
131 131
 	 */
132
-	protected function createBasePage( string $title, string $newText ) {
132
+	protected function createBasePage ( string $title, string $newText ) {
133 133
 		$this->getLogger()->info( "Creating base page $title" );
134 134
 
135 135
 		$params = [
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param string $title
147 147
 	 * @param string $newText
148 148
 	 */
149
-	protected function updateBasePage( string $title, string $newText ) {
149
+	protected function updateBasePage ( string $title, string $newText ) {
150 150
 		$this->getLogger()->info( "Updating base page $title" );
151 151
 
152 152
 		$params = [
Please login to merge, or discard this patch.
includes/Task/Subtask/UserNotice.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\Subtask;
4 4
 
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @inheritDoc
13 13
 	 */
14
-	public function runInternal() : int {
14
+	public function runInternal () : int {
15 15
 		$pages = $this->getDataProvider()->getCreatedPages();
16 16
 		$users = $this->getDataProvider()->getUsersToProcess();
17 17
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 			return TaskResult::STATUS_NOTHING;
20 20
 		}
21 21
 
22
-		$ricNums = [];
22
+		$ricNums = [ ];
23 23
 		foreach ( $pages as $page ) {
24 24
 			$ricNums[ $page->getUser() ] = $page->getNum();
25 25
 		}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param string $user
38 38
 	 * @param int $ricNum
39 39
 	 */
40
-	protected function addMsg( string $user, int $ricNum ) {
40
+	protected function addMsg ( string $user, int $ricNum ) {
41 41
 		$this->getLogger()->info( "Leaving msg to $user" );
42 42
 		$msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text();
43 43
 
Please login to merge, or discard this patch.
includes/Task/Subtask/ClosePages.php 1 patch
Spacing   +5 added lines, -6 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
 		$pages = $this->getDataProvider()->getPagesToClose();
18 18
 		$protectReason = $this->getConfig()->get( 'close-protect-summary' );
19 19
 		foreach ( $pages as $page ) {
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	/**
31 31
 	 * @param PageRiconferma $page
32 32
 	 */
33
-	protected function addVoteCloseText( PageRiconferma $page ) {
33
+	protected function addVoteCloseText ( PageRiconferma $page ) {
34 34
 		$content = $page->getContent();
35 35
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
36 36
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -45,15 +45,14 @@  discard block
 block discarded – undo
45 45
 	 * @param PageRiconferma $page
46 46
 	 * @see CreatePages::updateBasePage()
47 47
 	 */
48
-	protected function updateBasePage( PageRiconferma $page ) {
48
+	protected function updateBasePage ( PageRiconferma $page ) {
49 49
 		$this->getLogger()->info( "Updating base page for $page" );
50 50
 
51 51
 		$basePage = new Page( $page->getBaseTitle() );
52 52
 		$current = $basePage->getContent();
53 53
 
54 54
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
55
-			'non riconfermato' :
56
-			'riconfermato';
55
+			'non riconfermato' : 'riconfermato';
57 56
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
58 57
 
59 58
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
Please login to merge, or discard this patch.
includes/Task/TaskBase.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;
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
 		$task = static::class;
42 42
 		$this->getLogger()->info( "Starting task $task" );
43 43
 
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return int One of the STATUS_* constants
69 69
 	 */
70
-	abstract protected function runInternal() : int;
70
+	abstract protected function runInternal () : int;
71 71
 
72 72
 	/**
73 73
 	 * Exception handler.
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	 * @param \Throwable $ex
76 76
 	 * @protected
77 77
 	 */
78
-	public function handleException( \Throwable $ex ) {
78
+	public function handleException ( \Throwable $ex ) {
79 79
 		$this->getLogger()->error(
80 80
 			get_class( $ex ) . ': ' .
81 81
 			$ex->getMessage() . "\nTrace:\n" .
@@ -92,14 +92,14 @@  discard block
 block discarded – undo
92 92
 	 * @param int $errline
93 93
 	 * @protected
94 94
 	 */
95
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
95
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
96 96
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
97 97
 	}
98 98
 
99 99
 	/**
100 100
 	 * @return TaskDataProvider
101 101
 	 */
102
-	protected function getDataProvider() : TaskDataProvider {
102
+	protected function getDataProvider () : TaskDataProvider {
103 103
 		return $this->dataProvider;
104 104
 	}
105 105
 }
Please login to merge, or discard this patch.
includes/Task/StartVote.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;
4 4
 
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
15 15
 	/**
16 16
 	 * @inheritDoc
17 17
 	 */
18
-	protected function getSubtasksMap(): array {
18
+	protected function getSubtasksMap (): array {
19 19
 		// Everything is done here.
20
-		return [];
20
+		return [ ];
21 21
 	}
22 22
 
23 23
 	/**
24 24
 	 * @inheritDoc
25 25
 	 */
26
-	public function runInternal() : int {
26
+	public function runInternal () : int {
27 27
 		$pages = $this->getDataProvider()->getOpenPages();
28 28
 
29 29
 		if ( !$pages ) {
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	/**
39 39
 	 * @param PageRiconferma[] $pages
40 40
 	 */
41
-	protected function processPages( array $pages ) {
42
-		$actualPages = [];
41
+	protected function processPages ( array $pages ) {
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
 
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @param PageRiconferma $page
62 62
 	 */
63
-	protected function openVote( PageRiconferma $page ) {
63
+	protected function openVote ( PageRiconferma $page ) {
64 64
 		$this->getLogger()->info( "Starting vote on $page" );
65 65
 
66 66
 		$content = $page->getContent();
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 	 * @see SimpleUpdates::updateVote()
100 100
 	 * @see UpdatesAround::addVote()
101 101
 	 */
102
-	protected function updateVotePage( array $pages ) {
102
+	protected function updateVotePage ( array $pages ) {
103 103
 		$votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) );
104 104
 		$content = $votePage->getContent();
105 105
 
106
-		$titles = [];
106
+		$titles = [ ];
107 107
 		foreach ( $pages as $page ) {
108
-			$titles[] = preg_quote( $page->getTitle() );
108
+			$titles[ ] = preg_quote( $page->getTitle() );
109 109
 		}
110 110
 		$titleReg = implode( '|', $titles );
111 111
 		$search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm";
@@ -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 ) === false ) {
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' )
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @see UpdatesAround::addNews()
158 158
 	 * @see SimpleUpdates::updateNews()
159 159
 	 */
160
-	protected function updateNews( int $amount ) {
160
+	protected function updateNews ( int $amount ) {
161 161
 		$this->getLogger()->info( "Turning $amount pages into votes" );
162 162
 		$newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) );
163 163
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 			throw new TaskException( 'Param "voto" not found in news page' );
173 173
 		}
174 174
 
175
-		$newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: '';
176
-		$newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: '';
175
+		$newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: '';
176
+		$newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: '';
177 177
 
178 178
 		$newContent = preg_replace( $regTac, '${1}' . $newTac, $content );
179 179
 		$newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent );
Please login to merge, or discard this patch.
includes/TaskResult.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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	 * @param int $status One of the Task::STATUS_* constants
22 22
 	 * @param string[] $errors
23 23
 	 */
24
-	public function __construct( int $status, array $errors = [] ) {
24
+	public function __construct ( int $status, array $errors = [ ] ) {
25 25
 		$this->status = $status;
26 26
 		$this->errors = $errors;
27 27
 	}
@@ -29,21 +29,21 @@  discard block
 block discarded – undo
29 29
 	/**
30 30
 	 * @return int
31 31
 	 */
32
-	public function getStatus() : int {
32
+	public function getStatus () : int {
33 33
 		return $this->status;
34 34
 	}
35 35
 
36 36
 	/**
37 37
 	 * @return string[]
38 38
 	 */
39
-	public function getErrors() {
39
+	public function getErrors () {
40 40
 		return $this->errors;
41 41
 	}
42 42
 
43 43
 	/**
44 44
 	 * @param TaskResult $that
45 45
 	 */
46
-	public function merge( TaskResult $that ) {
46
+	public function merge ( TaskResult $that ) {
47 47
 		$this->status |= $that->status;
48 48
 		$this->errors = array_merge( $this->errors, $that->errors );
49 49
 	}
@@ -51,15 +51,15 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * @return string
53 53
 	 */
54
-	public function __toString() {
54
+	public function __toString () {
55 55
 		if ( $this->isOK() ) {
56 56
 			$stat = 'OK';
57 57
 			$errs = "\tNo errors.";
58 58
 		} else {
59 59
 			$stat = 'ERROR';
60
-			$formattedErrs = [];
60
+			$formattedErrs = [ ];
61 61
 			foreach ( $this->errors as $err ) {
62
-				$formattedErrs[] = "\t - $err";
62
+				$formattedErrs[ ] = "\t - $err";
63 63
 			}
64 64
 			$errs = implode( "\n", $formattedErrs );
65 65
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return bool
73 73
 	 */
74
-	public function isOK() : bool {
74
+	public function isOK () : bool {
75 75
 		return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD;
76 76
 	}
77 77
 }
Please login to merge, or discard this patch.