@@ -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 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param MessageProvider $mp |
38 | 38 | * @param PageBotList $pbl |
39 | 39 | */ |
40 | - public function __construct( |
|
40 | + public function __construct ( |
|
41 | 41 | LoggerInterface $logger, |
42 | 42 | WikiGroup $wikiGroup, |
43 | 43 | MessageProvider $mp, |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @return LoggerInterface |
55 | 55 | */ |
56 | - protected function getLogger(): LoggerInterface { |
|
56 | + protected function getLogger (): LoggerInterface { |
|
57 | 57 | return $this->logger; |
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * @inheritDoc |
62 | 62 | */ |
63 | - public function setLogger( LoggerInterface $logger ): void { |
|
63 | + public function setLogger ( LoggerInterface $logger ): void { |
|
64 | 64 | $this->logger = $logger; |
65 | 65 | } |
66 | 66 | |
@@ -70,21 +70,21 @@ discard block |
||
70 | 70 | * @param string $optname |
71 | 71 | * @return mixed |
72 | 72 | */ |
73 | - protected function getOpt( string $optname ) { |
|
73 | + protected function getOpt ( string $optname ) { |
|
74 | 74 | return $this->getConfig()->get( $optname ); |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return Config |
79 | 79 | */ |
80 | - protected function getConfig(): Config { |
|
80 | + protected function getConfig (): Config { |
|
81 | 81 | return $this->config; |
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @param Config $cfg |
86 | 86 | */ |
87 | - protected function setConfig( Config $cfg ): void { |
|
87 | + protected function setConfig ( Config $cfg ): void { |
|
88 | 88 | $this->config = $cfg; |
89 | 89 | } |
90 | 90 | |
@@ -92,35 +92,35 @@ discard block |
||
92 | 92 | * Shorthand |
93 | 93 | * @return Wiki |
94 | 94 | */ |
95 | - protected function getWiki(): Wiki { |
|
95 | + protected function getWiki (): Wiki { |
|
96 | 96 | return $this->getWikiGroup()->getMainWiki(); |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
100 | 100 | * @return WikiGroup |
101 | 101 | */ |
102 | - protected function getWikiGroup(): WikiGroup { |
|
102 | + protected function getWikiGroup (): WikiGroup { |
|
103 | 103 | return $this->wikiGroup; |
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @param WikiGroup $wikiGroup |
108 | 108 | */ |
109 | - protected function setWikiGroup( WikiGroup $wikiGroup ): void { |
|
109 | + protected function setWikiGroup ( WikiGroup $wikiGroup ): void { |
|
110 | 110 | $this->wikiGroup = $wikiGroup; |
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
114 | 114 | * @return MessageProvider |
115 | 115 | */ |
116 | - protected function getMessageProvider(): MessageProvider { |
|
116 | + protected function getMessageProvider (): MessageProvider { |
|
117 | 117 | return $this->messageProvider; |
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
121 | 121 | * @param MessageProvider $mp |
122 | 122 | */ |
123 | - protected function setMessageProvider( MessageProvider $mp ): void { |
|
123 | + protected function setMessageProvider ( MessageProvider $mp ): void { |
|
124 | 124 | $this->messageProvider = $mp; |
125 | 125 | } |
126 | 126 | |
@@ -130,21 +130,21 @@ discard block |
||
130 | 130 | * @param string $key |
131 | 131 | * @return Message |
132 | 132 | */ |
133 | - protected function msg( string $key ): Message { |
|
133 | + protected function msg ( string $key ): Message { |
|
134 | 134 | return $this->messageProvider->getMessage( $key ); |
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @return PageBotList |
139 | 139 | */ |
140 | - public function getBotList(): PageBotList { |
|
140 | + public function getBotList (): PageBotList { |
|
141 | 141 | return $this->pageBotList; |
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
145 | 145 | * @return RequestFactory |
146 | 146 | */ |
147 | - public function getRequestFactory(): RequestFactory { |
|
147 | + public function getRequestFactory (): RequestFactory { |
|
148 | 148 | return $this->getWiki()->getRequestFactory(); |
149 | 149 | } |
150 | 150 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param string $title |
155 | 155 | * @return Page |
156 | 156 | */ |
157 | - protected function getPage( string $title ): Page { |
|
157 | + protected function getPage ( string $title ): Page { |
|
158 | 158 | return new Page( $title, $this->getWiki() ); |
159 | 159 | } |
160 | 160 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @param string $name |
165 | 165 | * @return User |
166 | 166 | */ |
167 | - protected function getUser( string $name ): User { |
|
167 | + protected function getUser ( string $name ): User { |
|
168 | 168 | $ui = $this->getBotList()->getUserInfo( $name ); |
169 | 169 | return new User( $ui, $this->getWiki() ); |
170 | 170 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Message; |
4 | 4 | |
@@ -23,7 +23,7 @@ discard block |
||
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 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @phan-param array<string,int|string> $args |
33 | 33 | * @return self |
34 | 34 | */ |
35 | - public function params( array $args ): self { |
|
35 | + public function params ( array $args ): self { |
|
36 | 36 | $this->value = strtr( $this->value, $args ); |
37 | 37 | return $this; |
38 | 38 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | /** |
41 | 41 | * @return string |
42 | 42 | */ |
43 | - public function text(): string { |
|
43 | + public function text (): string { |
|
44 | 44 | $this->parsePlurals(); |
45 | 45 | return $this->value; |
46 | 46 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * Replace {{$plur|<amount>|sing|plur}} |
50 | 50 | */ |
51 | - protected function parsePlurals(): void { |
|
51 | + protected function parsePlurals (): void { |
|
52 | 52 | $reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!'; |
53 | 53 | |
54 | 54 | if ( preg_match( $reg, $this->value ) === 0 ) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @return string |
62 | 62 | */ |
63 | 63 | static function ( array $matches ): string { |
64 | - return (int)$matches['amount'] > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
64 | + return (int)$matches[ 'amount' ] > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
65 | 65 | }, |
66 | 66 | $this->value |
67 | 67 | ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param string $timeString Full format, e.g. "15 aprile 2019 18:27" |
74 | 74 | * @return int |
75 | 75 | */ |
76 | - public static function getTimestampFromLocalTime( string $timeString ): int { |
|
76 | + public static function getTimestampFromLocalTime ( string $timeString ): int { |
|
77 | 77 | $englishTime = str_ireplace( |
78 | 78 | array_values( self::MONTHS ), |
79 | 79 | array_keys( self::MONTHS ), |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | * @param string $emptyText |
93 | 93 | * @return string |
94 | 94 | */ |
95 | - public static function commaList( array $data, string $emptyText = 'nessuno' ): string { |
|
95 | + public static function commaList ( array $data, string $emptyText = 'nessuno' ): string { |
|
96 | 96 | if ( count( $data ) > 1 ) { |
97 | 97 | $last = array_pop( $data ); |
98 | 98 | $ret = implode( ', ', $data ) . " e $last"; |
99 | 99 | } elseif ( $data ) { |
100 | - $ret = (string)$data[0]; |
|
100 | + $ret = (string)$data[ 0 ]; |
|
101 | 101 | } else { |
102 | 102 | $ret = $emptyText; |
103 | 103 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | return $ret; |
106 | 106 | } |
107 | 107 | |
108 | - public function __toString(): string { |
|
108 | + public function __toString (): string { |
|
109 | 109 | return $this->text(); |
110 | 110 | } |
111 | 111 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Utils; |
4 | 4 | |
@@ -9,5 +9,5 @@ discard block |
||
9 | 9 | * @param string $delimiter |
10 | 10 | * @return string |
11 | 11 | */ |
12 | - public function getRegex( string $delimiter ): string; |
|
12 | + public function getRegex ( string $delimiter ): string; |
|
13 | 13 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Utils; |
4 | 4 | |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | * @param IRegexable ...$elements |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public static function regexFromArray( |
|
13 | + public static function regexFromArray ( |
|
14 | 14 | string $delimiter = '/', |
15 | 15 | IRegexable ...$elements |
16 | 16 | ): string { |
17 | - $bits = []; |
|
17 | + $bits = [ ]; |
|
18 | 18 | foreach ( $elements as $el ) { |
19 | - $bits[] = $el->getRegex( $delimiter ); |
|
19 | + $bits[ ] = $el->getRegex( $delimiter ); |
|
20 | 20 | } |
21 | 21 | return '(?:' . implode( '|', $bits ) . ')'; |
22 | 22 | } |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @param LoggerInterface $logger |
15 | 15 | * @param string $domain |
16 | 16 | */ |
17 | - public function __construct( LoggerInterface $logger, string $domain ) { |
|
17 | + public function __construct ( LoggerInterface $logger, string $domain ) { |
|
18 | 18 | $this->logger = $logger; |
19 | 19 | $this->domain = $domain; |
20 | 20 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @phan-param array<int|string|bool> $params |
25 | 25 | * @return RequestBase |
26 | 26 | */ |
27 | - public function newFromParams( array $params ): RequestBase { |
|
27 | + public function newFromParams ( array $params ): RequestBase { |
|
28 | 28 | if ( extension_loaded( 'curl' ) ) { |
29 | 29 | return new CurlRequest( $this->logger, $params, $this->domain ); |
30 | 30 | } |
@@ -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 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | foreach ( $http_response_header as $header ) { |
29 | 29 | /** @var string[] $bits */ |
30 | 30 | $bits = explode( ':', $header, 2 ); |
31 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
32 | - $this->newCookies[] = $bits[1]; |
|
31 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
32 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @inheritDoc |
14 | 14 | * @throws APIRequestException |
15 | 15 | */ |
16 | - protected function reallyMakeRequest( string $params ): string { |
|
16 | + protected function reallyMakeRequest ( string $params ): string { |
|
17 | 17 | $curl = curl_init(); |
18 | 18 | if ( $curl === false ) { |
19 | 19 | throw new APIRequestException( 'Cannot open cURL handler.' ); |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * @internal Only used as CB for cURL (CURLOPT_HEADERFUNCTION) |
60 | 60 | * @suppress PhanUnreferencedPublicMethod,PhanUnusedPublicNoOverrideMethodParameter |
61 | 61 | */ |
62 | - public function headersHandler( $ch, string $header ): int { |
|
62 | + public function headersHandler ( $ch, string $header ): int { |
|
63 | 63 | /** @var string[] $bits */ |
64 | 64 | $bits = explode( ':', $header, 2 ); |
65 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
66 | - $this->newCookies[] = $bits[1]; |
|
65 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
66 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | return strlen( $header ); |
@@ -1,4 +1,4 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Wiki; |
4 | 4 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param Wiki $centralWiki |
19 | 19 | * @param Wiki $privateWiki |
20 | 20 | */ |
21 | - public function __construct( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) { |
|
21 | + public function __construct ( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) { |
|
22 | 22 | $this->mainWiki = $mainWiki; |
23 | 23 | $this->centralWiki = $centralWiki; |
24 | 24 | $this->privateWiki = $privateWiki; |
@@ -27,21 +27,21 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @return Wiki |
29 | 29 | */ |
30 | - public function getMainWiki(): Wiki { |
|
30 | + public function getMainWiki (): Wiki { |
|
31 | 31 | return $this->mainWiki; |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @return Wiki |
36 | 36 | */ |
37 | - public function getCentralWiki(): Wiki { |
|
37 | + public function getCentralWiki (): Wiki { |
|
38 | 38 | return $this->centralWiki; |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return Wiki |
43 | 43 | */ |
44 | - public function getPrivateWiki(): Wiki { |
|
44 | + public function getPrivateWiki (): Wiki { |
|
45 | 45 | return $this->privateWiki; |
46 | 46 | } |
47 | 47 | } |