Passed
Push — master ( 35639c...18326f )
by Daimona
01:42
created
includes/ContextSource.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
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	/** @var WikiController */
19 19
 	private $controller;
20 20
 
21
-	public function __construct() {
21
+	public function __construct () {
22 22
 		$this->setLogger( new Logger );
23 23
 		$this->setConfig( Config::getInstance() );
24 24
 		$this->setController( new WikiController );
@@ -27,42 +27,42 @@  discard block
 block discarded – undo
27 27
 	/**
28 28
 	 * @return LoggerInterface
29 29
 	 */
30
-	protected function getLogger() : LoggerInterface {
30
+	protected function getLogger () : LoggerInterface {
31 31
 		return $this->logger;
32 32
 	}
33 33
 
34 34
 	/**
35 35
 	 * @inheritDoc
36 36
 	 */
37
-	public function setLogger( LoggerInterface $logger ) {
37
+	public function setLogger ( LoggerInterface $logger ) {
38 38
 		$this->logger = $logger;
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * @return Config
43 43
 	 */
44
-	protected function getConfig() : Config {
44
+	protected function getConfig () : Config {
45 45
 		return $this->config;
46 46
 	}
47 47
 
48 48
 	/**
49 49
 	 * @param Config $cfg
50 50
 	 */
51
-	protected function setConfig( Config $cfg ) {
51
+	protected function setConfig ( Config $cfg ) {
52 52
 		$this->config = $cfg;
53 53
 	}
54 54
 
55 55
 	/**
56 56
 	 * @return WikiController
57 57
 	 */
58
-	protected function getController() : WikiController {
58
+	protected function getController () : WikiController {
59 59
 		return $this->controller;
60 60
 	}
61 61
 
62 62
 	/**
63 63
 	 * @param WikiController $controller
64 64
 	 */
65
-	protected function setController( WikiController $controller ) {
65
+	protected function setController ( WikiController $controller ) {
66 66
 		$this->controller = $controller;
67 67
 	}
68 68
 
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string $key
73 73
 	 * @return Message
74 74
 	 */
75
-	protected function msg( string $key ) : Message {
75
+	protected function msg ( string $key ) : Message {
76 76
 		return new Message( $key );
77 77
 	}
78 78
 }
Please login to merge, or discard this patch.
includes/Message.php 1 patch
Spacing   +6 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;
4 4
 
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 	/**
15 15
 	 * @param string $key
16 16
 	 */
17
-	public function __construct( string $key ) {
17
+	public function __construct ( string $key ) {
18 18
 		$this->key = $key;
19 19
 		$this->value = Config::getInstance()->getWikiMessage( $key );
20 20
 	}
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param array $args
24 24
 	 * @return self
25 25
 	 */
26
-	public function params( array $args ) : self {
26
+	public function params ( array $args ) : self {
27 27
 		$this->value = strtr( $this->value, $args );
28 28
 		return $this;
29 29
 	}
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	/**
32 32
 	 * @return string
33 33
 	 */
34
-	public function text() : string {
34
+	public function text () : string {
35 35
 		$this->parsePlurals();
36 36
 		return $this->value;
37 37
 	}
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	/**
40 40
 	 * Replace {{$plur|<amount>|sing|plur}}
41 41
 	 */
42
-	protected function parsePlurals() {
42
+	protected function parsePlurals () {
43 43
 		$this->value = preg_replace_callback(
44 44
 			'!\{\{$plur|(?P<amount>\d+)|(?P<sing>[^}|]+)|(?P<plur>[^|}]+)}}!',
45 45
 			function ( $matches ) {
46
-				return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] );
46
+				return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] );
47 47
 			},
48 48
 			$this->value
49 49
 		);
Please login to merge, or discard this patch.
includes/PageRiconferma.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;
4 4
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @return string
23 23
 	 */
24
-	public function getUser() : string {
25
-		return explode( '/', $this->title )[2];
24
+	public function getUser () : string {
25
+		return explode( '/', $this->title )[ 2 ];
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @return int
32 32
 	 */
33
-	public function getNum() : int {
33
+	public function getNum () : int {
34 34
 		$bits = explode( '/', $this->getTitle() );
35 35
 		return intval( end( $bits ) );
36 36
 	}
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 	 *
41 41
 	 * @return string
42 42
 	 */
43
-	public function getUserNum() : string {
44
-		return explode( '/', $this->getTitle(), 3 )[2];
43
+	public function getUserNum () : string {
44
+		return explode( '/', $this->getTitle(), 3 )[ 2 ];
45 45
 	}
46 46
 
47 47
 	/**
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 *
50 50
 	 * @return string
51 51
 	 */
52
-	public function getBaseTitle() : string {
52
+	public function getBaseTitle () : string {
53 53
 		// @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug
54 54
 		return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) );
55 55
 	}
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @return int
61 61
 	 */
62
-	public function getOpposingCount() : int {
62
+	public function getOpposingCount () : int {
63 63
 		return $this->getCountForSection( self::SECTION_OPPOSE );
64 64
 	}
65 65
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 *
69 69
 	 * @return int
70 70
 	 */
71
-	public function getSupportCount() : int {
71
+	public function getSupportCount () : int {
72 72
 		return $this->getCountForSection( self::SECTION_SUPPORT );
73 73
 	}
74 74
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @param int $secNum
79 79
 	 * @return int
80 80
 	 */
81
-	protected function getCountForSection( int $secNum ) : int {
81
+	protected function getCountForSection ( int $secNum ) : int {
82 82
 		$content = $this->controller->getPageContent( $this->title, $secNum );
83 83
 		// Let's hope that this is good enough...
84 84
 		return substr_count( $content, "\n\# *(?![#*])" );
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	 *
90 90
 	 * @return int
91 91
 	 */
92
-	protected function getQuorum() : int {
92
+	protected function getQuorum () : int {
93 93
 		$reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!";
94
-		$matches = [];
94
+		$matches = [ ];
95 95
 		preg_match( $reg, $this->getContent(), $matches );
96
-		return intval( $matches[1] );
96
+		return intval( $matches[ 1 ] );
97 97
 	}
98 98
 
99 99
 	/**
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 * @return bool
103 103
 	 */
104
-	public function hasOpposition() : bool {
104
+	public function hasOpposition () : bool {
105 105
 		return $this->getOpposingCount() >= 15;
106 106
 	}
107 107
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	 * @return int One of the OUTCOME_* constants
112 112
 	 * @throws \BadMethodCallException
113 113
 	 */
114
-	public function getOutcome() : int {
114
+	public function getOutcome () : int {
115 115
 		if ( !$this->isVote() ) {
116 116
 			throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' );
117 117
 		}
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @return string
131 131
 	 * @throws \BadMethodCallException
132 132
 	 */
133
-	public function getOutcomeText() : string {
133
+	public function getOutcomeText () : string {
134 134
 		if ( !$this->isVote() ) {
135 135
 			throw new \BadMethodCallException( 'No need for an outcome text.' );
136 136
 		}
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 *
163 163
 	 * @return bool
164 164
 	 */
165
-	public function isVote() : bool {
165
+	public function isVote () : bool {
166 166
 		$sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/';
167 167
 		return preg_match( $sectionReg, $this->getContent() ) === false;
168 168
 	}
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return int
174 174
 	 */
175
-	public function getEndTimestamp() : int {
175
+	public function getEndTimestamp () : int {
176 176
 		if ( $this->isVote() ) {
177
-			$matches = [];
177
+			$matches = [ ];
178 178
 			$reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!";
179 179
 			preg_match( $reg, $this->getContent(), $matches );
180 180
 			list( , $day, $hours ) = $matches;
Please login to merge, or discard this patch.
includes/TaskDataProvider.php 1 patch
Spacing   +15 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;
4 4
 
@@ -13,14 +13,14 @@  discard block
 block discarded – undo
13 13
 	/** @var array[] */
14 14
 	private $allUsers;
15 15
 	/** @var PageRiconferma[] */
16
-	private $createdPages = [];
16
+	private $createdPages = [ ];
17 17
 
18 18
 	/**
19 19
 	 * Get the full content of the JSON users list
20 20
 	 *
21 21
 	 * @return array[]
22 22
 	 */
23
-	public function getUsersList() : array {
23
+	public function getUsersList () : array {
24 24
 		if ( $this->allUsers === null ) {
25 25
 			$this->getLogger()->debug( 'Retrieving users list' );
26 26
 			$content = $this->getController()->getPageContent( $this->getConfig()->get( 'list-title' ) );
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @return array[]
37 37
 	 */
38
-	public function getUsersToProcess() : array {
38
+	public function getUsersToProcess () : array {
39 39
 		if ( $this->processUsers === null ) {
40
-			$this->processUsers = [];
40
+			$this->processUsers = [ ];
41 41
 			foreach ( $this->getUsersList() as $user => $groups ) {
42 42
 				$timestamp = $this->getValidTimestamp( $groups );
43 43
 
@@ -59,13 +59,11 @@  discard block
 block discarded – undo
59 59
 	 * @param array $groups
60 60
 	 * @return int
61 61
 	 */
62
-	private function getValidTimestamp( array $groups ) : int {
62
+	private function getValidTimestamp ( array $groups ) : int {
63 63
 		$checkuser = isset( $groups[ 'checkuser' ] ) ?
64
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() :
65
-			0;
64
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0;
66 65
 		$bureaucrat = isset( $groups[ 'bureaucrat' ] ) ?
67
-			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() :
68
-			0;
66
+			\DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0;
69 67
 
70 68
 		$timestamp = max( $bureaucrat, $checkuser );
71 69
 		if ( $timestamp === 0 ) {
@@ -79,7 +77,7 @@  discard block
 block discarded – undo
79 77
 	 *
80 78
 	 * @return PageRiconferma[]
81 79
 	 */
82
-	public function getOpenPages() : array {
80
+	public function getOpenPages () : array {
83 81
 		$baseTitle = $this->getConfig()->get( 'ric-main-page' );
84 82
 		$params = [
85 83
 			'action' => 'query',
@@ -91,10 +89,10 @@  discard block
 block discarded – undo
91 89
 
92 90
 		$res = RequestBase::newFromParams( $params )->execute();
93 91
 		$pages = $res->query->pages;
94
-		$ret = [];
92
+		$ret = [ ];
95 93
 		foreach ( reset( $pages )->templates as $page ) {
96 94
 			if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) {
97
-				$ret[] = new PageRiconferma( $page->title );
95
+				$ret[ ] = new PageRiconferma( $page->title );
98 96
 			}
99 97
 		}
100 98
 		return $ret;
@@ -105,21 +103,21 @@  discard block
 block discarded – undo
105 103
 	 *
106 104
 	 * @param string $name
107 105
 	 */
108
-	public function removeUser( string $name ) {
106
+	public function removeUser ( string $name ) {
109 107
 		unset( $this->processUsers[ $name ] );
110 108
 	}
111 109
 
112 110
 	/**
113 111
 	 * @return PageRiconferma[]
114 112
 	 */
115
-	public function getCreatedPages() : array {
113
+	public function getCreatedPages () : array {
116 114
 		return $this->createdPages;
117 115
 	}
118 116
 
119 117
 	/**
120 118
 	 * @param PageRiconferma $page
121 119
 	 */
122
-	public function addCreatedPages( PageRiconferma $page ) {
123
-		$this->createdPages[] = $page;
120
+	public function addCreatedPages ( PageRiconferma $page ) {
121
+		$this->createdPages[ ] = $page;
124 122
 	}
125 123
 }
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 {
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			}
66 66
 		}
67 67
 		// @phan-suppress-next-line PhanTypeArraySuspiciousNullable
68
-		return $messages[$key];
68
+		return $messages[ $key ];
69 69
 	}
70 70
 	/**
71 71
 	 * Set a config value.
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @param string $key
74 74
 	 * @param mixed $value
75 75
 	 */
76
-	protected function set( string $key, $value ) {
76
+	protected function set ( string $key, $value ) {
77 77
 		$this->opts[ $key ] = $value;
78 78
 	}
79 79
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @return self
84 84
 	 * @throws ConfigException
85 85
 	 */
86
-	public static function getInstance() : self {
86
+	public static function getInstance () : self {
87 87
 		if ( !self::$instance ) {
88 88
 			throw new ConfigException( 'Config not yet initialized' );
89 89
 		}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return mixed
98 98
 	 * @throws ConfigException
99 99
 	 */
100
-	public function get( string $opt ) {
100
+	public function get ( string $opt ) {
101 101
 		if ( !isset( $this->opts[ $opt ] ) ) {
102 102
 			throw new ConfigException( "Config option '$opt' not set." );
103 103
 		}
Please login to merge, or discard this patch.
includes/Request/RequestBase.php 1 patch
Spacing   +22 added lines, -22 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\Request;
4 4
 
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	/** @var string */
30 30
 	protected $method = 'GET';
31 31
 	/** @var string[] */
32
-	protected $newCookies = [];
32
+	protected $newCookies = [ ];
33 33
 
34 34
 	/**
35 35
 	 * Use self::newFromParams, which will provide the right class to use
36 36
 	 *
37 37
 	 * @param array $params
38 38
 	 */
39
-	protected function __construct( array $params ) {
39
+	protected function __construct ( array $params ) {
40 40
 		$this->params = [ 'format' => 'json' ] + $params;
41 41
 		$this->url = DEFAULT_URL;
42 42
 	}
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * @param array $params
48 48
 	 * @return self
49 49
 	 */
50
-	public static function newFromParams( array $params ) : self {
50
+	public static function newFromParams ( array $params ) : self {
51 51
 		if ( extension_loaded( 'curl' ) ) {
52 52
 			$ret = new CurlRequest( $params );
53 53
 		} else {
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 *
62 62
 	 * @return self For chaining
63 63
 	 */
64
-	public function setPost() : self {
64
+	public function setPost () : self {
65 65
 		$this->method = 'POST';
66 66
 		return $this;
67 67
 	}
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param string $url
73 73
 	 * @return self for chaining
74 74
 	 */
75
-	public function setUrl( string $url ) : self {
75
+	public function setUrl ( string $url ) : self {
76 76
 		$this->url = $url;
77 77
 		return $this;
78 78
 	}
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	 *
83 83
 	 * @return \stdClass
84 84
 	 */
85
-	public function execute() : \stdClass {
85
+	public function execute () : \stdClass {
86 86
 		$curParams = $this->params;
87
-		$sets = [];
87
+		$sets = [ ];
88 88
 		do {
89 89
 			$res = $this->makeRequestInternal( $curParams );
90 90
 
91 91
 			$this->handleErrorAndWarnings( $res );
92
-			$sets[] = $res;
92
+			$sets[ ] = $res;
93 93
 
94 94
 			$finished = true;
95 95
 			if ( isset( $res->continue ) ) {
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
 	 * @param array $params
108 108
 	 * @return \stdClass
109 109
 	 */
110
-	private function makeRequestInternal( array $params ) : \stdClass {
110
+	private function makeRequestInternal ( array $params ) : \stdClass {
111 111
 		if ( $this->method === 'POST' ) {
112
-			$params['maxlag'] = self::MAXLAG;
112
+			$params[ 'maxlag' ] = self::MAXLAG;
113 113
 		}
114 114
 		$params = http_build_query( $params );
115 115
 
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
 	 * @param string $params
126 126
 	 * @return string
127 127
 	 */
128
-	abstract protected function reallyMakeRequest( string $params ) : string;
128
+	abstract protected function reallyMakeRequest ( string $params ) : string;
129 129
 
130 130
 	/**
131 131
 	 * After a request, set cookies for the next ones
132 132
 	 *
133 133
 	 * @param array $cookies
134 134
 	 */
135
-	protected function setCookies( array $cookies ) {
135
+	protected function setCookies ( array $cookies ) {
136 136
 		foreach ( $cookies as $cookie ) {
137 137
 			$bits = explode( ';', $cookie );
138
-			list( $name, $value ) = explode( '=', $bits[0] );
138
+			list( $name, $value ) = explode( '=', $bits[ 0 ] );
139 139
 			self::$cookiesToSet[ $name ] = $value;
140 140
 		}
141 141
 	}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param \stdClass $res
147 147
 	 * @throws APIRequestException
148 148
 	 */
149
-	protected function handleErrorAndWarnings( $res ) {
149
+	protected function handleErrorAndWarnings ( $res ) {
150 150
 		if ( isset( $res->error ) ) {
151 151
 			switch ( $res->error->code ) {
152 152
 				case 'missingtitle':
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @param \stdClass[] $sets
173 173
 	 * @return \stdClass
174 174
 	 */
175
-	private function mergeSets( array $sets ) : \stdClass {
175
+	private function mergeSets ( array $sets ) : \stdClass {
176 176
 		// Use the first set as template
177 177
 		$ret = array_shift( $sets );
178 178
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * @param array|\stdClass $second
190 190
 	 * @return array|\stdClass array
191 191
 	 */
192
-	private function recursiveMerge( $first, $second ) {
192
+	private function recursiveMerge ( $first, $second ) {
193 193
 		$ret = $first;
194 194
 		if ( is_array( $second ) ) {
195 195
 			$ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second;
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @return array
209 209
 	 */
210
-	protected function getHeaders() :array {
210
+	protected function getHeaders () :array {
211 211
 		$ret = self::HEADERS;
212 212
 		if ( self::$cookiesToSet ) {
213
-			$cookies = [];
213
+			$cookies = [ ];
214 214
 			foreach ( self::$cookiesToSet as $cname => $cval ) {
215
-				$cookies[] = trim( "$cname=$cval" );
215
+				$cookies[ ] = trim( "$cname=$cval" );
216 216
 			}
217
-			$ret[] = 'Cookie: ' . implode( '; ', $cookies );
217
+			$ret[ ] = 'Cookie: ' . implode( '; ', $cookies );
218 218
 		}
219 219
 		return $ret;
220 220
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param array $headers
226 226
 	 * @return string
227 227
 	 */
228
-	protected function buildHeadersString( array $headers ) : string {
228
+	protected function buildHeadersString ( array $headers ) : string {
229 229
 		$ret = '';
230 230
 		foreach ( $headers as $header ) {
231 231
 			$ret .= "$header\r\n";
Please login to merge, or discard this patch.
includes/Request/NativeRequest.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\Request;
4 4
 
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	/**
10 10
 	 * @inheritDoc
11 11
 	 */
12
-	protected function reallyMakeRequest( string $params ) : string {
12
+	protected function reallyMakeRequest ( string $params ) : string {
13 13
 		$context = [
14 14
 			'http' => [
15 15
 				'method' => $this->method,
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		];
19 19
 		$url = $this->url;
20 20
 		if ( $this->method === 'POST' ) {
21
-			$context['http']['content'] = $params;
21
+			$context[ 'http' ][ 'content' ] = $params;
22 22
 		} else {
23 23
 			$url = "$url?$params";
24 24
 		}
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 
28 28
 		foreach ( $http_response_header as $header ) {
29 29
 			$bits = explode( ':', $header, 2 );
30
-			if ( trim( $bits[0] ) === 'Set-Cookie' ) {
31
-				$this->newCookies[] = $bits[1];
30
+			if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) {
31
+				$this->newCookies[ ] = $bits[ 1 ];
32 32
 			}
33 33
 		}
34 34
 
Please login to merge, or discard this patch.
includes/Page.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
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 * @param string $title
18 18
 	 * @param string $domain The site where the page lives, if different from default
19 19
 	 */
20
-	public function __construct( string $title, string $domain = DEFAULT_URL ) {
20
+	public function __construct ( string $title, string $domain = DEFAULT_URL ) {
21 21
 		$this->title = $title;
22 22
 		$this->controller = new WikiController( $domain );
23 23
 	}
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * @return string
27 27
 	 */
28
-	public function getTitle() : string {
28
+	public function getTitle () : string {
29 29
 		return $this->title;
30 30
 	}
31 31
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param int|null $section A section number to retrieve the content of that section
36 36
 	 * @return string
37 37
 	 */
38
-	public function getContent( int $section = null ) : string {
38
+	public function getContent ( int $section = null ) : string {
39 39
 		if ( $this->content === null ) {
40 40
 			$this->content = $this->controller->getPageContent( $this->title, $section );
41 41
 		}
@@ -47,16 +47,16 @@  discard block
 block discarded – undo
47 47
 	 *
48 48
 	 * @param array $params
49 49
 	 */
50
-	public function edit( array $params ) {
50
+	public function edit ( array $params ) {
51 51
 		$params = [
52 52
 			'title' => $this->getTitle()
53 53
 		] + $params;
54 54
 
55 55
 		$this->controller->editPage( $params );
56
-		if ( isset( $params['text'] ) ) {
57
-			$this->content = $params['text'];
58
-		} elseif ( isset( $params['appendtext'] ) ) {
59
-			$this->content .= $params['appendtext'];
56
+		if ( isset( $params[ 'text' ] ) ) {
57
+			$this->content = $params[ 'text' ];
58
+		} elseif ( isset( $params[ 'appendtext' ] ) ) {
59
+			$this->content .= $params[ 'appendtext' ];
60 60
 		} else {
61 61
 			// Clear the cache anyway
62 62
 			( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) );
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * @return string
71 71
 	 */
72
-	public function __toString() {
72
+	public function __toString () {
73 73
 		return $this->getTitle();
74 74
 	}
75 75
 }
Please login to merge, or discard this patch.
includes/WikiController.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;
4 4
 
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	/**
25 25
 	 * @param string $domain The URL of the wiki, if different from default
26 26
 	 */
27
-	public function __construct( string $domain = DEFAULT_URL ) {
27
+	public function __construct ( string $domain = DEFAULT_URL ) {
28 28
 		$this->logger = new Logger;
29 29
 		$this->domain = $domain;
30 30
 	}
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @return string
38 38
 	 * @throws MissingPageException
39 39
 	 */
40
-	public function getPageContent( string $title, int $section = null ) : string {
40
+	public function getPageContent ( string $title, int $section = null ) : string {
41 41
 		$this->logger->debug( "Retrieving page $title" );
42 42
 		$params = [
43 43
 			'action' => 'query',
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 		];
49 49
 
50 50
 		if ( $section !== null ) {
51
-			$params['rvsection'] = $section;
51
+			$params[ 'rvsection' ] = $section;
52 52
 		}
53 53
 
54 54
 		$req = RequestBase::newFromParams( $params )->setUrl( $this->domain );
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 			throw new MissingPageException( $title );
59 59
 		}
60 60
 
61
-		return $page->revisions[0]->slots->main->{ '*' };
61
+		return $page->revisions[ 0 ]->slots->main->{ '*' };
62 62
 	}
63 63
 
64 64
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param array $params
68 68
 	 * @throws EditException
69 69
 	 */
70
-	public function editPage( array $params ) {
70
+	public function editPage ( array $params ) {
71 71
 		$this->login();
72 72
 
73 73
 		$params = [
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	 * @return string
93 93
 	 * @fixme Not the right place for this
94 94
 	 */
95
-	public static function getTimeWithArticle( int $timestamp ) : string {
95
+	public static function getTimeWithArticle ( int $timestamp ) : string {
96 96
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
97 97
 		$timeString = strftime( '%e %B alle %R', $timestamp );
98 98
 		// Remove the left space if day has a single digit
@@ -111,16 +111,16 @@  discard block
 block discarded – undo
111 111
 	 * @fixme Not the right place for this
112 112
 	 * @todo Is there a better way?
113 113
 	 */
114
-	public static function getTimestampFromLocalTime( string $timeString ) : int {
114
+	public static function getTimestampFromLocalTime ( string $timeString ) : int {
115 115
 		$oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' );
116 116
 		$bits = strptime( $timeString, '%e %m %Y alle %H:%M' );
117 117
 		$timestamp = mktime(
118
-			$bits['tm_hour'],
119
-			$bits['tm_min'],
118
+			$bits[ 'tm_hour' ],
119
+			$bits[ 'tm_min' ],
120 120
 			0,
121
-			$bits['tm_mon'] + 1,
122
-			$bits['tm_mday'],
123
-			$bits['tm_year'] + 1900
121
+			$bits[ 'tm_mon' ] + 1,
122
+			$bits[ 'tm_mday' ],
123
+			$bits[ 'tm_year' ] + 1900
124 124
 		);
125 125
 		setlocale( LC_TIME, $oldLoc );
126 126
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * Login wrapper. Checks if we're already logged in and clears tokens cache
131 131
 	 * @throws LoginException
132 132
 	 */
133
-	public function login() {
133
+	public function login () {
134 134
 		if ( self::$loggedIn ) {
135 135
 			$this->logger->debug( 'Already logged in' );
136 136
 			return;
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
 		self::$loggedIn = true;
159 159
 		// Clear tokens cache
160
-		$this->tokens = [];
160
+		$this->tokens = [ ];
161 161
 		$this->logger->info( 'Login succeeded' );
162 162
 	}
163 163
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param string $type
168 168
 	 * @return string
169 169
 	 */
170
-	public function getToken( string $type ) : string {
170
+	public function getToken ( string $type ) : string {
171 171
 		if ( !isset( $this->tokens[ $type ] ) ) {
172 172
 			$params = [
173 173
 				'action' => 'query',
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @param string $title
191 191
 	 * @return int
192 192
 	 */
193
-	public function getPageCreationTS( string $title ) : int {
193
+	public function getPageCreationTS ( string $title ) : int {
194 194
 		$params = [
195 195
 			'action' => 'query',
196 196
 			'prop' => 'revisions',
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 
204 204
 		$res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute();
205 205
 		$data = $res->query->pages;
206
-		return strtotime( reset( $data )->revisions[0]->timestamp );
206
+		return strtotime( reset( $data )->revisions[ 0 ]->timestamp );
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @param string $title
213 213
 	 * @param string $reason
214 214
 	 */
215
-	public function protectPage( string $title, string $reason ) {
215
+	public function protectPage ( string $title, string $reason ) {
216 216
 		$this->logger->info( "Protecting page $title" );
217 217
 		$this->login();
218 218
 
Please login to merge, or discard this patch.