Passed
Push — master ( a192f6...3a1f1a )
by Daimona
02:01
created
includes/Config.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;
4 4
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/** @var self */
22 22
 	private static $instance;
23 23
 	/** @var array */
24
-	private $opts = [];
24
+	private $opts = [ ];
25 25
 	/** @var Wiki */
26 26
 	private $wiki;
27 27
 
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param Wiki $wiki
32 32
 	 */
33
-	private function __construct( Wiki $wiki ) {
33
+	private function __construct ( Wiki $wiki ) {
34 34
 		$this->wiki = $wiki;
35 35
 	}
36 36
 
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 	 * @param Wiki $wiki
42 42
 	 * @throws ConfigException
43 43
 	 */
44
-	public static function init( array $defaults, Wiki $wiki ) : void {
44
+	public static function init ( array $defaults, Wiki $wiki ) : void {
45 45
 		if ( self::$instance ) {
46 46
 			throw new ConfigException( 'Config was already initialized' );
47 47
 		}
48 48
 
49 49
 		$inst = new self( $wiki );
50
-		$inst->set( 'list-title', $defaults['list-title'] );
51
-		$inst->set( 'msg-title', $defaults['msg-title'] );
52
-		$inst->set( 'username', $defaults['username'] );
53
-		$inst->set( 'password', $defaults['password'] );
50
+		$inst->set( 'list-title', $defaults[ 'list-title' ] );
51
+		$inst->set( 'msg-title', $defaults[ 'msg-title' ] );
52
+		$inst->set( 'username', $defaults[ 'username' ] );
53
+		$inst->set( 'password', $defaults[ 'password' ] );
54 54
 
55 55
 		// On-wiki values
56 56
 		try {
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @param string $key
72 72
 	 * @param mixed $value
73 73
 	 */
74
-	protected function set( string $key, $value ) : void {
74
+	protected function set ( string $key, $value ) : void {
75 75
 		$this->opts[ $key ] = $value;
76 76
 	}
77 77
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @return self
82 82
 	 * @throws ConfigException
83 83
 	 */
84
-	public static function getInstance() : self {
84
+	public static function getInstance () : self {
85 85
 		if ( !self::$instance ) {
86 86
 			throw new ConfigException( 'Config not yet initialized' );
87 87
 		}
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	 * @return mixed
96 96
 	 * @throws ConfigException
97 97
 	 */
98
-	public function get( string $opt ) {
98
+	public function get ( string $opt ) {
99 99
 		if ( !isset( $this->opts[ $opt ] ) ) {
100 100
 			throw new ConfigException( "Config option '$opt' not set." );
101 101
 		}
Please login to merge, or discard this patch.
includes/Message.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;
4 4
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @param string $value
25 25
 	 */
26
-	public function __construct( string $value ) {
26
+	public function __construct ( string $value ) {
27 27
 		$this->value = $value;
28 28
 	}
29 29
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 * @param array $args
32 32
 	 * @return self
33 33
 	 */
34
-	public function params( array $args ) : self {
34
+	public function params ( array $args ) : self {
35 35
 		$this->value = strtr( $this->value, $args );
36 36
 		return $this;
37 37
 	}
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * @return string
41 41
 	 */
42
-	public function text() : string {
42
+	public function text () : string {
43 43
 		$this->parsePlurals();
44 44
 		return $this->value;
45 45
 	}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	/**
48 48
 	 * Replace {{$plur|<amount>|sing|plur}}
49 49
 	 */
50
-	protected function parsePlurals() : void {
50
+	protected function parsePlurals () : void {
51 51
 		$reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!';
52 52
 
53 53
 		if ( preg_match( $reg, $this->value ) === 0 ) {
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$this->value = preg_replace_callback(
57 57
 			$reg,
58 58
 			static function ( $matches ) {
59
-				return (int)$matches['amount'] > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
59
+				return (int)$matches[ 'amount' ] > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
60 60
 			},
61 61
 			$this->value
62 62
 		);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param string $timeString Full format, e.g. "15 aprile 2019 18:27"
69 69
 	 * @return int
70 70
 	 */
71
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
71
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
72 72
 		$englishTime = str_ireplace(
73 73
 			array_values( self::MONTHS ),
74 74
 			array_keys( self::MONTHS ),
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 * @param string $emptyText
87 87
 	 * @return string
88 88
 	 */
89
-	public static function commaList( array $data, string $emptyText = 'nessuno' ) : string {
89
+	public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string {
90 90
 		if ( count( $data ) > 1 ) {
91 91
 			$last = array_pop( $data );
92 92
 			$ret = implode( ', ', $data ) . " e $last";
93 93
 		} elseif ( $data ) {
94
-			$ret = (string)$data[0];
94
+			$ret = (string)$data[ 0 ];
95 95
 		} else {
96 96
 			$ret = $emptyText;
97 97
 		}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		return $ret;
100 100
 	}
101 101
 
102
-	public function __toString() {
102
+	public function __toString () {
103 103
 		return $this->text();
104 104
 	}
105 105
 }
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 public function getOperationName(): string {
36
+	final public 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
 		/** @var Subtask $ret */
48 48
 		$ret = new $class(
49 49
 			$this->getLogger(),
Please login to merge, or discard this patch.
includes/Task/TaskBase.php 1 patch
Spacing   +7 added lines, -7 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
 abstract class TaskBase extends ContextSource {
16 16
 	/** @var string[] */
17
-	protected $errors = [];
17
+	protected $errors = [ ];
18 18
 	/** @var TaskDataProvider */
19 19
 	protected $dataProvider;
20 20
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param TaskDataProvider $dataProvider
27 27
 	 * @param MessageProvider $mp
28 28
 	 */
29
-	final public function __construct(
29
+	final public function __construct (
30 30
 		LoggerInterface $logger,
31 31
 		Wiki $wiki,
32 32
 		TaskDataProvider $dataProvider,
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @return TaskResult
43 43
 	 */
44
-	final public function run() : TaskResult {
44
+	final public function run () : TaskResult {
45 45
 		$class = ( new \ReflectionClass( $this ) )->getShortName();
46 46
 		$opName = $this->getOperationName();
47 47
 		$this->getLogger()->info( "Starting $opName $class" );
@@ -72,19 +72,19 @@  discard block
 block discarded – undo
72 72
 	 *
73 73
 	 * @return int One of the STATUS_* constants
74 74
 	 */
75
-	abstract protected function runInternal() : int;
75
+	abstract protected function runInternal () : int;
76 76
 
77 77
 	/**
78 78
 	 * How this operation should be called in logs
79 79
 	 *
80 80
 	 * @return string
81 81
 	 */
82
-	abstract public function getOperationName() : string;
82
+	abstract public function getOperationName () : string;
83 83
 
84 84
 	/**
85 85
 	 * @return TaskDataProvider
86 86
 	 */
87
-	protected function getDataProvider() : TaskDataProvider {
87
+	protected function getDataProvider () : TaskDataProvider {
88 88
 		return $this->dataProvider;
89 89
 	}
90 90
 }
Please login to merge, or discard this patch.
includes/Exception/CannotLoginException.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\Exception;
4 4
 
Please login to merge, or discard this patch.
includes/Exception/MessageNotFoundException.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\Exception;
4 4
 
Please login to merge, or discard this patch.
includes/Exception/MessagesPageDoesNotExistException.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\Exception;
4 4
 
Please login to merge, or discard this patch.
includes/MessageProvider.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
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param Wiki $wiki
21 21
 	 * @param string $msgTitle
22 22
 	 */
23
-	public function __construct( Wiki $wiki, string $msgTitle ) {
23
+	public function __construct ( Wiki $wiki, string $msgTitle ) {
24 24
 		$this->wiki = $wiki;
25 25
 		$this->msgTitle = $msgTitle;
26 26
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	/**
29 29
 	 * @throws MessagesPageDoesNotExistException
30 30
 	 */
31
-	private function grabWikiMessages() : void {
31
+	private function grabWikiMessages () : void {
32 32
 		if ( self::$messages !== null ) {
33 33
 			return;
34 34
 		}
@@ -45,12 +45,12 @@  discard block
 block discarded – undo
45 45
 	 * @return Message
46 46
 	 * @throws MessageNotFoundException
47 47
 	 */
48
-	public function getMessage( string $key ) : Message {
48
+	public function getMessage ( string $key ) : Message {
49 49
 		$this->grabWikiMessages();
50 50
 		if ( !isset( self::$messages[ $key ] ) ) {
51 51
 			throw new MessageNotFoundException( "Message '$key' does not exist." );
52 52
 		}
53 53
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
54
-		return new Message( self::$messages[$key] );
54
+		return new Message( self::$messages[ $key ] );
55 55
 	}
56 56
 }
Please login to merge, or discard this patch.
includes/Wiki/LoginInfo.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\Wiki;
4 4
 
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 	 * @param string $username
16 16
 	 * @param string $password
17 17
 	 */
18
-	public function __construct( string $username, string $password ) {
18
+	public function __construct ( string $username, string $password ) {
19 19
 		$this->username = $username;
20 20
 		$this->password = $password;
21 21
 	}
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 	/**
24 24
 	 * @return string
25 25
 	 */
26
-	public function getUsername() : string {
26
+	public function getUsername () : string {
27 27
 		return $this->username;
28 28
 	}
29 29
 
30 30
 	/**
31 31
 	 * @return string
32 32
 	 */
33
-	public function getPassword() : string {
33
+	public function getPassword () : string {
34 34
 		return $this->password;
35 35
 	}
36 36
 }
Please login to merge, or discard this patch.