@@ -1,4 +1,4 @@ discard block |
||
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 |
||
14 | 14 | /** @var User[]|null */ |
15 | 15 | private $processUsers; |
16 | 16 | /** @var PageRiconferma[] */ |
17 | - private $createdPages = []; |
|
17 | + private $createdPages = [ ]; |
|
18 | 18 | /** @var PageRiconferma[]|null */ |
19 | 19 | private $openPages; |
20 | 20 | /** @var PageRiconferma[]|null */ |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return User[] |
27 | 27 | */ |
28 | - public function getUsersToProcess() : array { |
|
28 | + public function getUsersToProcess () : array { |
|
29 | 29 | if ( $this->processUsers === null ) { |
30 | - $this->processUsers = []; |
|
30 | + $this->processUsers = [ ]; |
|
31 | 31 | foreach ( PageBotList::get( $this->getWiki() )->getAdminsList() as $name => $user ) { |
32 | 32 | if ( $this->shouldAddUser( $user ) ) { |
33 | 33 | $this->processUsers[ $name ] = $user; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param User $user |
45 | 45 | * @return bool |
46 | 46 | */ |
47 | - private function shouldAddUser( User $user ) : bool { |
|
47 | + private function shouldAddUser ( User $user ) : bool { |
|
48 | 48 | $timestamp = PageBotList::getOverrideTimestamp( $user->getUserInfo() ); |
49 | 49 | $override = $timestamp !== null; |
50 | 50 | |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return PageRiconferma[] |
64 | 64 | */ |
65 | - public function getOpenPages() : array { |
|
65 | + public function getOpenPages () : array { |
|
66 | 66 | if ( $this->openPages === null ) { |
67 | - $this->openPages = []; |
|
67 | + $this->openPages = [ ]; |
|
68 | 68 | $mainTitle = $this->getOpt( 'main-page-title' ); |
69 | 69 | $params = [ |
70 | 70 | 'action' => 'query', |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | $pages = RequestBase::newFromParams( $params )->execute()->query->pages; |
79 | 79 | foreach ( reset( $pages )->templates as $page ) { |
80 | 80 | if ( preg_match( "!$titleReg/[^/]+/\d!", $page->title ) ) { |
81 | - $this->openPages[] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
81 | + $this->openPages[ ] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return PageRiconferma[] |
93 | 93 | */ |
94 | - public function getPagesToClose() : array { |
|
94 | + public function getPagesToClose () : array { |
|
95 | 95 | if ( $this->pagesToClose === null ) { |
96 | - $this->pagesToClose = []; |
|
96 | + $this->pagesToClose = [ ]; |
|
97 | 97 | foreach ( $this->getOpenPages() as $page ) { |
98 | 98 | if ( time() > $page->getEndTimestamp() ) { |
99 | - $this->pagesToClose[] = $page; |
|
99 | + $this->pagesToClose[ ] = $page; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -108,21 +108,21 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @param string $name |
110 | 110 | */ |
111 | - public function removeUser( string $name ) : void { |
|
111 | + public function removeUser ( string $name ) : void { |
|
112 | 112 | unset( $this->processUsers[ $name ] ); |
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
116 | 116 | * @return PageRiconferma[] |
117 | 117 | */ |
118 | - public function getCreatedPages() : array { |
|
118 | + public function getCreatedPages () : array { |
|
119 | 119 | return $this->createdPages; |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | 123 | * @param PageRiconferma $page |
124 | 124 | */ |
125 | - public function addCreatedPage( PageRiconferma $page ) : void { |
|
126 | - $this->createdPages[] = $page; |
|
125 | + public function addCreatedPage ( PageRiconferma $page ) : void { |
|
126 | + $this->createdPages[ ] = $page; |
|
127 | 127 | } |
128 | 128 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @param string $minlevel |
19 | 19 | */ |
20 | - public function __construct( $minlevel = LogLevel::INFO ) { |
|
20 | + public function __construct ( $minlevel = LogLevel::INFO ) { |
|
21 | 21 | $this->minLevel = $this->levelToInt( $minlevel ); |
22 | 22 | } |
23 | 23 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @inheritDoc |
26 | 26 | * @suppress PhanUnusedPublicMethodParameter |
27 | 27 | */ |
28 | - public function log( $level, $message, array $context = [] ) : void { |
|
28 | + public function log ( $level, $message, array $context = [ ] ) : void { |
|
29 | 29 | if ( $this->levelToInt( $level ) >= $this->minLevel ) { |
30 | 30 | echo $this->getFormattedMessage( $level, $message ) . "\n"; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @inheritDoc |
36 | 36 | */ |
37 | - public function flush() : void { |
|
37 | + public function flush () : void { |
|
38 | 38 | // Everything else is printed immediately |
39 | 39 | echo "\n" . str_repeat( '-', 80 ) . "\n\n"; |
40 | 40 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @param IFlushingAwareLogger ...$loggers |
16 | 16 | */ |
17 | - public function __construct( IFlushingAwareLogger ...$loggers ) { |
|
17 | + public function __construct ( IFlushingAwareLogger ...$loggers ) { |
|
18 | 18 | $this->loggers = $loggers; |
19 | 19 | } |
20 | 20 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * @inheritDoc |
23 | 23 | * @suppress PhanUnusedPublicMethodParameter |
24 | 24 | */ |
25 | - public function log( $level, $message, array $context = [] ) :void { |
|
25 | + public function log ( $level, $message, array $context = [ ] ) :void { |
|
26 | 26 | foreach ( $this->loggers as $logger ) { |
27 | 27 | $logger->log( $level, $message ); |
28 | 28 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @inheritDoc |
33 | 33 | */ |
34 | - public function flush() : void { |
|
34 | + public function flush () : void { |
|
35 | 35 | foreach ( $this->loggers as $logger ) { |
36 | 36 | $logger->flush(); |
37 | 37 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @param string $level |
12 | 12 | * @return int |
13 | 13 | */ |
14 | - protected function levelToInt( string $level ) : int { |
|
14 | + protected function levelToInt ( string $level ) : int { |
|
15 | 15 | // Order matters |
16 | 16 | $mapping = [ |
17 | 17 | LogLevel::DEBUG, |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $message |
32 | 32 | * @return string |
33 | 33 | */ |
34 | - protected function getFormattedMessage( string $level, string $message ) : string { |
|
34 | + protected function getFormattedMessage ( string $level, string $message ) : string { |
|
35 | 35 | return sprintf( '%s [%s] - %s', date( 'd M H:i:s' ), $level, $message ); |
36 | 36 | } |
37 | 37 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme; |
4 | 4 | |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | /** |
58 | 58 | * @return bool |
59 | 59 | */ |
60 | - public static function isCLI() : bool { |
|
60 | + public static function isCLI () : bool { |
|
61 | 61 | return PHP_SAPI === 'cli'; |
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Populate options and check for required ones |
66 | 66 | */ |
67 | - public function __construct() { |
|
67 | + public function __construct () { |
|
68 | 68 | $opts = getopt( self::SHORT_OPTS, self::LONG_OPTS ); |
69 | 69 | $this->checkRequiredOpts( $opts ); |
70 | 70 | $this->checkConflictingOpts( $opts ); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | /** |
76 | 76 | * @param array $opts |
77 | 77 | */ |
78 | - private function checkRequiredOpts( array $opts ) : void { |
|
78 | + private function checkRequiredOpts ( array $opts ) : void { |
|
79 | 79 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
80 | 80 | if ( $missingOpts ) { |
81 | 81 | exit( 'Required options missing: ' . implode( ', ', $missingOpts ) ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * @param array $opts |
93 | 93 | */ |
94 | - private function checkConflictingOpts( array $opts ) : void { |
|
94 | + private function checkConflictingOpts ( array $opts ) : void { |
|
95 | 95 | $hasPw = array_key_exists( 'password', $opts ); |
96 | 96 | $hasPwFile = array_key_exists( 'use-password-file', $opts ); |
97 | 97 | if ( $hasPw && $hasPwFile ) { |
@@ -108,11 +108,11 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * @param array &$opts |
110 | 110 | */ |
111 | - private function canonicalize( array &$opts ) : void { |
|
111 | + private function canonicalize ( array &$opts ) : void { |
|
112 | 112 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
113 | 113 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
114 | - $opts['password'] = $pw; |
|
115 | - unset( $opts['use-password-file'] ); |
|
114 | + $opts[ 'password' ] = $pw; |
|
115 | + unset( $opts[ 'use-password-file' ] ); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | * These are the options required by Config. |
121 | 121 | * @return array |
122 | 122 | */ |
123 | - public function getMainOpts() : array { |
|
123 | + public function getMainOpts () : array { |
|
124 | 124 | return array_intersect_key( |
125 | 125 | $this->opts, |
126 | 126 | array_fill_keys( Config::REQUIRED_OPTS, true ) |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | * @param mixed|null $default |
133 | 133 | * @return mixed |
134 | 134 | */ |
135 | - public function getOpt( string $opt, $default = null ) { |
|
136 | - return $this->opts[$opt] ?? $default; |
|
135 | + public function getOpt ( string $opt, $default = null ) { |
|
136 | + return $this->opts[ $opt ] ?? $default; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | 140 | * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ] |
141 | 141 | */ |
142 | - public function getTaskOpt() : array { |
|
142 | + public function getTaskOpt () : array { |
|
143 | 143 | return array_intersect_key( |
144 | 144 | $this->opts, |
145 | 145 | [ 'task' => true, 'subtask' => true ] |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @return string|null |
151 | 151 | */ |
152 | - public function getURL() : ?string { |
|
152 | + public function getURL () : ?string { |
|
153 | 153 | return $this->getOpt( 'force-url' ); |
154 | 154 | } |
155 | 155 | } |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Exception; |
4 | 4 |
@@ -1,4 +1,4 @@ discard block |
||
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 |
||
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 |
||
18 | 18 | ]; |
19 | 19 | $url = $this->url; |
20 | 20 | if ( $this->method === self::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 |
||
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 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Request; |
4 | 4 | |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | /** @var string */ |
34 | 34 | protected $method = self::METHOD_GET; |
35 | 35 | /** @var string[] */ |
36 | - protected $newCookies = []; |
|
36 | + protected $newCookies = [ ]; |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Use self::newFromParams, which will provide the right class to use |
40 | 40 | * |
41 | 41 | * @param array $params |
42 | 42 | */ |
43 | - protected function __construct( array $params ) { |
|
43 | + protected function __construct ( array $params ) { |
|
44 | 44 | $this->params = [ 'format' => 'json' ] + $params; |
45 | 45 | $this->url = DEFAULT_URL; |
46 | 46 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param array $params |
52 | 52 | * @return self |
53 | 53 | */ |
54 | - public static function newFromParams( array $params ) : self { |
|
54 | + public static function newFromParams ( array $params ) : self { |
|
55 | 55 | if ( extension_loaded( 'curl' ) ) { |
56 | 56 | $ret = new CurlRequest( $params ); |
57 | 57 | } else { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * |
66 | 66 | * @return self For chaining |
67 | 67 | */ |
68 | - public function setPost() : self { |
|
68 | + public function setPost () : self { |
|
69 | 69 | $this->method = self::METHOD_POST; |
70 | 70 | return $this; |
71 | 71 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param string $url |
77 | 77 | * @return self for chaining |
78 | 78 | */ |
79 | - public function setUrl( string $url ) : self { |
|
79 | + public function setUrl ( string $url ) : self { |
|
80 | 80 | $this->url = $url; |
81 | 81 | return $this; |
82 | 82 | } |
@@ -88,14 +88,14 @@ discard block |
||
88 | 88 | * @todo Return an iterable object which automatically continues the query only if the last |
89 | 89 | * entry available is reached. |
90 | 90 | */ |
91 | - public function execute() : \stdClass { |
|
91 | + public function execute () : \stdClass { |
|
92 | 92 | $curParams = $this->params; |
93 | - $sets = []; |
|
93 | + $sets = [ ]; |
|
94 | 94 | do { |
95 | 95 | $res = $this->makeRequestInternal( $curParams ); |
96 | 96 | |
97 | 97 | $this->handleErrorAndWarnings( $res ); |
98 | - $sets[] = $res; |
|
98 | + $sets[ ] = $res; |
|
99 | 99 | |
100 | 100 | $finished = true; |
101 | 101 | if ( isset( $res->continue ) ) { |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | * @param array $params |
114 | 114 | * @return \stdClass |
115 | 115 | */ |
116 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
116 | + private function makeRequestInternal ( array $params ) : \stdClass { |
|
117 | 117 | if ( $this->method === self::METHOD_POST ) { |
118 | - $params['maxlag'] = self::MAXLAG; |
|
118 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
119 | 119 | } |
120 | 120 | $query = http_build_query( $params ); |
121 | 121 | |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | * @param string $params |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
134 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * After a request, set cookies for the next ones |
138 | 138 | * |
139 | 139 | * @param array $cookies |
140 | 140 | */ |
141 | - protected function setCookies( array $cookies ) : void { |
|
141 | + protected function setCookies ( array $cookies ) : void { |
|
142 | 142 | foreach ( $cookies as $cookie ) { |
143 | 143 | $bits = explode( ';', $cookie ); |
144 | - [ $name, $value ] = explode( '=', $bits[0] ); |
|
144 | + [ $name, $value ] = explode( '=', $bits[ 0 ] ); |
|
145 | 145 | self::$cookiesToSet[ $name ] = $value; |
146 | 146 | } |
147 | 147 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param \stdClass $res |
153 | 153 | * @return APIRequestException |
154 | 154 | */ |
155 | - private function getException( \stdClass $res ) : APIRequestException { |
|
155 | + private function getException ( \stdClass $res ) : APIRequestException { |
|
156 | 156 | switch ( $res->error->code ) { |
157 | 157 | case 'missingtitle': |
158 | 158 | $ex = new MissingPageException; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @param \stdClass $res |
176 | 176 | * @throws APIRequestException |
177 | 177 | */ |
178 | - protected function handleErrorAndWarnings( \stdClass $res ) : void { |
|
178 | + protected function handleErrorAndWarnings ( \stdClass $res ) : void { |
|
179 | 179 | if ( isset( $res->error ) ) { |
180 | 180 | throw $this->getException( $res ); |
181 | 181 | } elseif ( isset( $res->warnings ) ) { |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param \stdClass[] $sets |
192 | 192 | * @return \stdClass |
193 | 193 | */ |
194 | - private function mergeSets( array $sets ) : \stdClass { |
|
194 | + private function mergeSets ( array $sets ) : \stdClass { |
|
195 | 195 | // Use the first set as template |
196 | 196 | $ret = array_shift( $sets ); |
197 | 197 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param array|\stdClass $second |
209 | 209 | * @return array|\stdClass array |
210 | 210 | */ |
211 | - private function recursiveMerge( $first, $second ) { |
|
211 | + private function recursiveMerge ( $first, $second ) { |
|
212 | 212 | $ret = $first; |
213 | 213 | if ( is_array( $second ) ) { |
214 | 214 | $ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second; |
@@ -226,14 +226,14 @@ discard block |
||
226 | 226 | * |
227 | 227 | * @return array |
228 | 228 | */ |
229 | - protected function getHeaders() :array { |
|
229 | + protected function getHeaders () :array { |
|
230 | 230 | $ret = self::HEADERS; |
231 | 231 | if ( self::$cookiesToSet ) { |
232 | - $cookies = []; |
|
232 | + $cookies = [ ]; |
|
233 | 233 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
234 | - $cookies[] = trim( "$cname=$cval" ); |
|
234 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
235 | 235 | } |
236 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
236 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
237 | 237 | } |
238 | 238 | return $ret; |
239 | 239 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @param array $headers |
245 | 245 | * @return string |
246 | 246 | */ |
247 | - protected function buildHeadersString( array $headers ) : string { |
|
247 | + protected function buildHeadersString ( array $headers ) : string { |
|
248 | 248 | $ret = ''; |
249 | 249 | foreach ( $headers as $header ) { |
250 | 250 | $ret .= "$header\r\n"; |
@@ -1,4 +1,4 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |