Passed
Push — master ( 1801c5...ff3dfd )
by Daimona
01:39
created
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.
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 runInternal() : int {
17
+	public function runInternal () : int {
18 18
 		$orderedList = [
19 19
 			'create-pages',
20 20
 			'updates-around',
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	/**
33 33
 	 * @inheritDoc
34 34
 	 */
35
-	protected function getSubtasksMap() : array {
35
+	protected function getSubtasksMap () : array {
36 36
 		return [
37 37
 			'create-pages' => CreatePages::class,
38 38
 			'updates-around' => UpdatesAround::class,
Please login to merge, or discard this patch.
includes/Page/PageRiconferma.php 1 patch
Spacing   +18 added lines, -18 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/**
22 22
 	 * @param string $title
23 23
 	 */
24
-	public function __construct( string $title ) {
24
+	public function __construct ( string $title ) {
25 25
 		parent::__construct( $title );
26 26
 		$this->supportSection = $this->isVote() ? 3 : 0;
27 27
 		$this->opposeSection = $this->isVote() ? 4 : 3;
@@ -32,8 +32,8 @@  discard block
 block discarded – undo
32 32
 	 *
33 33
 	 * @return string
34 34
 	 */
35
-	public function getUser() : string {
36
-		return explode( '/', $this->title )[2];
35
+	public function getUser () : string {
36
+		return explode( '/', $this->title )[ 2 ];
37 37
 	}
38 38
 
39 39
 	/**
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return int
43 43
 	 */
44
-	public function getNum() : int {
44
+	public function getNum () : int {
45 45
 		$bits = explode( '/', $this->getTitle() );
46 46
 		return intval( end( $bits ) );
47 47
 	}
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 *
52 52
 	 * @return string
53 53
 	 */
54
-	public function getUserNum() : string {
55
-		return explode( '/', $this->getTitle(), 3 )[2];
54
+	public function getUserNum () : string {
55
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
56 56
 	}
57 57
 
58 58
 	/**
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 	 *
61 61
 	 * @return string
62 62
 	 */
63
-	public function getBaseTitle() : string {
63
+	public function getBaseTitle () : string {
64 64
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
65 65
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
66 66
 	}
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @return int
72 72
 	 */
73
-	public function getOpposingCount() : int {
73
+	public function getOpposingCount () : int {
74 74
 		return $this->getCountForSection( $this->opposeSection );
75 75
 	}
76 76
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @return int
81 81
 	 * @throws \BadMethodCallException
82 82
 	 */
83
-	public function getSupportCount() : int {
83
+	public function getSupportCount () : int {
84 84
 		if ( !$this->isVote() ) {
85 85
 			throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' );
86 86
 		}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param int $secNum
94 94
 	 * @return int
95 95
 	 */
96
-	protected function getCountForSection( int $secNum ) : int {
96
+	protected function getCountForSection ( int $secNum ) : int {
97 97
 		$content = $this->controller->getPageContent( $this->title, $secNum );
98 98
 		// Let's hope that this is good enough...
99 99
 		return substr_count( $content, "\n\# *(?![#*])" );
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return int
106 106
 	 */
107
-	protected function getQuorum() : int {
107
+	protected function getQuorum () : int {
108 108
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
109
-		return intval( $this->getMatch( $reg )[1] );
109
+		return intval( $this->getMatch( $reg )[ 1 ] );
110 110
 	}
111 111
 
112 112
 	/**
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 *
115 115
 	 * @return bool
116 116
 	 */
117
-	public function hasOpposition() : bool {
117
+	public function hasOpposition () : bool {
118 118
 		return $this->getOpposingCount() >= 15;
119 119
 	}
120 120
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return int One of the OUTCOME_* constants
125 125
 	 * @throws \BadMethodCallException
126 126
 	 */
127
-	public function getOutcome() : int {
127
+	public function getOutcome () : int {
128 128
 		if ( !$this->isVote() ) {
129 129
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
130 130
 		}
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @throws \BadMethodCallException
145 145
 	 * @throws \LogicException
146 146
 	 */
147
-	public function getOutcomeText() : string {
147
+	public function getOutcomeText () : string {
148 148
 		if ( !$this->isVote() ) {
149 149
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
150 150
 		}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @return bool
180 180
 	 */
181
-	public function isVote() : bool {
181
+	public function isVote () : bool {
182 182
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
183 183
 		return !$this->matches( $sectionReg );
184 184
 	}
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @return int
190 190
 	 */
191
-	public function getEndTimestamp() : int {
191
+	public function getEndTimestamp () : int {
192 192
 		if ( $this->isVote() ) {
193 193
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
194 194
 			list( , $day, $hours ) = $this->getMatch( $reg );
Please login to merge, or discard this patch.
includes/Exception/MissingSectionException.php 1 patch
Spacing   +2 added lines, -2 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\Exception;
4 4
 
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	 * @param string $title
11 11
 	 * @param int|string $section Number or title
12 12
 	 */
13
-	public function __construct( string $title = '[unavailable]', $section = '[unavailable]' ) {
13
+	public function __construct ( string $title = '[unavailable]', $section = '[unavailable]' ) {
14 14
 		parent::__construct( "The section $section in the page $title doesn't exist." );
15 15
 	}
16 16
 }
Please login to merge, or discard this patch.
includes/Task/Subtask/Subtask.php 1 patch
Spacing   +2 added lines, -2 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
-	final protected function getOperationName(): string {
14
+	final protected function getOperationName (): string {
15 15
 		return 'subtask';
16 16
 	}
17 17
 }
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
 
@@ -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
 		$pages = $this->getDataProvider()->getPagesToClose();
19 19
 		$protectReason = $this->msg( 'close-protect-summary' )->text();
20 20
 		foreach ( $pages as $page ) {
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	/**
32 32
 	 * @param PageRiconferma $page
33 33
 	 */
34
-	protected function addVoteCloseText( PageRiconferma $page ) {
34
+	protected function addVoteCloseText ( PageRiconferma $page ) {
35 35
 		$content = $page->getContent();
36 36
 		$beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!';
37 37
 		$newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content );
@@ -46,15 +46,14 @@  discard block
 block discarded – undo
46 46
 	 * @param PageRiconferma $page
47 47
 	 * @see CreatePages::updateBasePage()
48 48
 	 */
49
-	protected function updateBasePage( PageRiconferma $page ) {
49
+	protected function updateBasePage ( PageRiconferma $page ) {
50 50
 		$this->getLogger()->info( "Updating base page for $page" );
51 51
 
52 52
 		$basePage = new Page( $page->getBaseTitle() );
53 53
 		$current = $basePage->getContent();
54 54
 
55 55
 		$outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ?
56
-			'non riconfermato' :
57
-			'riconfermato';
56
+			'non riconfermato' : 'riconfermato';
58 57
 		$text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita';
59 58
 
60 59
 		$newContent = str_replace( 'riconferma in corso', $text, $current );
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 protected function getOperationName() : string;
78
+	abstract protected 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
 			get_class( $ex ) . ': ' .
89 89
 			$ex->getMessage() . "\nTrace:\n" .
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 	 * @param int $errline
101 101
 	 * @protected
102 102
 	 */
103
-	public function handleError( $errno, $errstr, $errfile, $errline ) {
103
+	public function handleError ( $errno, $errstr, $errfile, $errline ) {
104 104
 		throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline );
105 105
 	}
106 106
 
107 107
 	/**
108 108
 	 * @return TaskDataProvider
109 109
 	 */
110
-	protected function getDataProvider() : TaskDataProvider {
110
+	protected function getDataProvider () : TaskDataProvider {
111 111
 		return $this->dataProvider;
112 112
 	}
113 113
 }
Please login to merge, or discard this patch.
includes/Task/Task.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\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." );
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	/**
34 34
 	 * @inheritDoc
35 35
 	 */
36
-	final protected function getOperationName(): string {
36
+	final protected function getOperationName (): string {
37 37
 		return 'task';
38 38
 	}
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param string $class
44 44
 	 * @return Subtask
45 45
 	 */
46
-	private function getSubtaskInstance( string $class ) : Subtask {
46
+	private function getSubtaskInstance ( string $class ) : Subtask {
47 47
 		return new $class( $this->getDataProvider() );
48 48
 	}
49 49
 }
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
 
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 	/** @var self */
13 13
 	private static $instance;
14 14
 	/** @var array */
15
-	private $opts = [];
15
+	private $opts = [ ];
16 16
 
17 17
 	/**
18 18
 	 * Use self::init() and self::getInstance()
19 19
 	 */
20
-	private function __construct() {
20
+	private function __construct () {
21 21
 	}
22 22
 
23 23
 	/**
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
 	 * @param array $defaults
27 27
 	 * @throws ConfigException
28 28
 	 */
29
-	public static function init( array $defaults ) {
29
+	public static function init ( array $defaults ) {
30 30
 		if ( self::$instance ) {
31 31
 			throw new ConfigException( 'Config was already initialized' );
32 32
 		}
33 33
 
34 34
 		$inst = new self;
35
-		$inst->set( 'list-title', $defaults['list-title'] );
36
-		$inst->set( 'msg-title', $defaults['msg-title'] );
37
-		$inst->set( 'username', $defaults['username'] );
38
-		$inst->set( 'password', $defaults['password'] );
35
+		$inst->set( 'list-title', $defaults[ 'list-title' ] );
36
+		$inst->set( 'msg-title', $defaults[ 'msg-title' ] );
37
+		$inst->set( 'username', $defaults[ 'username' ] );
38
+		$inst->set( 'password', $defaults[ 'password' ] );
39 39
 		self::$instance = $inst;
40 40
 
41 41
 		// On-wiki values
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * @param string $key
55 55
 	 * @return string
56 56
 	 */
57
-	public function getWikiMessage( string $key ) : string {
57
+	public function getWikiMessage ( string $key ) : string {
58 58
 		static $messages = null;
59 59
 		if ( $messages === null ) {
60 60
 			try {
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 			throw new ConfigException( "Message '$key' does not exist." );
69 69
 		}
70 70
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
71
-		return $messages[$key];
71
+		return $messages[ $key ];
72 72
 	}
73 73
 	/**
74 74
 	 * Set a config value.
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 	 * @param string $key
77 77
 	 * @param mixed $value
78 78
 	 */
79
-	protected function set( string $key, $value ) {
79
+	protected function set ( string $key, $value ) {
80 80
 		$this->opts[ $key ] = $value;
81 81
 	}
82 82
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @return self
87 87
 	 * @throws ConfigException
88 88
 	 */
89
-	public static function getInstance() : self {
89
+	public static function getInstance () : self {
90 90
 		if ( !self::$instance ) {
91 91
 			throw new ConfigException( 'Config not yet initialized' );
92 92
 		}
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @return mixed
101 101
 	 * @throws ConfigException
102 102
 	 */
103
-	public function get( string $opt ) {
103
+	public function get ( string $opt ) {
104 104
 		if ( !isset( $this->opts[ $opt ] ) ) {
105 105
 			throw new ConfigException( "Config option '$opt' not set." );
106 106
 		}
Please login to merge, or discard this patch.