@@ -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,15 +115,15 @@ 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 | |
@@ -155,16 +155,16 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param PageRiconferma[] $pages |
| 157 | 157 | */ |
| 158 | - protected function updateUltimeNotizie( array $pages ) : void { |
|
| 158 | + protected function updateUltimeNotizie ( array $pages ) : void { |
|
| 159 | 159 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 160 | 160 | $notiziePage = $this->getPage( $this->getOpt( 'ultimenotizie-page-title' ) ); |
| 161 | 161 | |
| 162 | - $names = []; |
|
| 162 | + $names = [ ]; |
|
| 163 | 163 | $text = ''; |
| 164 | 164 | $msg = $this->msg( 'ultimenotizie-text' ); |
| 165 | 165 | foreach ( $pages as $page ) { |
| 166 | 166 | $user = $page->getUserName(); |
| 167 | - $names[] = $user; |
|
| 167 | + $names[ ] = $user; |
|
| 168 | 168 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | * |
| 193 | 193 | * @param PageRiconferma[] $pages |
| 194 | 194 | */ |
| 195 | - protected function updateTimeline( array $pages ) : void { |
|
| 195 | + protected function updateTimeline ( array $pages ) : void { |
|
| 196 | 196 | $this->getLogger()->info( 'Updating timeline' ); |
| 197 | 197 | $timelinePage = $this->getPage( $this->getOpt( 'timeline-page-title' ) ); |
| 198 | 198 | $content = $timelinePage->getContent(); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @param PageRiconferma[] $pages |
| 222 | 222 | */ |
| 223 | - private function updateCronologia( array $pages ) : void { |
|
| 223 | + private function updateCronologia ( array $pages ) : void { |
|
| 224 | 224 | $this->getLogger()->info( 'Updating cronologia' ); |
| 225 | 225 | $timelinePage = $this->getPage( $this->getOpt( 'cronologia-page-title' ) ); |
| 226 | 226 | $content = $timelinePage->getContent(); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @param PageRiconferma[] $pages |
| 249 | 249 | */ |
| 250 | - private function blockOnPrivate( array $pages ) : void { |
|
| 250 | + private function blockOnPrivate ( array $pages ) : void { |
|
| 251 | 251 | $this->getLogger()->info( 'Blocking on private wiki: ' . implode( ', ', $pages ) ); |
| 252 | 252 | |
| 253 | 253 | $privWiki = $this->getWikiGroup()->getPrivateWiki(); |
@@ -264,12 +264,12 @@ discard block |
||
| 264 | 264 | * @param PageRiconferma[] $pages |
| 265 | 265 | * @return User[] |
| 266 | 266 | */ |
| 267 | - private function getFailedBureaucrats( array $pages ) : array { |
|
| 268 | - $ret = []; |
|
| 267 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
| 268 | + $ret = [ ]; |
|
| 269 | 269 | foreach ( $pages as $page ) { |
| 270 | 270 | $user = $this->getUser( $page->getUserName() ); |
| 271 | 271 | if ( $user->inGroup( 'bureaucrat' ) ) { |
| 272 | - $ret[] = $user; |
|
| 272 | + $ret[ ] = $user; |
|
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | 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 | |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * @return bool |
| 67 | 67 | */ |
| 68 | - public static function isCLI() : bool { |
|
| 68 | + public static function isCLI () : bool { |
|
| 69 | 69 | return PHP_SAPI === 'cli'; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
| 73 | 73 | * Populate options and check for required ones |
| 74 | 74 | */ |
| 75 | - public function __construct() { |
|
| 75 | + public function __construct () { |
|
| 76 | 76 | $opts = getopt( self::SHORT_OPTS, self::LONG_OPTS ); |
| 77 | 77 | $this->checkRequiredOpts( $opts ); |
| 78 | 78 | $this->checkConflictingOpts( $opts ); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * @param array $opts |
| 85 | 85 | */ |
| 86 | - private function checkRequiredOpts( array $opts ) : void { |
|
| 86 | + private function checkRequiredOpts ( array $opts ) : void { |
|
| 87 | 87 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
| 88 | 88 | if ( $missingOpts ) { |
| 89 | 89 | exit( 'Required options missing: ' . implode( ', ', $missingOpts ) ); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | /** |
| 106 | 106 | * @param array $opts |
| 107 | 107 | */ |
| 108 | - private function checkConflictingOpts( array $opts ) : void { |
|
| 108 | + private function checkConflictingOpts ( array $opts ) : void { |
|
| 109 | 109 | $hasPw = array_key_exists( 'password', $opts ); |
| 110 | 110 | $hasPwFile = array_key_exists( 'use-password-file', $opts ); |
| 111 | 111 | if ( $hasPw && $hasPwFile ) { |
@@ -130,16 +130,16 @@ discard block |
||
| 130 | 130 | /** |
| 131 | 131 | * @param array &$opts |
| 132 | 132 | */ |
| 133 | - private function canonicalize( array &$opts ) : void { |
|
| 133 | + private function canonicalize ( array &$opts ) : void { |
|
| 134 | 134 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
| 135 | 135 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
| 136 | - $opts['password'] = $pw; |
|
| 137 | - unset( $opts['use-password-file'] ); |
|
| 136 | + $opts[ 'password' ] = $pw; |
|
| 137 | + unset( $opts[ 'use-password-file' ] ); |
|
| 138 | 138 | } |
| 139 | 139 | if ( array_key_exists( 'use-private-password-file', $opts ) ) { |
| 140 | 140 | $pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) ); |
| 141 | - $opts['private-password'] = $pw; |
|
| 142 | - unset( $opts['use-private-password-file'] ); |
|
| 141 | + $opts[ 'private-password' ] = $pw; |
|
| 142 | + unset( $opts[ 'use-private-password-file' ] ); |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | * @param mixed|null $default |
| 149 | 149 | * @return mixed |
| 150 | 150 | */ |
| 151 | - public function getOpt( string $opt, $default = null ) { |
|
| 152 | - return $this->opts[$opt] ?? $default; |
|
| 151 | + public function getOpt ( string $opt, $default = null ) { |
|
| 152 | + return $this->opts[ $opt ] ?? $default; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | 156 | * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ] |
| 157 | 157 | */ |
| 158 | - public function getTaskOpt() : array { |
|
| 158 | + public function getTaskOpt () : array { |
|
| 159 | 159 | return array_intersect_key( |
| 160 | 160 | $this->opts, |
| 161 | 161 | [ 'task' => true, 'subtask' => true ] |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | /** |
| 166 | 166 | * @return string|null |
| 167 | 167 | */ |
| 168 | - public function getURL() : ?string { |
|
| 168 | + public function getURL () : ?string { |
|
| 169 | 169 | return $this->getOpt( 'force-url' ); |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -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 | } |
@@ -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 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param LoggerInterface $logger |
| 37 | 37 | * @param RequestFactory $requestFactory |
| 38 | 38 | */ |
| 39 | - public function __construct( |
|
| 39 | + public function __construct ( |
|
| 40 | 40 | LoginInfo $li, |
| 41 | 41 | LoggerInterface $logger, |
| 42 | 42 | RequestFactory $requestFactory |
@@ -49,35 +49,35 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @return LoginInfo |
| 51 | 51 | */ |
| 52 | - public function getLoginInfo() : LoginInfo { |
|
| 52 | + public function getLoginInfo () : LoginInfo { |
|
| 53 | 53 | return $this->loginInfo; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @return RequestFactory |
| 58 | 58 | */ |
| 59 | - public function getRequestFactory() : RequestFactory { |
|
| 59 | + public function getRequestFactory () : RequestFactory { |
|
| 60 | 60 | return $this->requestFactory; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @param string $prefix |
| 65 | 65 | */ |
| 66 | - public function setPagePrefix( string $prefix ) : void { |
|
| 66 | + public function setPagePrefix ( string $prefix ) : void { |
|
| 67 | 67 | $this->pagePrefix = $prefix; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @param string $ident |
| 72 | 72 | */ |
| 73 | - public function setLocalUserIdentifier( string $ident ) : void { |
|
| 73 | + public function setLocalUserIdentifier ( string $ident ) : void { |
|
| 74 | 74 | $this->localUserIdentifier = $ident; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * @return string |
| 79 | 79 | */ |
| 80 | - public function getLocalUserIdentifier() : string { |
|
| 80 | + public function getLocalUserIdentifier () : string { |
|
| 81 | 81 | return $this->localUserIdentifier; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @throws MissingPageException |
| 91 | 91 | * @throws MissingSectionException |
| 92 | 92 | */ |
| 93 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 93 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 94 | 94 | $fullTitle = $this->pagePrefix . $title; |
| 95 | 95 | $msg = "Retrieving content of $fullTitle" . ( $section !== null ? ", section $section" : '' ); |
| 96 | 96 | $this->logger->info( $msg ); |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | ]; |
| 104 | 104 | |
| 105 | 105 | if ( $section !== null ) { |
| 106 | - $params['rvsection'] = $section; |
|
| 106 | + $params[ 'rvsection' ] = $section; |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | $req = $this->buildRequest( $params ); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | throw new MissingPageException( $title ); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 116 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 117 | 117 | |
| 118 | 118 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
| 119 | 119 | throw new MissingSectionException( $title, $section ); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param array $params |
| 128 | 128 | * @throws EditException |
| 129 | 129 | */ |
| 130 | - public function editPage( array $params ) : void { |
|
| 130 | + public function editPage ( array $params ) : void { |
|
| 131 | 131 | $this->login(); |
| 132 | 132 | |
| 133 | 133 | $params = [ |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | ] + $params; |
| 137 | 137 | |
| 138 | 138 | if ( BOT_EDITS === true ) { |
| 139 | - $params['bot'] = 1; |
|
| 139 | + $params[ 'bot' ] = 1; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $res = $this->buildRequest( $params )->setPost()->execute(); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 155 | 155 | * @throws LoginException |
| 156 | 156 | */ |
| 157 | - public function login() : void { |
|
| 157 | + public function login () : void { |
|
| 158 | 158 | if ( $this->loginInfo === null ) { |
| 159 | 159 | throw new CannotLoginException( 'Missing login data' ); |
| 160 | 160 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | |
| 185 | 185 | $this->loggedIn = true; |
| 186 | 186 | // Clear tokens cache |
| 187 | - $this->tokens = []; |
|
| 187 | + $this->tokens = [ ]; |
|
| 188 | 188 | $this->logger->info( 'Login succeeded' ); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * @param string $type |
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | - public function getToken( string $type ) : string { |
|
| 197 | + public function getToken ( string $type ) : string { |
|
| 198 | 198 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 199 | 199 | $params = [ |
| 200 | 200 | 'action' => 'query', |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param string $title |
| 218 | 218 | * @return int |
| 219 | 219 | */ |
| 220 | - public function getPageCreationTS( string $title ) : int { |
|
| 220 | + public function getPageCreationTS ( string $title ) : int { |
|
| 221 | 221 | $params = [ |
| 222 | 222 | 'action' => 'query', |
| 223 | 223 | 'prop' => 'revisions', |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $res = $this->buildRequest( $params )->execute(); |
| 232 | 232 | $data = $res->query->pages; |
| 233 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 233 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | * @param string $title |
| 240 | 240 | * @param string $reason |
| 241 | 241 | */ |
| 242 | - public function protectPage( string $title, string $reason ) : void { |
|
| 242 | + public function protectPage ( string $title, string $reason ) : void { |
|
| 243 | 243 | $fullTitle = $this->pagePrefix . $title; |
| 244 | 244 | $this->logger->info( "Protecting page $fullTitle" ); |
| 245 | 245 | $this->login(); |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @param string $username |
| 263 | 263 | * @param string $reason |
| 264 | 264 | */ |
| 265 | - public function blockUser( string $username, string $reason ) : void { |
|
| 265 | + public function blockUser ( string $username, string $reason ) : void { |
|
| 266 | 266 | $this->logger->info( "Blocking user $username" ); |
| 267 | 267 | $this->login(); |
| 268 | 268 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * @param array $params |
| 289 | 289 | * @return RequestBase |
| 290 | 290 | */ |
| 291 | - private function buildRequest( array $params ) : RequestBase { |
|
| 291 | + private function buildRequest ( array $params ) : RequestBase { |
|
| 292 | 292 | return $this->requestFactory->newFromParams( $params ); |
| 293 | 293 | } |
| 294 | 294 | } |