@@ -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 | } |
@@ -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,7 +59,7 @@ 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 | $this->handleResponseHeader( $header ); |
| 64 | 64 | return strlen( $header ); |
| 65 | 65 | } |
@@ -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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * @param string $listTitle |
| 19 | 19 | * @param Wiki $wiki |
| 20 | 20 | */ |
| 21 | - private function __construct( string $listTitle, Wiki $wiki ) { |
|
| 21 | + private function __construct ( string $listTitle, Wiki $wiki ) { |
|
| 22 | 22 | parent::__construct( $listTitle, $wiki ); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $listTitle |
| 30 | 30 | * @return self |
| 31 | 31 | */ |
| 32 | - public static function get( Wiki $wiki, string $listTitle ): self { |
|
| 32 | + public static function get ( Wiki $wiki, string $listTitle ): self { |
|
| 33 | 33 | static $instance = null; |
| 34 | 34 | if ( $instance === null ) { |
| 35 | 35 | $instance = new self( $listTitle, $wiki ); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param UserInfo $ui |
| 42 | 42 | * @return int|null |
| 43 | 43 | */ |
| 44 | - public function getOverrideTimestamp( UserInfo $ui ): ?int { |
|
| 44 | + public function getOverrideTimestamp ( UserInfo $ui ): ?int { |
|
| 45 | 45 | $info = $ui->getInfo(); |
| 46 | 46 | if ( !array_intersect_key( $info, [ 'override-perm' => true, 'override' => true ] ) ) { |
| 47 | 47 | return null; |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // A one-time override takes precedence |
| 51 | 51 | if ( array_key_exists( 'override', $info ) ) { |
| 52 | - $date = $info['override']; |
|
| 52 | + $date = $info[ 'override' ]; |
|
| 53 | 53 | } else { |
| 54 | - $date = $info['override-prem'] . '/' . date( 'Y' ); |
|
| 54 | + $date = $info[ 'override-prem' ] . '/' . date( 'Y' ); |
|
| 55 | 55 | } |
| 56 | 56 | return DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp(); |
| 57 | 57 | } |
@@ -63,18 +63,18 @@ discard block |
||
| 63 | 63 | * @return int |
| 64 | 64 | * @suppress PhanPluginComparisonObjectOrdering DateTime objects can be compared (phan issue #2907) |
| 65 | 65 | */ |
| 66 | - public function getNextTimestamp( string $user ): int { |
|
| 66 | + public function getNextTimestamp ( string $user ): int { |
|
| 67 | 67 | $userInfo = $this->getUserInfo( $user )->getInfo(); |
| 68 | 68 | $now = new DateTime(); |
| 69 | - if ( isset( $userInfo['override-perm'] ) ) { |
|
| 69 | + if ( isset( $userInfo[ 'override-perm' ] ) ) { |
|
| 70 | 70 | $date = DateTime::createFromFormat( |
| 71 | 71 | 'd/m/Y', |
| 72 | - $userInfo['override-perm'] . '/' . date( 'Y' ) |
|
| 72 | + $userInfo[ 'override-perm' ] . '/' . date( 'Y' ) |
|
| 73 | 73 | ); |
| 74 | 74 | } else { |
| 75 | 75 | $date = null; |
| 76 | - if ( isset( $userInfo['override'] ) ) { |
|
| 77 | - $date = DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] ); |
|
| 76 | + if ( isset( $userInfo[ 'override' ] ) ) { |
|
| 77 | + $date = DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] ); |
|
| 78 | 78 | } |
| 79 | 79 | if ( !$date || $date <= $now ) { |
| 80 | 80 | $ts = self::getValidFlagTimestamp( $userInfo ); |
@@ -95,17 +95,15 @@ discard block |
||
| 95 | 95 | * @param string[] $groups |
| 96 | 96 | * @return int |
| 97 | 97 | */ |
| 98 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
| 99 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
| 100 | - DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
| 101 | - 0; |
|
| 102 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
| 103 | - DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
| 104 | - 0; |
|
| 98 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
| 99 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
| 100 | + DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 101 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
| 102 | + DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 105 | 103 | |
| 106 | 104 | $timestamp = max( $bureaucrat, $checkuser ); |
| 107 | 105 | if ( $timestamp === 0 ) { |
| 108 | - $timestamp = DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
| 106 | + $timestamp = DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
| 109 | 107 | } |
| 110 | 108 | return $timestamp; |
| 111 | 109 | } |
@@ -119,14 +117,14 @@ discard block |
||
| 119 | 117 | * @param string[] $groups |
| 120 | 118 | * @return bool |
| 121 | 119 | */ |
| 122 | - public static function isOverrideExpired( array $groups ): bool { |
|
| 123 | - if ( !isset( $groups['override'] ) ) { |
|
| 120 | + public static function isOverrideExpired ( array $groups ): bool { |
|
| 121 | + if ( !isset( $groups[ 'override' ] ) ) { |
|
| 124 | 122 | return false; |
| 125 | 123 | } |
| 126 | 124 | |
| 127 | 125 | $flagTS = self::getValidFlagTimestamp( $groups ); |
| 128 | 126 | $usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) ); |
| 129 | - $overrideTS = DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp(); |
|
| 127 | + $overrideTS = DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp(); |
|
| 130 | 128 | $delay = 60 * 60 * 24 * 3; |
| 131 | 129 | |
| 132 | 130 | return time() > $usualTS + $delay && time() > $overrideTS + $delay; |
@@ -137,9 +135,9 @@ discard block |
||
| 137 | 135 | * |
| 138 | 136 | * @return UserInfo[] |
| 139 | 137 | */ |
| 140 | - public function getAdminsList(): array { |
|
| 138 | + public function getAdminsList (): array { |
|
| 141 | 139 | if ( $this->adminsList === null ) { |
| 142 | - $this->adminsList = []; |
|
| 140 | + $this->adminsList = [ ]; |
|
| 143 | 141 | foreach ( $this->getDecodedContent() as $user => $info ) { |
| 144 | 142 | $this->adminsList[ $user ] = new UserInfo( $user, $info ); |
| 145 | 143 | } |
@@ -151,8 +149,8 @@ discard block |
||
| 151 | 149 | * @param string $user |
| 152 | 150 | * @return UserInfo |
| 153 | 151 | */ |
| 154 | - public function getUserInfo( string $user ): UserInfo { |
|
| 155 | - return $this->getAdminsList()[$user]; |
|
| 152 | + public function getUserInfo ( string $user ): UserInfo { |
|
| 153 | + return $this->getAdminsList()[ $user ]; |
|
| 156 | 154 | } |
| 157 | 155 | |
| 158 | 156 | /** |
@@ -161,7 +159,7 @@ discard block |
||
| 161 | 159 | * @return array[] |
| 162 | 160 | * @phan-return array<string,array{sysop:string,checkuser?:string,bureaucrat?:string,override?:string,override-perm?:string,aliases?:list<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\Request; |
| 4 | 4 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param LoggerInterface $logger |
| 21 | 21 | * @param string $domain |
| 22 | 22 | */ |
| 23 | - public function __construct( LoggerInterface $logger, string $domain ) { |
|
| 23 | + public function __construct ( LoggerInterface $logger, string $domain ) { |
|
| 24 | 24 | $this->logger = $logger; |
| 25 | 25 | $this->domain = $domain; |
| 26 | 26 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param callable $cookiesCallback |
| 33 | 33 | * @return RequestBase |
| 34 | 34 | */ |
| 35 | - public function createRequest( array $params, array $cookies, callable $cookiesCallback ) { |
|
| 35 | + public function createRequest ( array $params, array $cookies, callable $cookiesCallback ) { |
|
| 36 | 36 | $ret = extension_loaded( 'curl' ) |
| 37 | 37 | ? new CurlRequest( $this->logger, $params, $this->domain, $cookiesCallback ) |
| 38 | 38 | : new NativeRequest( $this->logger, $params, $this->domain, $cookiesCallback ); |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @phan-param array<int|string|bool> $params |
| 48 | 48 | * @return RequestBase |
| 49 | 49 | */ |
| 50 | - public function createStandaloneRequest( array $params ) { |
|
| 50 | + public function createStandaloneRequest ( array $params ) { |
|
| 51 | 51 | /** @param string[] $newCookies */ |
| 52 | 52 | $cookiesCallback = function ( array $newCookies ) { |
| 53 | 53 | $newCookies = array_map( 'trim', array_keys( $newCookies ) ); |
@@ -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; |
| 4 | 4 | |
@@ -22,15 +22,15 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * @inheritDoc |
| 24 | 24 | */ |
| 25 | - protected function getSubtasksMap(): array { |
|
| 25 | + protected function getSubtasksMap (): array { |
|
| 26 | 26 | // Everything is done here. |
| 27 | - return []; |
|
| 27 | + return [ ]; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @inheritDoc |
| 32 | 32 | */ |
| 33 | - public function runInternal(): int { |
|
| 33 | + public function runInternal (): int { |
|
| 34 | 34 | $this->actualList = $this->computeActualList(); |
| 35 | 35 | $pageBotList = $this->getBotList(); |
| 36 | 36 | $botList = $pageBotList->getDecodedContent(); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @return string[][] |
| 56 | 56 | * @phan-return array<string,string[]> |
| 57 | 57 | */ |
| 58 | - private function computeActualList(): array { |
|
| 58 | + private function computeActualList (): array { |
|
| 59 | 59 | $params = [ |
| 60 | 60 | 'action' => 'query', |
| 61 | 61 | 'list' => 'allusers', |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @return string[][] |
| 74 | 74 | * @phan-return array<string,string[]> |
| 75 | 75 | */ |
| 76 | - private function extractAdminsData( Generator $data ): array { |
|
| 77 | - $ret = []; |
|
| 76 | + private function extractAdminsData ( Generator $data ): array { |
|
| 77 | + $ret = [ ]; |
|
| 78 | 78 | $blacklist = $this->getOpt( 'exclude-admins' ); |
| 79 | 79 | foreach ( $data as $user ) { |
| 80 | 80 | if ( in_array( $user->name, $blacklist, true ) ) { |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @phan-param array<string,array{sysop:string,checkuser?:string,bureaucrat?:string,override?:string,override-perm?:string,aliases?:list<string>}> $curList |
| 95 | 95 | * @return array[] |
| 96 | 96 | */ |
| 97 | - private function computeNewList( array $curList ): array { |
|
| 97 | + private function computeNewList ( array $curList ): array { |
|
| 98 | 98 | $newList = $curList; |
| 99 | 99 | |
| 100 | 100 | $extra = $this->getExtraAdminGroups( $curList ); |
@@ -114,21 +114,21 @@ discard block |
||
| 114 | 114 | * @phan-param array<string,array<string,string|string[]>> &$newList |
| 115 | 115 | * @param string[][] $extra |
| 116 | 116 | */ |
| 117 | - private function handleExtraAndMissing( array &$newList, array $extra ): void { |
|
| 117 | + private function handleExtraAndMissing ( array &$newList, array $extra ): void { |
|
| 118 | 118 | $missing = $this->getMissingAdminGroups( $newList ); |
| 119 | 119 | |
| 120 | - $removed = []; |
|
| 120 | + $removed = [ ]; |
|
| 121 | 121 | foreach ( $newList as $user => $data ) { |
| 122 | - if ( isset( $missing[$user] ) ) { |
|
| 123 | - $newList[$user] = array_merge( $data, $missing[$user] ); |
|
| 124 | - unset( $missing[$user] ); |
|
| 125 | - } elseif ( isset( $extra[$user] ) ) { |
|
| 126 | - $newGroups = array_diff_key( $data, $extra[$user] ); |
|
| 122 | + if ( isset( $missing[ $user ] ) ) { |
|
| 123 | + $newList[ $user ] = array_merge( $data, $missing[ $user ] ); |
|
| 124 | + unset( $missing[ $user ] ); |
|
| 125 | + } elseif ( isset( $extra[ $user ] ) ) { |
|
| 126 | + $newGroups = array_diff_key( $data, $extra[ $user ] ); |
|
| 127 | 127 | if ( array_diff_key( $newGroups, self::NON_GROUP_KEYS ) ) { |
| 128 | - $newList[$user] = $newGroups; |
|
| 128 | + $newList[ $user ] = $newGroups; |
|
| 129 | 129 | } else { |
| 130 | - $removed[] = $user; |
|
| 131 | - unset( $newList[$user] ); |
|
| 130 | + $removed[ ] = $user; |
|
| 131 | + unset( $newList[ $user ] ); |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -146,17 +146,17 @@ discard block |
||
| 146 | 146 | * @phan-param array<string,array<string,string|string[]>> $botList |
| 147 | 147 | * @return string[][] |
| 148 | 148 | */ |
| 149 | - private function getMissingAdminGroups( array $botList ): array { |
|
| 150 | - $missing = []; |
|
| 149 | + private function getMissingAdminGroups ( array $botList ): array { |
|
| 150 | + $missing = [ ]; |
|
| 151 | 151 | foreach ( $this->actualList as $admin => $groups ) { |
| 152 | - $missingGroups = array_diff( $groups, array_keys( $botList[$admin] ?? [] ) ); |
|
| 152 | + $missingGroups = array_diff( $groups, array_keys( $botList[ $admin ] ?? [ ] ) ); |
|
| 153 | 153 | foreach ( $missingGroups as $group ) { |
| 154 | 154 | $ts = $this->getFlagDate( $admin, $group ); |
| 155 | 155 | if ( $ts === null ) { |
| 156 | - $this->errors[] = "$group flag date unavailable for $admin"; |
|
| 156 | + $this->errors[ ] = "$group flag date unavailable for $admin"; |
|
| 157 | 157 | continue; |
| 158 | 158 | } |
| 159 | - $missing[$admin][$group] = $ts; |
|
| 159 | + $missing[ $admin ][ $group ] = $ts; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | return $missing; |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @param string $group |
| 170 | 170 | * @return string|null |
| 171 | 171 | */ |
| 172 | - private function getFlagDate( string $admin, string $group ): ?string { |
|
| 172 | + private function getFlagDate ( string $admin, string $group ): ?string { |
|
| 173 | 173 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 174 | 174 | |
| 175 | 175 | $wiki = $this->getWiki(); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param string $group |
| 201 | 201 | * @return string|null |
| 202 | 202 | */ |
| 203 | - private function extractTimestamp( Generator $data, string $group ): ?string { |
|
| 203 | + private function extractTimestamp ( Generator $data, string $group ): ?string { |
|
| 204 | 204 | $ts = null; |
| 205 | 205 | foreach ( $data as $entry ) { |
| 206 | 206 | if ( |
@@ -222,14 +222,14 @@ discard block |
||
| 222 | 222 | * @phan-param array<string,array{sysop:string,checkuser?:string,bureaucrat?:string,override?:string,override-perm?:string,aliases?:list<string>}> $botList |
| 223 | 223 | * @return string[][] |
| 224 | 224 | */ |
| 225 | - private function getExtraAdminGroups( array $botList ): array { |
|
| 226 | - $extra = []; |
|
| 225 | + private function getExtraAdminGroups ( array $botList ): array { |
|
| 226 | + $extra = [ ]; |
|
| 227 | 227 | foreach ( $botList as $name => $data ) { |
| 228 | 228 | $groups = array_diff_key( $data, self::NON_GROUP_KEYS ); |
| 229 | - if ( !isset( $this->actualList[$name] ) ) { |
|
| 230 | - $extra[$name] = $groups; |
|
| 231 | - } elseif ( count( $groups ) > count( $this->actualList[$name] ) ) { |
|
| 232 | - $extra[$name] = array_diff_key( $groups, $this->actualList[$name] ); |
|
| 229 | + if ( !isset( $this->actualList[ $name ] ) ) { |
|
| 230 | + $extra[ $name ] = $groups; |
|
| 231 | + } elseif ( count( $groups ) > count( $this->actualList[ $name ] ) ) { |
|
| 232 | + $extra[ $name ] = array_diff_key( $groups, $this->actualList[ $name ] ); |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | return $extra; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param string[] $oldNames |
| 240 | 240 | * @return Generator |
| 241 | 241 | */ |
| 242 | - private function getRenameEntries( array $oldNames ): Generator { |
|
| 242 | + private function getRenameEntries ( array $oldNames ): Generator { |
|
| 243 | 243 | $titles = array_map( static function ( string $x ): string { |
| 244 | 244 | return "Utente:$x"; |
| 245 | 245 | }, $oldNames ); |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | * @param string[] $oldNames |
| 264 | 264 | * @return string[] [ old_name => new_name ] |
| 265 | 265 | */ |
| 266 | - private function getRenamedUsers( array $oldNames ): array { |
|
| 266 | + private function getRenamedUsers ( array $oldNames ): array { |
|
| 267 | 267 | if ( !$oldNames ) { |
| 268 | - return []; |
|
| 268 | + return [ ]; |
|
| 269 | 269 | } |
| 270 | 270 | $this->getLogger()->info( 'Checking rename for ' . implode( ', ', $oldNames ) ); |
| 271 | 271 | |
| 272 | 272 | $data = $this->getRenameEntries( $oldNames ); |
| 273 | - $ret = []; |
|
| 273 | + $ret = [ ]; |
|
| 274 | 274 | foreach ( $data as $entry ) { |
| 275 | 275 | // 1 month is arbitrary |
| 276 | 276 | if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) { |
@@ -291,15 +291,15 @@ discard block |
||
| 291 | 291 | * @param string[][] $extra |
| 292 | 292 | * @return array<string,string> Map of renamed users |
| 293 | 293 | */ |
| 294 | - private function handleRenames( array &$newList, array $extra ): array { |
|
| 294 | + private function handleRenames ( array &$newList, array $extra ): array { |
|
| 295 | 295 | $renameMap = $this->getRenamedUsers( array_keys( $extra ) ); |
| 296 | 296 | foreach ( $renameMap as $oldName => $newName ) { |
| 297 | 297 | $this->getLogger()->info( "Found rename $oldName -> $newName" ); |
| 298 | - $newList[$newName] = $newList[$oldName]; |
|
| 299 | - $newList[$newName]['aliases'] = array_unique( |
|
| 300 | - array_merge( $newList[$newName]['aliases'] ?? [], [ $oldName ] ) |
|
| 298 | + $newList[ $newName ] = $newList[ $oldName ]; |
|
| 299 | + $newList[ $newName ][ 'aliases' ] = array_unique( |
|
| 300 | + array_merge( $newList[ $newName ][ 'aliases' ] ?? [ ], [ $oldName ] ) |
|
| 301 | 301 | ); |
| 302 | - unset( $newList[$oldName] ); |
|
| 302 | + unset( $newList[ $oldName ] ); |
|
| 303 | 303 | } |
| 304 | 304 | return $renameMap; |
| 305 | 305 | } |
@@ -309,12 +309,12 @@ discard block |
||
| 309 | 309 | * |
| 310 | 310 | * @param array[] &$newList |
| 311 | 311 | */ |
| 312 | - private function removeOverrides( array &$newList ): void { |
|
| 313 | - $removed = []; |
|
| 312 | + private function removeOverrides ( array &$newList ): void { |
|
| 313 | + $removed = [ ]; |
|
| 314 | 314 | foreach ( $newList as $user => $data ) { |
| 315 | 315 | if ( PageBotList::isOverrideExpired( $data ) ) { |
| 316 | - unset( $newList[$user]['override'] ); |
|
| 317 | - $removed[] = $user; |
|
| 316 | + unset( $newList[ $user ][ 'override' ] ); |
|
| 317 | + $removed[ ] = $user; |
|
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
@@ -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 | /** @var callable|null */ |
| 46 | 46 | private $cookiesHandlerCallback; |
| 47 | 47 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param string $domain |
| 58 | 58 | * @param callable $cookiesHandlerCallback |
| 59 | 59 | */ |
| 60 | - public function __construct( |
|
| 60 | + public function __construct ( |
|
| 61 | 61 | LoggerInterface $logger, |
| 62 | 62 | array $params, |
| 63 | 63 | string $domain, |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return self For chaining |
| 76 | 76 | */ |
| 77 | - public function setPost(): self { |
|
| 77 | + public function setPost (): self { |
|
| 78 | 78 | $this->method = self::METHOD_POST; |
| 79 | 79 | return $this; |
| 80 | 80 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string[] $cookies |
| 84 | 84 | * @return self For chaining |
| 85 | 85 | */ |
| 86 | - public function setCookies( array $cookies ): self { |
|
| 86 | + public function setCookies ( array $cookies ): self { |
|
| 87 | 87 | $this->cookiesToSet = $cookies; |
| 88 | 88 | return $this; |
| 89 | 89 | } |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | * Execute a query request |
| 93 | 93 | * @return Generator |
| 94 | 94 | */ |
| 95 | - public function executeAsQuery(): Generator { |
|
| 96 | - if ( ( $this->params['action'] ?? false ) !== 'query' ) { |
|
| 95 | + public function executeAsQuery (): Generator { |
|
| 96 | + if ( ( $this->params[ 'action' ] ?? false ) !== 'query' ) { |
|
| 97 | 97 | throw new BadMethodCallException( 'Not an ApiQuery!' ); |
| 98 | 98 | } |
| 99 | 99 | // TODO Is this always correct? |
| 100 | - $key = $this->params['list'] ?? 'pages'; |
|
| 100 | + $key = $this->params[ 'list' ] ?? 'pages'; |
|
| 101 | 101 | $curParams = $this->params; |
| 102 | 102 | $lim = $this->parseLimit(); |
| 103 | 103 | do { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * Execute a request that doesn't need any continuation. |
| 127 | 127 | * @return stdClass |
| 128 | 128 | */ |
| 129 | - public function executeSingle(): stdClass { |
|
| 129 | + public function executeSingle (): stdClass { |
|
| 130 | 130 | $curParams = $this->params; |
| 131 | 131 | $res = $this->makeRequestInternal( $curParams ); |
| 132 | 132 | $this->handleErrorAndWarnings( $res ); |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | /** |
| 137 | 137 | * @return int |
| 138 | 138 | */ |
| 139 | - private function parseLimit(): int { |
|
| 139 | + private function parseLimit (): int { |
|
| 140 | 140 | foreach ( $this->params as $name => $val ) { |
| 141 | 141 | if ( substr( $name, -strlen( 'limit' ) ) === 'limit' ) { |
| 142 | 142 | return $val === 'max' ? -1 : (int)$val; |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @param string $resKey |
| 154 | 154 | * @return int|null |
| 155 | 155 | */ |
| 156 | - private function countQueryResults( stdClass $res, string $resKey ): ?int { |
|
| 156 | + private function countQueryResults ( stdClass $res, string $resKey ): ?int { |
|
| 157 | 157 | if ( !isset( $res->query->$resKey ) ) { |
| 158 | 158 | return null; |
| 159 | 159 | } |
@@ -181,9 +181,9 @@ discard block |
||
| 181 | 181 | * @phan-param array<int|string|bool> $params |
| 182 | 182 | * @return stdClass |
| 183 | 183 | */ |
| 184 | - private function makeRequestInternal( array $params ): stdClass { |
|
| 184 | + private function makeRequestInternal ( array $params ): stdClass { |
|
| 185 | 185 | if ( $this->method === self::METHOD_POST ) { |
| 186 | - $params['maxlag'] = self::MAXLAG; |
|
| 186 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
| 187 | 187 | } |
| 188 | 188 | $query = http_build_query( $params ); |
| 189 | 189 | |
@@ -203,15 +203,15 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @param string $rawHeader |
| 205 | 205 | */ |
| 206 | - protected function handleResponseHeader( string $rawHeader ): void { |
|
| 206 | + protected function handleResponseHeader ( string $rawHeader ): void { |
|
| 207 | 207 | $headerParts = explode( ':', $rawHeader, 2 ); |
| 208 | - $headerName = $headerParts[0]; |
|
| 209 | - $headerValue = $headerParts[1] ?? null; |
|
| 208 | + $headerName = $headerParts[ 0 ]; |
|
| 209 | + $headerValue = $headerParts[ 1 ] ?? null; |
|
| 210 | 210 | if ( strtolower( trim( $headerName ) ) === 'set-cookie' && $headerValue ) { |
| 211 | 211 | // TODO Maybe use a cookie file? |
| 212 | - $cookieKeyVal = explode( ';', $headerValue )[0]; |
|
| 212 | + $cookieKeyVal = explode( ';', $headerValue )[ 0 ]; |
|
| 213 | 213 | [ $name, $value ] = explode( '=', $cookieKeyVal ); |
| 214 | - $this->newCookies[$name] = $value; |
|
| 214 | + $this->newCookies[ $name ] = $value; |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * @param string $params |
| 222 | 222 | * @return string |
| 223 | 223 | */ |
| 224 | - abstract protected function reallyMakeRequest( string $params ): string; |
|
| 224 | + abstract protected function reallyMakeRequest ( string $params ): string; |
|
| 225 | 225 | |
| 226 | 226 | /** |
| 227 | 227 | * Get a specific exception class depending on the error code |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | * @param stdClass $res |
| 230 | 230 | * @return APIRequestException |
| 231 | 231 | */ |
| 232 | - private function getException( stdClass $res ): APIRequestException { |
|
| 232 | + private function getException ( stdClass $res ): APIRequestException { |
|
| 233 | 233 | switch ( $res->error->code ) { |
| 234 | 234 | case 'missingtitle': |
| 235 | 235 | $ex = new MissingPageException; |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @param stdClass $res |
| 256 | 256 | * @throws APIRequestException |
| 257 | 257 | */ |
| 258 | - protected function handleErrorAndWarnings( stdClass $res ): void { |
|
| 258 | + protected function handleErrorAndWarnings ( stdClass $res ): void { |
|
| 259 | 259 | if ( isset( $res->error ) ) { |
| 260 | 260 | throw $this->getException( $res ); |
| 261 | 261 | } |
@@ -271,14 +271,14 @@ discard block |
||
| 271 | 271 | * |
| 272 | 272 | * @return string[] |
| 273 | 273 | */ |
| 274 | - protected function getHeaders(): array { |
|
| 274 | + protected function getHeaders (): array { |
|
| 275 | 275 | $ret = self::HEADERS; |
| 276 | 276 | if ( $this->cookiesToSet ) { |
| 277 | - $cookies = []; |
|
| 277 | + $cookies = [ ]; |
|
| 278 | 278 | foreach ( $this->cookiesToSet as $cname => $cval ) { |
| 279 | - $cookies[] = trim( "$cname=$cval" ); |
|
| 279 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
| 280 | 280 | } |
| 281 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 281 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
| 282 | 282 | } |
| 283 | 283 | return $ret; |
| 284 | 284 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @param string[] $headers |
| 290 | 290 | * @return string |
| 291 | 291 | */ |
| 292 | - protected function buildHeadersString( array $headers ): string { |
|
| 292 | + protected function buildHeadersString ( array $headers ): string { |
|
| 293 | 293 | $ret = ''; |
| 294 | 294 | foreach ( $headers as $header ) { |
| 295 | 295 | $ret .= "$header\r\n"; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * @param string $actualParams |
| 302 | 302 | * @return string |
| 303 | 303 | */ |
| 304 | - protected function getDebugURL( string $actualParams ): string { |
|
| 304 | + protected function getDebugURL ( string $actualParams ): string { |
|
| 305 | 305 | return strpos( $this->url, 'login' ) !== false |
| 306 | 306 | ? '[Login request]' |
| 307 | 307 | : "{$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\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; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * because they can vary depending on whether the page is a vote, which is relatively |
| 37 | 37 | * expensive to know since it requires parsing the content of the page. |
| 38 | 38 | */ |
| 39 | - private function defineSections(): void { |
|
| 39 | + private function defineSections (): void { |
|
| 40 | 40 | $this->supportSection = $this->isVote() ? 3 : 0; |
| 41 | 41 | $this->opposeSection = $this->isVote() ? 4 : 3; |
| 42 | 42 | } |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return string |
| 48 | 48 | */ |
| 49 | - public function getUserName(): string { |
|
| 50 | - return explode( '/', $this->title )[2]; |
|
| 49 | + public function getUserName (): string { |
|
| 50 | + return explode( '/', $this->title )[ 2 ]; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return int |
| 57 | 57 | */ |
| 58 | - public function getNum(): int { |
|
| 58 | + public function getNum (): int { |
|
| 59 | 59 | $bits = explode( '/', $this->getTitle() ); |
| 60 | 60 | return (int)end( $bits ); |
| 61 | 61 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function getUserNum(): string { |
|
| 69 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 68 | + public function getUserNum (): string { |
|
| 69 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return int |
| 76 | 76 | */ |
| 77 | - public function getOpposingCount(): int { |
|
| 77 | + public function getOpposingCount (): int { |
|
| 78 | 78 | $this->defineSections(); |
| 79 | 79 | return $this->getCountForSection( $this->opposeSection ); |
| 80 | 80 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @return int |
| 86 | 86 | * @throws BadMethodCallException |
| 87 | 87 | */ |
| 88 | - public function getSupportCount(): int { |
|
| 88 | + public function getSupportCount (): int { |
|
| 89 | 89 | if ( !$this->isVote() ) { |
| 90 | 90 | throw new BadMethodCallException( 'Cannot get support for a non-vote page.' ); |
| 91 | 91 | } |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | * @param int $secNum |
| 100 | 100 | * @return int |
| 101 | 101 | */ |
| 102 | - protected function getCountForSection( int $secNum ): int { |
|
| 102 | + protected function getCountForSection ( int $secNum ): int { |
|
| 103 | 103 | if ( !isset( $this->sectionCounts[ $secNum ] ) ) { |
| 104 | 104 | $content = $this->wiki->getPageContent( $this->title, $secNum ); |
| 105 | 105 | // Let's hope that this is good enough... |
| 106 | - $this->sectionCounts[$secNum] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); |
|
| 106 | + $this->sectionCounts[ $secNum ] = preg_match_all( "/^# *(?![# *:]|\.\.\.$)/m", $content ); |
|
| 107 | 107 | } |
| 108 | - return $this->sectionCounts[$secNum]; |
|
| 108 | + return $this->sectionCounts[ $secNum ]; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return int |
| 115 | 115 | */ |
| 116 | - protected function getQuorum(): int { |
|
| 116 | + protected function getQuorum (): int { |
|
| 117 | 117 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 118 | - return (int)$this->getMatch( $reg )[1]; |
|
| 118 | + return (int)$this->getMatch( $reg )[ 1 ]; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return bool |
| 125 | 125 | */ |
| 126 | - public function hasOpposition(): bool { |
|
| 126 | + public function hasOpposition (): bool { |
|
| 127 | 127 | $req = min( |
| 128 | 128 | self::REQUIRED_OPPOSE_MAX, |
| 129 | 129 | ceil( $this->getQuorum() * self::REQUIRED_OPPOSE_QUORUM_RATIO ) |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * |
| 137 | 137 | * @return int One of the OUTCOME_* constants |
| 138 | 138 | */ |
| 139 | - public function getOutcome(): int { |
|
| 139 | + public function getOutcome (): int { |
|
| 140 | 140 | if ( !$this->isVote() ) { |
| 141 | 141 | return self::OUTCOME_OK; |
| 142 | 142 | } |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | * @throws BadMethodCallException |
| 160 | 160 | * @throws LogicException |
| 161 | 161 | */ |
| 162 | - public function getOutcomeText(): string { |
|
| 162 | + public function getOutcomeText (): string { |
|
| 163 | 163 | if ( !$this->isVote() ) { |
| 164 | 164 | throw new BadMethodCallException( 'No need for an outcome text.' ); |
| 165 | 165 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * |
| 194 | 194 | * @return bool |
| 195 | 195 | */ |
| 196 | - public function isVote(): bool { |
|
| 196 | + public function isVote (): bool { |
|
| 197 | 197 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 198 | 198 | return !$this->matches( $sectionReg ); |
| 199 | 199 | } |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @return int |
| 205 | 205 | */ |
| 206 | - public function getCreationTimestamp(): int { |
|
| 206 | + public function getCreationTimestamp (): int { |
|
| 207 | 207 | return $this->wiki->getPageCreationTS( $this->title ); |
| 208 | 208 | } |
| 209 | 209 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * |
| 213 | 213 | * @return int |
| 214 | 214 | */ |
| 215 | - public function getEndTimestamp(): int { |
|
| 215 | + public function getEndTimestamp (): int { |
|
| 216 | 216 | if ( $this->isVote() ) { |
| 217 | 217 | $reg = "!La votazione ha inizio il.+ e ha termine il (\d+ \w+ \d+) alle ([\d:]+)!"; |
| 218 | 218 | [ , $day, $hours ] = $this->getMatch( $reg ); |
@@ -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,16 +137,16 @@ 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 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string $msg |
| 155 | 155 | * @return never |
| 156 | 156 | */ |
| 157 | - private function fatal( string $msg ): void { |
|
| 157 | + private function fatal ( string $msg ): void { |
|
| 158 | 158 | exit( $msg . "\n" ); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | * @param string $opt |
| 164 | 164 | * @return string |
| 165 | 165 | */ |
| 166 | - public function getSetOpt( string $opt ): string { |
|
| 167 | - return $this->opts[$opt]; |
|
| 166 | + public function getSetOpt ( string $opt ): string { |
|
| 167 | + return $this->opts[ $opt ]; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -172,14 +172,14 @@ discard block |
||
| 172 | 172 | * @param string|null $default |
| 173 | 173 | * @return string|null |
| 174 | 174 | */ |
| 175 | - public function getOpt( string $opt, string $default = null ): ?string { |
|
| 176 | - return $this->opts[$opt] ?? $default; |
|
| 175 | + public function getOpt ( string $opt, string $default = null ): ?string { |
|
| 176 | + return $this->opts[ $opt ] ?? $default; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
| 180 | 180 | * @return string[] Either [ 'tasks' => name1,... ] or [ 'subtasks' => name1,... ] |
| 181 | 181 | */ |
| 182 | - public function getTaskOpt(): array { |
|
| 182 | + public function getTaskOpt (): array { |
|
| 183 | 183 | return array_intersect_key( |
| 184 | 184 | $this->opts, |
| 185 | 185 | [ 'tasks' => true, 'subtasks' => true ] |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | /** |
| 190 | 190 | * @return string|null |
| 191 | 191 | */ |
| 192 | - public function getURL(): ?string { |
|
| 192 | + public function getURL (): ?string { |
|
| 193 | 193 | return $this->getOpt( 'force-url' ); |
| 194 | 194 | } |
| 195 | 195 | } |