@@ -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 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | /** @var string */ |
| 42 | 42 | protected $method = self::METHOD_GET; |
| 43 | 43 | /** @var string[] */ |
| 44 | - protected $newCookies = []; |
|
| 44 | + protected $newCookies = [ ]; |
|
| 45 | 45 | |
| 46 | 46 | /** @var LoggerInterface */ |
| 47 | 47 | protected $logger; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @phan-param array<int|string|bool> $params |
| 55 | 55 | * @param string $domain |
| 56 | 56 | */ |
| 57 | - public function __construct( LoggerInterface $logger, array $params, string $domain ) { |
|
| 57 | + public function __construct ( LoggerInterface $logger, array $params, string $domain ) { |
|
| 58 | 58 | $this->logger = $logger; |
| 59 | 59 | $this->params = [ 'format' => 'json' ] + $params; |
| 60 | 60 | $this->url = $domain; |
@@ -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 | } |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | * Execute a query request |
| 75 | 75 | * @return Generator |
| 76 | 76 | */ |
| 77 | - public function executeAsQuery() : Generator { |
|
| 78 | - if ( ( $this->params['action'] ?? false ) !== 'query' ) { |
|
| 77 | + public function executeAsQuery () : Generator { |
|
| 78 | + if ( ( $this->params[ 'action' ] ?? false ) !== 'query' ) { |
|
| 79 | 79 | throw new BadMethodCallException( 'Not an ApiQuery!' ); |
| 80 | 80 | } |
| 81 | 81 | // TODO Is this always correct? |
| 82 | - $key = $this->params['list'] ?? 'pages'; |
|
| 82 | + $key = $this->params[ 'list' ] ?? 'pages'; |
|
| 83 | 83 | $curParams = $this->params; |
| 84 | 84 | $lim = $this->parseLimit(); |
| 85 | 85 | do { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * Execute a request that doesn't need any continuation. |
| 109 | 109 | * @return stdClass |
| 110 | 110 | */ |
| 111 | - public function executeSingle() : stdClass { |
|
| 111 | + public function executeSingle () : stdClass { |
|
| 112 | 112 | $curParams = $this->params; |
| 113 | 113 | $res = $this->makeRequestInternal( $curParams ); |
| 114 | 114 | $this->handleErrorAndWarnings( $res ); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | /** |
| 119 | 119 | * @return int |
| 120 | 120 | */ |
| 121 | - private function parseLimit() : int { |
|
| 121 | + private function parseLimit () : int { |
|
| 122 | 122 | foreach ( $this->params as $name => $val ) { |
| 123 | 123 | if ( substr( $name, -strlen( 'limit' ) ) === 'limit' ) { |
| 124 | 124 | return $val === 'max' ? -1 : (int)$val; |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param string $resKey |
| 136 | 136 | * @return int|null |
| 137 | 137 | */ |
| 138 | - private function countQueryResults( stdClass $res, string $resKey ) : ?int { |
|
| 138 | + private function countQueryResults ( stdClass $res, string $resKey ) : ?int { |
|
| 139 | 139 | if ( !isset( $res->query->$resKey ) ) { |
| 140 | 140 | return null; |
| 141 | 141 | } |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | * @phan-param array<int|string|bool> $params |
| 164 | 164 | * @return stdClass |
| 165 | 165 | */ |
| 166 | - private function makeRequestInternal( array $params ) : stdClass { |
|
| 166 | + private function makeRequestInternal ( array $params ) : stdClass { |
|
| 167 | 167 | if ( $this->method === self::METHOD_POST ) { |
| 168 | - $params['maxlag'] = self::MAXLAG; |
|
| 168 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
| 169 | 169 | } |
| 170 | 170 | $query = http_build_query( $params ); |
| 171 | 171 | |
@@ -186,18 +186,18 @@ discard block |
||
| 186 | 186 | * @param string $params |
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
| 189 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
| 190 | 190 | |
| 191 | 191 | /** |
| 192 | 192 | * After a request, set cookies for the next ones |
| 193 | 193 | * |
| 194 | 194 | * @param string[] $cookies |
| 195 | 195 | */ |
| 196 | - protected function setCookies( array $cookies ) : void { |
|
| 196 | + protected function setCookies ( array $cookies ) : void { |
|
| 197 | 197 | foreach ( $cookies as $cookie ) { |
| 198 | 198 | /** @var string[] $bits */ |
| 199 | 199 | $bits = explode( ';', $cookie ); |
| 200 | - [ $name, $value ] = explode( '=', $bits[0] ); |
|
| 200 | + [ $name, $value ] = explode( '=', $bits[ 0 ] ); |
|
| 201 | 201 | self::$cookiesToSet[ $name ] = $value; |
| 202 | 202 | } |
| 203 | 203 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * @param stdClass $res |
| 209 | 209 | * @return APIRequestException |
| 210 | 210 | */ |
| 211 | - private function getException( stdClass $res ) : APIRequestException { |
|
| 211 | + private function getException ( stdClass $res ) : APIRequestException { |
|
| 212 | 212 | switch ( $res->error->code ) { |
| 213 | 213 | case 'missingtitle': |
| 214 | 214 | $ex = new MissingPageException; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @param stdClass $res |
| 235 | 235 | * @throws APIRequestException |
| 236 | 236 | */ |
| 237 | - protected function handleErrorAndWarnings( stdClass $res ) : void { |
|
| 237 | + protected function handleErrorAndWarnings ( stdClass $res ) : void { |
|
| 238 | 238 | if ( isset( $res->error ) ) { |
| 239 | 239 | throw $this->getException( $res ); |
| 240 | 240 | } |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return string[] |
| 252 | 252 | */ |
| 253 | - protected function getHeaders() : array { |
|
| 253 | + protected function getHeaders () : array { |
|
| 254 | 254 | $ret = self::HEADERS; |
| 255 | 255 | if ( self::$cookiesToSet ) { |
| 256 | - $cookies = []; |
|
| 256 | + $cookies = [ ]; |
|
| 257 | 257 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
| 258 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 258 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
| 259 | 259 | } |
| 260 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 260 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 261 | 261 | } |
| 262 | 262 | return $ret; |
| 263 | 263 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | * @param string[] $headers |
| 269 | 269 | * @return string |
| 270 | 270 | */ |
| 271 | - protected function buildHeadersString( array $headers ) : string { |
|
| 271 | + protected function buildHeadersString ( array $headers ) : string { |
|
| 272 | 272 | $ret = ''; |
| 273 | 273 | foreach ( $headers as $header ) { |
| 274 | 274 | $ret .= "$header\r\n"; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param string $actualParams |
| 281 | 281 | * @return string |
| 282 | 282 | */ |
| 283 | - protected function getDebugURL( string $actualParams ) : string { |
|
| 283 | + protected function getDebugURL ( string $actualParams ) : string { |
|
| 284 | 284 | return strpos( $this->url, 'login' ) !== false |
| 285 | 285 | ? '[Login request]' |
| 286 | 286 | : "{$this->url}?$actualParams"; |
@@ -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\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\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; |
| 4 | 4 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param MessageProvider $mp |
| 73 | 73 | * @param PageBotList $pbl |
| 74 | 74 | */ |
| 75 | - public function __construct( |
|
| 75 | + public function __construct ( |
|
| 76 | 76 | LoggerInterface $logger, |
| 77 | 77 | WikiGroup $wikiGroup, |
| 78 | 78 | MessageProvider $mp, |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * @param string[] $tasks Only used in MODE_TASK and MODE_SUBTASK |
| 98 | 98 | * @return TaskResult |
| 99 | 99 | */ |
| 100 | - public function run( string $mode, array $tasks = [] ) : TaskResult { |
|
| 100 | + public function run ( string $mode, array $tasks = [ ] ) : TaskResult { |
|
| 101 | 101 | if ( $mode === self::MODE_COMPLETE ) { |
| 102 | 102 | $tasks = self::FULL_RUN_ORDERED; |
| 103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param string[] $tasks |
| 114 | 114 | * @return TaskResult |
| 115 | 115 | */ |
| 116 | - private function runTasks( array $tasks ) : TaskResult { |
|
| 116 | + private function runTasks ( array $tasks ) : TaskResult { |
|
| 117 | 117 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
| 118 | 118 | do { |
| 119 | 119 | $res->merge( $this->runTask( current( $tasks ) ) ); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $name |
| 129 | 129 | * @return TaskResult |
| 130 | 130 | */ |
| 131 | - protected function runTask( string $name ) : TaskResult { |
|
| 131 | + protected function runTask ( string $name ) : TaskResult { |
|
| 132 | 132 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 133 | 133 | throw new InvalidArgumentException( "'$name' is not a valid task." ); |
| 134 | 134 | } |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string[] $subtasks |
| 143 | 143 | * @return TaskResult |
| 144 | 144 | */ |
| 145 | - private function runSubtasks( array $subtasks ) : TaskResult { |
|
| 145 | + private function runSubtasks ( array $subtasks ) : TaskResult { |
|
| 146 | 146 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
| 147 | 147 | do { |
| 148 | 148 | $res->merge( $this->runSubtask( current( $subtasks ) ) ); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $name |
| 158 | 158 | * @return TaskResult |
| 159 | 159 | */ |
| 160 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 160 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 161 | 161 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 162 | 162 | throw new InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 163 | 163 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param string $name |
| 173 | 173 | * @return Task |
| 174 | 174 | */ |
| 175 | - private function getTaskInstance( string $name ) : Task { |
|
| 175 | + private function getTaskInstance ( string $name ) : Task { |
|
| 176 | 176 | $class = self::TASKS_MAP[ $name ]; |
| 177 | 177 | return new $class( |
| 178 | 178 | $this->logger, |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param string $class |
| 190 | 190 | * @return Subtask |
| 191 | 191 | */ |
| 192 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 192 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 193 | 193 | return new $class( |
| 194 | 194 | $this->logger, |
| 195 | 195 | $this->wikiGroup, |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task\Subtask; |
| 4 | 4 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @inheritDoc |
| 18 | 18 | */ |
| 19 | - public function runInternal() : int { |
|
| 19 | + public function runInternal () : int { |
|
| 20 | 20 | $failed = $this->getFailures(); |
| 21 | 21 | if ( !$failed ) { |
| 22 | 22 | return TaskResult::STATUS_NOTHING; |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return PageRiconferma[] |
| 43 | 43 | */ |
| 44 | - private function getFailures() : array { |
|
| 45 | - $ret = []; |
|
| 44 | + private function getFailures () : array { |
|
| 45 | + $ret = [ ]; |
|
| 46 | 46 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 47 | 47 | foreach ( $allPages as $page ) { |
| 48 | 48 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 49 | - $ret[] = $page; |
|
| 49 | + $ret[ ] = $page; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | return $ret; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @param User[] $users |
| 57 | 57 | */ |
| 58 | - protected function updateBurList( array $users ) : void { |
|
| 58 | + protected function updateBurList ( array $users ) : void { |
|
| 59 | 59 | $this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) ); |
| 60 | 60 | $remList = RegexUtils::regexFromArray( '!', ...$users ); |
| 61 | 61 | $burList = $this->getPage( $this->getOpt( 'bur-list-title' ) ); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * |
| 79 | 79 | * @param PageRiconferma[] $pages |
| 80 | 80 | */ |
| 81 | - protected function requestRemoval( array $pages ) : void { |
|
| 81 | + protected function requestRemoval ( array $pages ) : void { |
|
| 82 | 82 | $this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) ); |
| 83 | 83 | |
| 84 | 84 | $metaWiki = $this->getWikiGroup()->getCentralWiki(); |
@@ -115,21 +115,21 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @param PageRiconferma[] $pages |
| 117 | 117 | */ |
| 118 | - protected function updateAnnunci( array $pages ) : void { |
|
| 118 | + protected function updateAnnunci ( array $pages ) : void { |
|
| 119 | 119 | $this->getLogger()->info( 'Updating annunci' ); |
| 120 | 120 | $section = 1; |
| 121 | 121 | |
| 122 | - $names = []; |
|
| 122 | + $names = [ ]; |
|
| 123 | 123 | $text = ''; |
| 124 | 124 | foreach ( $pages as $page ) { |
| 125 | 125 | $user = $page->getUserName(); |
| 126 | - $names[] = $user; |
|
| 126 | + $names[ ] = $user; |
|
| 127 | 127 | $text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text(); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | /** @var string $curMonth */ |
| 131 | 131 | $curMonth = date( 'F' ); |
| 132 | - $month = ucfirst( Message::MONTHS[$curMonth] ); |
|
| 132 | + $month = ucfirst( Message::MONTHS[ $curMonth ] ); |
|
| 133 | 133 | |
| 134 | 134 | $annunciPage = $this->getPage( $this->getOpt( 'annunci-page-title' ) ); |
| 135 | 135 | $content = $annunciPage->getContent( $section ); |
@@ -157,16 +157,16 @@ discard block |
||
| 157 | 157 | * |
| 158 | 158 | * @param PageRiconferma[] $pages |
| 159 | 159 | */ |
| 160 | - protected function updateUltimeNotizie( array $pages ) : void { |
|
| 160 | + protected function updateUltimeNotizie ( array $pages ) : void { |
|
| 161 | 161 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 162 | 162 | $notiziePage = $this->getPage( $this->getOpt( 'ultimenotizie-page-title' ) ); |
| 163 | 163 | |
| 164 | - $names = []; |
|
| 164 | + $names = [ ]; |
|
| 165 | 165 | $text = ''; |
| 166 | 166 | $msg = $this->msg( 'ultimenotizie-text' ); |
| 167 | 167 | foreach ( $pages as $page ) { |
| 168 | 168 | $user = $page->getUserName(); |
| 169 | - $names[] = $user; |
|
| 169 | + $names[ ] = $user; |
|
| 170 | 170 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @param PageRiconferma[] $pages |
| 196 | 196 | */ |
| 197 | - protected function updateTimeline( array $pages ) : void { |
|
| 197 | + protected function updateTimeline ( array $pages ) : void { |
|
| 198 | 198 | $this->getLogger()->info( 'Updating timeline' ); |
| 199 | 199 | $timelinePage = $this->getPage( $this->getOpt( 'timeline-page-title' ) ); |
| 200 | 200 | $content = $timelinePage->getContent(); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | * |
| 223 | 223 | * @param PageRiconferma[] $pages |
| 224 | 224 | */ |
| 225 | - private function updateCronologia( array $pages ) : void { |
|
| 225 | + private function updateCronologia ( array $pages ) : void { |
|
| 226 | 226 | $this->getLogger()->info( 'Updating cronologia' ); |
| 227 | 227 | $timelinePage = $this->getPage( $this->getOpt( 'cronologia-page-title' ) ); |
| 228 | 228 | $content = $timelinePage->getContent(); |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @param PageRiconferma[] $pages |
| 251 | 251 | */ |
| 252 | - private function blockOnPrivate( array $pages ) : void { |
|
| 252 | + private function blockOnPrivate ( array $pages ) : void { |
|
| 253 | 253 | $this->getLogger()->info( 'Blocking on private wiki: ' . implode( ', ', $pages ) ); |
| 254 | 254 | |
| 255 | 255 | $privWiki = $this->getWikiGroup()->getPrivateWiki(); |
@@ -266,12 +266,12 @@ discard block |
||
| 266 | 266 | * @param PageRiconferma[] $pages |
| 267 | 267 | * @return User[] |
| 268 | 268 | */ |
| 269 | - private function getFailedBureaucrats( array $pages ) : array { |
|
| 270 | - $ret = []; |
|
| 269 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
| 270 | + $ret = [ ]; |
|
| 271 | 271 | foreach ( $pages as $page ) { |
| 272 | 272 | $user = $this->getUser( $page->getUserName() ); |
| 273 | 273 | if ( $user->inGroup( 'bureaucrat' ) ) { |
| 274 | - $ret[] = $user; |
|
| 274 | + $ret[ ] = $user; |
|
| 275 | 275 | } |
| 276 | 276 | } |
| 277 | 277 | return $ret; |
@@ -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 | |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | /** |
| 67 | 67 | * @return bool |
| 68 | 68 | */ |
| 69 | - public static function isCLI() : bool { |
|
| 69 | + public static function isCLI () : bool { |
|
| 70 | 70 | return PHP_SAPI === 'cli'; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * Populate options and check for required ones |
| 75 | 75 | */ |
| 76 | - public function __construct() { |
|
| 76 | + public function __construct () { |
|
| 77 | 77 | /** @var string[] $opts */ |
| 78 | 78 | $opts = getopt( self::SHORT_OPTS, self::LONG_OPTS ); |
| 79 | 79 | $this->checkRequiredOpts( $opts ); |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @param string[] $opts |
| 87 | 87 | */ |
| 88 | - private function checkRequiredOpts( array $opts ) : void { |
|
| 88 | + private function checkRequiredOpts ( array $opts ) : void { |
|
| 89 | 89 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
| 90 | 90 | if ( $missingOpts ) { |
| 91 | 91 | $this->fatal( 'Required options missing: ' . implode( ', ', $missingOpts ) ); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | /** |
| 108 | 108 | * @param string[] $opts |
| 109 | 109 | */ |
| 110 | - private function checkConflictingOpts( array $opts ) : void { |
|
| 110 | + private function checkConflictingOpts ( array $opts ) : void { |
|
| 111 | 111 | $this->checkNotBothSet( $opts, 'password', 'use-password-file' ); |
| 112 | 112 | if ( array_key_exists( 'use-password-file', $opts ) && !file_exists( self::PASSWORD_FILE ) ) { |
| 113 | 113 | $this->fatal( 'Please create the password file (' . self::PASSWORD_FILE . ')' ); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $first |
| 129 | 129 | * @param string $second |
| 130 | 130 | */ |
| 131 | - private function checkNotBothSet( array $opts, string $first, string $second ) : void { |
|
| 131 | + private function checkNotBothSet ( array $opts, string $first, string $second ) : void { |
|
| 132 | 132 | if ( array_key_exists( $first, $opts ) && array_key_exists( $second, $opts ) ) { |
| 133 | 133 | $this->fatal( "Can only use one of '$first' and '$second'" ); |
| 134 | 134 | } |
@@ -137,23 +137,23 @@ discard block |
||
| 137 | 137 | /** |
| 138 | 138 | * @param string[] &$opts |
| 139 | 139 | */ |
| 140 | - private function canonicalize( array &$opts ) : void { |
|
| 140 | + private function canonicalize ( array &$opts ) : void { |
|
| 141 | 141 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
| 142 | 142 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
| 143 | - $opts['password'] = $pw; |
|
| 144 | - unset( $opts['use-password-file'] ); |
|
| 143 | + $opts[ 'password' ] = $pw; |
|
| 144 | + unset( $opts[ 'use-password-file' ] ); |
|
| 145 | 145 | } |
| 146 | 146 | if ( array_key_exists( 'use-private-password-file', $opts ) ) { |
| 147 | 147 | $pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) ); |
| 148 | - $opts['private-password'] = $pw; |
|
| 149 | - unset( $opts['use-private-password-file'] ); |
|
| 148 | + $opts[ 'private-password' ] = $pw; |
|
| 149 | + unset( $opts[ 'use-private-password-file' ] ); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | 154 | * @param string $msg |
| 155 | 155 | */ |
| 156 | - private function fatal( string $msg ) : void { |
|
| 156 | + private function fatal ( string $msg ) : void { |
|
| 157 | 157 | exit( $msg . "\n" ); |
| 158 | 158 | } |
| 159 | 159 | |
@@ -162,14 +162,14 @@ discard block |
||
| 162 | 162 | * @param mixed|null $default |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - public function getOpt( string $opt, $default = null ) : string { |
|
| 166 | - return $this->opts[$opt] ?? $default; |
|
| 165 | + public function getOpt ( string $opt, $default = null ) : string { |
|
| 166 | + return $this->opts[ $opt ] ?? $default; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | 170 | * @return string[] Either [ 'tasks' => name1,... ] or [ 'subtasks' => name1,... ] |
| 171 | 171 | */ |
| 172 | - public function getTaskOpt() : array { |
|
| 172 | + public function getTaskOpt () : array { |
|
| 173 | 173 | return array_intersect_key( |
| 174 | 174 | $this->opts, |
| 175 | 175 | [ 'tasks' => true, 'subtasks' => true ] |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | /** |
| 180 | 180 | * @return string|null |
| 181 | 181 | */ |
| 182 | - public function getURL() : ?string { |
|
| 182 | + public function getURL () : ?string { |
|
| 183 | 183 | return $this->getOpt( 'force-url' ); |
| 184 | 184 | } |
| 185 | 185 | } |
@@ -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\Page; |
| 4 | 4 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param string $listTitle |
| 21 | 21 | * @param Wiki $wiki |
| 22 | 22 | */ |
| 23 | - private function __construct( string $listTitle, Wiki $wiki ) { |
|
| 23 | + private function __construct ( string $listTitle, Wiki $wiki ) { |
|
| 24 | 24 | parent::__construct( $listTitle, $wiki ); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @param string $listTitle |
| 32 | 32 | * @return self |
| 33 | 33 | */ |
| 34 | - public static function get( Wiki $wiki, string $listTitle ) : self { |
|
| 34 | + public static function get ( Wiki $wiki, string $listTitle ) : self { |
|
| 35 | 35 | static $instance = null; |
| 36 | 36 | if ( $instance === null ) { |
| 37 | 37 | $instance = new self( $listTitle, $wiki ); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param UserInfo $ui |
| 44 | 44 | * @return int|null |
| 45 | 45 | */ |
| 46 | - public function getOverrideTimestamp( UserInfo $ui ) : ?int { |
|
| 46 | + public function getOverrideTimestamp ( UserInfo $ui ) : ?int { |
|
| 47 | 47 | $info = $ui->getInfo(); |
| 48 | 48 | if ( !array_intersect_key( $info, [ 'override-perm' => true, 'override' => true ] ) ) { |
| 49 | 49 | return null; |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // A one-time override takes precedence |
| 53 | 53 | if ( array_key_exists( 'override', $info ) ) { |
| 54 | - $date = $info['override']; |
|
| 54 | + $date = $info[ 'override' ]; |
|
| 55 | 55 | } else { |
| 56 | - $date = $info['override-prem'] . '/' . date( 'Y' ); |
|
| 56 | + $date = $info[ 'override-prem' ] . '/' . date( 'Y' ); |
|
| 57 | 57 | } |
| 58 | 58 | return DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp(); |
| 59 | 59 | } |
@@ -65,18 +65,18 @@ discard block |
||
| 65 | 65 | * @return int |
| 66 | 66 | * @suppress PhanPluginComparisonObjectOrdering DateTime objects can be compared (phan issue #2907) |
| 67 | 67 | */ |
| 68 | - public function getNextTimestamp( string $user ) : int { |
|
| 68 | + public function getNextTimestamp ( string $user ) : int { |
|
| 69 | 69 | $userInfo = $this->getUserInfo( $user )->getInfo(); |
| 70 | 70 | $now = new DateTime(); |
| 71 | - if ( isset( $userInfo['override-perm'] ) ) { |
|
| 71 | + if ( isset( $userInfo[ 'override-perm' ] ) ) { |
|
| 72 | 72 | $date = DateTime::createFromFormat( |
| 73 | 73 | 'd/m/Y', |
| 74 | - $userInfo['override-perm'] . '/' . date( 'Y' ) |
|
| 74 | + $userInfo[ 'override-perm' ] . '/' . date( 'Y' ) |
|
| 75 | 75 | ); |
| 76 | 76 | } else { |
| 77 | 77 | $date = null; |
| 78 | - if ( isset( $userInfo['override'] ) ) { |
|
| 79 | - $date = DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] ); |
|
| 78 | + if ( isset( $userInfo[ 'override' ] ) ) { |
|
| 79 | + $date = DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] ); |
|
| 80 | 80 | } |
| 81 | 81 | if ( !$date || $date <= $now ) { |
| 82 | 82 | $ts = self::getValidFlagTimestamp( $userInfo ); |
@@ -96,17 +96,15 @@ discard block |
||
| 96 | 96 | * @param string[] $groups |
| 97 | 97 | * @return int |
| 98 | 98 | */ |
| 99 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
| 100 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
| 101 | - DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
| 102 | - 0; |
|
| 103 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
| 104 | - DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
| 105 | - 0; |
|
| 99 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
| 100 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
| 101 | + DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 102 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
| 103 | + DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 106 | 104 | |
| 107 | 105 | $timestamp = max( $bureaucrat, $checkuser ); |
| 108 | 106 | if ( $timestamp === 0 ) { |
| 109 | - $timestamp = DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
| 107 | + $timestamp = DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
| 110 | 108 | } |
| 111 | 109 | return $timestamp; |
| 112 | 110 | } |
@@ -120,14 +118,14 @@ discard block |
||
| 120 | 118 | * @param string[] $groups |
| 121 | 119 | * @return bool |
| 122 | 120 | */ |
| 123 | - public static function isOverrideExpired( array $groups ) : bool { |
|
| 124 | - if ( !isset( $groups['override'] ) ) { |
|
| 121 | + public static function isOverrideExpired ( array $groups ) : bool { |
|
| 122 | + if ( !isset( $groups[ 'override' ] ) ) { |
|
| 125 | 123 | return false; |
| 126 | 124 | } |
| 127 | 125 | |
| 128 | 126 | $flagTS = self::getValidFlagTimestamp( $groups ); |
| 129 | 127 | $usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) ); |
| 130 | - $overrideTS = DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp(); |
|
| 128 | + $overrideTS = DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp(); |
|
| 131 | 129 | $delay = 60 * 60 * 24 * 3; |
| 132 | 130 | |
| 133 | 131 | return time() > $usualTS + $delay && time() > $overrideTS + $delay; |
@@ -138,9 +136,9 @@ discard block |
||
| 138 | 136 | * |
| 139 | 137 | * @return UserInfo[] |
| 140 | 138 | */ |
| 141 | - public function getAdminsList() : array { |
|
| 139 | + public function getAdminsList () : array { |
|
| 142 | 140 | if ( $this->adminsList === null ) { |
| 143 | - $this->adminsList = []; |
|
| 141 | + $this->adminsList = [ ]; |
|
| 144 | 142 | foreach ( $this->getDecodedContent() as $user => $info ) { |
| 145 | 143 | $this->adminsList[ $user ] = new UserInfo( $user, $info ); |
| 146 | 144 | } |
@@ -152,8 +150,8 @@ discard block |
||
| 152 | 150 | * @param string $user |
| 153 | 151 | * @return UserInfo |
| 154 | 152 | */ |
| 155 | - public function getUserInfo( string $user ) : UserInfo { |
|
| 156 | - return $this->getAdminsList()[$user]; |
|
| 153 | + public function getUserInfo ( string $user ) : UserInfo { |
|
| 154 | + return $this->getAdminsList()[ $user ]; |
|
| 157 | 155 | } |
| 158 | 156 | |
| 159 | 157 | /** |
@@ -161,7 +159,7 @@ discard block |
||
| 161 | 159 | * |
| 162 | 160 | * @return string[][] |
| 163 | 161 | */ |
| 164 | - public function getDecodedContent() : array { |
|
| 162 | + public function getDecodedContent () : array { |
|
| 165 | 163 | return json_decode( $this->getContent(), true ); |
| 166 | 164 | } |
| 167 | 165 | } |
@@ -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\Page; |
| 4 | 4 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** @var int|null */ |
| 17 | 17 | private $opposeSection; |
| 18 | 18 | /** @var int[] Counts of votes for each section */ |
| 19 | - private $sectionCounts = []; |
|
| 19 | + private $sectionCounts = [ ]; |
|
| 20 | 20 | |
| 21 | 21 | // Possible outcomes of a vote |
| 22 | 22 | public const OUTCOME_OK = 0; |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * because they can vary depending on whether the page is a vote, which is relatively |
| 36 | 36 | * expensive to know since it requires parsing the content of the page. |
| 37 | 37 | */ |
| 38 | - private function defineSections() : void { |
|
| 38 | + private function defineSections () : void { |
|
| 39 | 39 | $this->supportSection = $this->isVote() ? 3 : 0; |
| 40 | 40 | $this->opposeSection = $this->isVote() ? 4 : 3; |
| 41 | 41 | } |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return string |
| 47 | 47 | */ |
| 48 | - public function getUserName() : string { |
|
| 49 | - return explode( '/', $this->title )[2]; |
|
| 48 | + public function getUserName () : string { |
|
| 49 | + return explode( '/', $this->title )[ 2 ]; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @return int |
| 56 | 56 | */ |
| 57 | - public function getNum() : int { |
|
| 57 | + public function getNum () : int { |
|
| 58 | 58 | $bits = explode( '/', $this->getTitle() ); |
| 59 | 59 | return (int)end( $bits ); |
| 60 | 60 | } |
@@ -64,8 +64,8 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | - public function getUserNum() : string { |
|
| 68 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 67 | + public function getUserNum () : string { |
|
| 68 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return int |
| 75 | 75 | */ |
| 76 | - public function getOpposingCount() : int { |
|
| 76 | + public function getOpposingCount () : int { |
|
| 77 | 77 | $this->defineSections(); |
| 78 | 78 | return $this->getCountForSection( $this->opposeSection ); |
| 79 | 79 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @return int |
| 85 | 85 | * @throws BadMethodCallException |
| 86 | 86 | */ |
| 87 | - public function getSupportCount() : int { |
|
| 87 | + public function getSupportCount () : int { |
|
| 88 | 88 | if ( !$this->isVote() ) { |
| 89 | 89 | throw new BadMethodCallException( 'Cannot get support for a non-vote page.' ); |
| 90 | 90 | } |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | * @param int $secNum |
| 99 | 99 | * @return int |
| 100 | 100 | */ |
| 101 | - protected function getCountForSection( int $secNum ) : int { |
|
| 101 | + protected function getCountForSection ( int $secNum ) : int { |
|
| 102 | 102 | if ( !isset( $this->sectionCounts[ $secNum ] ) ) { |
| 103 | 103 | $content = $this->wiki->getPageContent( $this->title, $secNum ); |
| 104 | 104 | // Let's hope that this is good enough... |
| 105 | - $this->sectionCounts[$secNum] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); |
|
| 105 | + $this->sectionCounts[ $secNum ] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); |
|
| 106 | 106 | } |
| 107 | - return $this->sectionCounts[$secNum]; |
|
| 107 | + return $this->sectionCounts[ $secNum ]; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | /** |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return int |
| 114 | 114 | */ |
| 115 | - protected function getQuorum() : int { |
|
| 115 | + protected function getQuorum () : int { |
|
| 116 | 116 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 117 | - return (int)$this->getMatch( $reg )[1]; |
|
| 117 | + return (int)$this->getMatch( $reg )[ 1 ]; |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return bool |
| 124 | 124 | */ |
| 125 | - public function hasOpposition() : bool { |
|
| 125 | + public function hasOpposition () : bool { |
|
| 126 | 126 | return $this->getOpposingCount() >= self::REQUIRED_OPPOSE; |
| 127 | 127 | } |
| 128 | 128 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * |
| 132 | 132 | * @return int One of the OUTCOME_* constants |
| 133 | 133 | */ |
| 134 | - public function getOutcome() : int { |
|
| 134 | + public function getOutcome () : int { |
|
| 135 | 135 | if ( !$this->isVote() ) { |
| 136 | 136 | return self::OUTCOME_OK; |
| 137 | 137 | } |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @throws BadMethodCallException |
| 155 | 155 | * @throws LogicException |
| 156 | 156 | */ |
| 157 | - public function getOutcomeText() : string { |
|
| 157 | + public function getOutcomeText () : string { |
|
| 158 | 158 | if ( !$this->isVote() ) { |
| 159 | 159 | throw new BadMethodCallException( 'No need for an outcome text.' ); |
| 160 | 160 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return bool |
| 190 | 190 | */ |
| 191 | - public function isVote() : bool { |
|
| 191 | + public function isVote () : bool { |
|
| 192 | 192 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 193 | 193 | return !$this->matches( $sectionReg ); |
| 194 | 194 | } |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return int |
| 200 | 200 | */ |
| 201 | - public function getCreationTimestamp() : int { |
|
| 201 | + public function getCreationTimestamp () : int { |
|
| 202 | 202 | return $this->wiki->getPageCreationTS( $this->title ); |
| 203 | 203 | } |
| 204 | 204 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | * |
| 208 | 208 | * @return int |
| 209 | 209 | */ |
| 210 | - public function getEndTimestamp() : int { |
|
| 210 | + public function getEndTimestamp () : int { |
|
| 211 | 211 | if ( $this->isVote() ) { |
| 212 | 212 | $reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!"; |
| 213 | 213 | [ , $hours, $day ] = $this->getMatch( $reg ); |