@@ -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 | |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return string[] |
| 16 | 16 | */ |
| 17 | - abstract protected function getSubtasksMap() : array; |
|
| 17 | + abstract protected function getSubtasksMap () : array; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param string $subtask Defined in self::SUBTASKS_MAP |
| 21 | 21 | * @return TaskResult |
| 22 | 22 | */ |
| 23 | - protected function runSubtask( string $subtask ) : TaskResult { |
|
| 23 | + protected function runSubtask ( string $subtask ) : TaskResult { |
|
| 24 | 24 | $map = $this->getSubtasksMap(); |
| 25 | 25 | if ( !isset( $map[ $subtask ] ) ) { |
| 26 | 26 | throw new \InvalidArgumentException( "'$subtask' is not a valid task." ); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @inheritDoc |
| 35 | 35 | */ |
| 36 | - final public function getOperationName(): string { |
|
| 36 | + final public function getOperationName (): string { |
|
| 37 | 37 | return 'task'; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $class |
| 44 | 44 | * @return Subtask |
| 45 | 45 | */ |
| 46 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 46 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 47 | 47 | return new $class( $this->getDataProvider() ); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | /** |
| 3 | 3 | * Entry point for the bot, called by CLI |
| 4 | 4 | */ |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | /* URL (for debugging purpose) */ |
| 39 | 39 | $urlParam = getopt( '', [ 'force-url:' ] ); |
| 40 | -$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php'; |
|
| 40 | +$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php'; |
|
| 41 | 41 | |
| 42 | 42 | define( 'DEFAULT_URL', $url ); |
| 43 | 43 | |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | if ( count( $taskOpts ) === 2 ) { |
| 89 | 89 | throw new InvalidArgumentException( 'Cannot specify both task and subtask.' ); |
| 90 | -} elseif ( isset( $taskOpts['task'] ) ) { |
|
| 90 | +} elseif ( isset( $taskOpts[ 'task' ] ) ) { |
|
| 91 | 91 | $bot->runTask( $taskOpts[ 'task' ] ); |
| 92 | -} elseif ( isset( $taskOpts['subtask'] ) ) { |
|
| 92 | +} elseif ( isset( $taskOpts[ 'subtask' ] ) ) { |
|
| 93 | 93 | $bot->runSubtask( $taskOpts[ 'subtask' ] ); |
| 94 | 94 | } else { |
| 95 | 95 | $bot->runAll(); |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** @var Controller */ |
| 20 | 20 | private $controller; |
| 21 | 21 | |
| 22 | - public function __construct() { |
|
| 22 | + public function __construct () { |
|
| 23 | 23 | $this->setLogger( new Logger ); |
| 24 | 24 | $this->setConfig( Config::getInstance() ); |
| 25 | 25 | $this->setController( new Controller ); |
@@ -28,42 +28,42 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @return LoggerInterface |
| 30 | 30 | */ |
| 31 | - protected function getLogger() : LoggerInterface { |
|
| 31 | + protected function getLogger () : LoggerInterface { |
|
| 32 | 32 | return $this->logger; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @inheritDoc |
| 37 | 37 | */ |
| 38 | - public function setLogger( LoggerInterface $logger ) { |
|
| 38 | + public function setLogger ( LoggerInterface $logger ) { |
|
| 39 | 39 | $this->logger = $logger; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @return Config |
| 44 | 44 | */ |
| 45 | - protected function getConfig() : Config { |
|
| 45 | + protected function getConfig () : Config { |
|
| 46 | 46 | return $this->config; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param Config $cfg |
| 51 | 51 | */ |
| 52 | - protected function setConfig( Config $cfg ) { |
|
| 52 | + protected function setConfig ( Config $cfg ) { |
|
| 53 | 53 | $this->config = $cfg; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @return Controller |
| 58 | 58 | */ |
| 59 | - protected function getController() : Controller { |
|
| 59 | + protected function getController () : Controller { |
|
| 60 | 60 | return $this->controller; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @param Controller $controller |
| 65 | 65 | */ |
| 66 | - protected function setController( Controller $controller ) { |
|
| 66 | + protected function setController ( Controller $controller ) { |
|
| 67 | 67 | $this->controller = $controller; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param string $key |
| 74 | 74 | * @return Message |
| 75 | 75 | */ |
| 76 | - protected function msg( string $key ) : Message { |
|
| 76 | + protected function msg ( string $key ) : Message { |
|
| 77 | 77 | return new Message( $key ); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function runInternal() : int { |
|
| 14 | + public function runInternal () : int { |
|
| 15 | 15 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 16 | 16 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | return TaskResult::STATUS_NOTHING; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - $ricNums = []; |
|
| 22 | + $ricNums = [ ]; |
|
| 23 | 23 | foreach ( $pages as $page ) { |
| 24 | 24 | $ricNums[ $page->getUser()->getName() ] = $page->getNum(); |
| 25 | 25 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param string $user |
| 38 | 38 | * @param int $ricNum |
| 39 | 39 | */ |
| 40 | - protected function addMsg( string $user, int $ricNum ) { |
|
| 40 | + protected function addMsg ( string $user, int $ricNum ) { |
|
| 41 | 41 | $this->getLogger()->info( "Leaving msg to $user" ); |
| 42 | 42 | $msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text(); |
| 43 | 43 | |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | abstract class TaskBase extends ContextSource { |
| 13 | 13 | /** @var string[] */ |
| 14 | - protected $errors = []; |
|
| 14 | + protected $errors = [ ]; |
|
| 15 | 15 | /** @var TaskDataProvider */ |
| 16 | 16 | protected $dataProvider; |
| 17 | 17 | |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @param TaskDataProvider $dataProvider |
| 22 | 22 | */ |
| 23 | - final public function __construct( TaskDataProvider $dataProvider ) { |
|
| 23 | + final public function __construct ( TaskDataProvider $dataProvider ) { |
|
| 24 | 24 | set_exception_handler( [ $this, 'handleException' ] ); |
| 25 | 25 | set_error_handler( [ $this, 'handleError' ] ); |
| 26 | 26 | parent::__construct(); |
| 27 | 27 | $this->dataProvider = $dataProvider; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function __destruct() { |
|
| 30 | + public function __destruct () { |
|
| 31 | 31 | restore_error_handler(); |
| 32 | 32 | restore_exception_handler(); |
| 33 | 33 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return TaskResult |
| 39 | 39 | */ |
| 40 | - final public function run() : TaskResult { |
|
| 40 | + final public function run () : TaskResult { |
|
| 41 | 41 | $class = ( new \ReflectionClass( $this ) )->getShortName(); |
| 42 | 42 | $opName = $this->getOperationName(); |
| 43 | 43 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return int One of the STATUS_* constants |
| 70 | 70 | */ |
| 71 | - abstract protected function runInternal() : int; |
|
| 71 | + abstract protected function runInternal () : int; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * How this operation should be called in logs |
| 75 | 75 | * |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - abstract public function getOperationName() : string; |
|
| 78 | + abstract public function getOperationName () : string; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Exception handler. |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param \Throwable $ex |
| 84 | 84 | * @protected |
| 85 | 85 | */ |
| 86 | - public function handleException( \Throwable $ex ) { |
|
| 86 | + public function handleException ( \Throwable $ex ) { |
|
| 87 | 87 | $this->getLogger()->error( |
| 88 | 88 | ( new \ReflectionClass( $ex ) )->getShortName() . ': ' . |
| 89 | 89 | $ex->getMessage() . "\nin " . $ex->getFile() . ' line ' . |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | * @param int $errline |
| 101 | 101 | * @protected |
| 102 | 102 | */ |
| 103 | - public function handleError( $errno, $errstr, $errfile, $errline ) { |
|
| 103 | + public function handleError ( $errno, $errstr, $errfile, $errline ) { |
|
| 104 | 104 | throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline ); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @return TaskDataProvider |
| 109 | 109 | */ |
| 110 | - protected function getDataProvider() : TaskDataProvider { |
|
| 110 | + protected function getDataProvider () : TaskDataProvider { |
|
| 111 | 111 | return $this->dataProvider; |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -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 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @param string $domain The URL of the wiki, if different from default |
| 29 | 29 | */ |
| 30 | - public function __construct( string $domain = DEFAULT_URL ) { |
|
| 30 | + public function __construct ( string $domain = DEFAULT_URL ) { |
|
| 31 | 31 | $this->logger = new Logger; |
| 32 | 32 | $this->domain = $domain; |
| 33 | 33 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return string |
| 41 | 41 | * @throws MissingPageException |
| 42 | 42 | */ |
| 43 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 43 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 44 | 44 | $msg = "Retrieving content of page $title" . ( $section !== null ? ", section $section" : '' ); |
| 45 | 45 | $this->logger->debug( $msg ); |
| 46 | 46 | $params = [ |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | ]; |
| 53 | 53 | |
| 54 | 54 | if ( $section !== null ) { |
| 55 | - $params['rvsection'] = $section; |
|
| 55 | + $params[ 'rvsection' ] = $section; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | throw new MissingPageException( $title ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 65 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 66 | 66 | |
| 67 | 67 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
| 68 | 68 | throw new MissingSectionException( $title, $section ); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param array $params |
| 77 | 77 | * @throws EditException |
| 78 | 78 | */ |
| 79 | - public function editPage( array $params ) { |
|
| 79 | + public function editPage ( array $params ) { |
|
| 80 | 80 | $this->login(); |
| 81 | 81 | |
| 82 | 82 | $params = [ |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 99 | 99 | * @throws LoginException |
| 100 | 100 | */ |
| 101 | - public function login() { |
|
| 101 | + public function login () { |
|
| 102 | 102 | if ( self::$loggedIn ) { |
| 103 | 103 | return; |
| 104 | 104 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | self::$loggedIn = true; |
| 126 | 126 | // Clear tokens cache |
| 127 | - $this->tokens = []; |
|
| 127 | + $this->tokens = [ ]; |
|
| 128 | 128 | $this->logger->info( 'Login succeeded' ); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param string $type |
| 135 | 135 | * @return string |
| 136 | 136 | */ |
| 137 | - public function getToken( string $type ) : string { |
|
| 137 | + public function getToken ( string $type ) : string { |
|
| 138 | 138 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 139 | 139 | $params = [ |
| 140 | 140 | 'action' => 'query', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $title |
| 158 | 158 | * @return int |
| 159 | 159 | */ |
| 160 | - public function getPageCreationTS( string $title ) : int { |
|
| 160 | + public function getPageCreationTS ( string $title ) : int { |
|
| 161 | 161 | $params = [ |
| 162 | 162 | 'action' => 'query', |
| 163 | 163 | 'prop' => 'revisions', |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
| 172 | 172 | $data = $res->query->pages; |
| 173 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 173 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param string $title |
| 180 | 180 | * @param string $reason |
| 181 | 181 | */ |
| 182 | - public function protectPage( string $title, string $reason ) { |
|
| 182 | + public function protectPage ( string $title, string $reason ) { |
|
| 183 | 183 | $this->logger->info( "Protecting page $title" ); |
| 184 | 184 | $this->login(); |
| 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\Task\Subtask; |
| 4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function runInternal() : int { |
|
| 18 | + public function runInternal () : int { |
|
| 19 | 19 | $failed = $this->getFailures(); |
| 20 | 20 | if ( $failed ) { |
| 21 | 21 | $this->updateBurList( $failed ); |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return PageRiconferma[] |
| 34 | 34 | */ |
| 35 | - private function getFailures() : array { |
|
| 36 | - $ret = []; |
|
| 35 | + private function getFailures () : array { |
|
| 36 | + $ret = [ ]; |
|
| 37 | 37 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 38 | 38 | foreach ( $allPages as $page ) { |
| 39 | 39 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 40 | - $ret[] = $page; |
|
| 40 | + $ret[ ] = $page; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | return $ret; |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @param PageRiconferma[] $pages |
| 48 | 48 | */ |
| 49 | - protected function updateBurList( array $pages ) { |
|
| 49 | + protected function updateBurList ( array $pages ) { |
|
| 50 | 50 | $this->getLogger()->info( 'Checking if bur list needs updating.' ); |
| 51 | 51 | |
| 52 | - $remove = []; |
|
| 52 | + $remove = [ ]; |
|
| 53 | 53 | foreach ( $pages as $page ) { |
| 54 | 54 | $user = $page->getUser(); |
| 55 | 55 | if ( $user->inGroup( 'bureaucrat' ) && |
| 56 | 56 | ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) |
| 57 | 57 | ) { |
| 58 | - $remove[] = $user; |
|
| 58 | + $remove[ ] = $user; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param PageRiconferma[] $pages |
| 87 | 87 | */ |
| 88 | - protected function requestRemoval( array $pages ) { |
|
| 88 | + protected function requestRemoval ( array $pages ) { |
|
| 89 | 89 | $this->getLogger()->info( |
| 90 | 90 | 'Requesting removal on meta for: ' . implode( ', ', $pages ) |
| 91 | 91 | ); |
@@ -124,15 +124,15 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param PageRiconferma[] $pages |
| 126 | 126 | */ |
| 127 | - protected function updateAnnunci( array $pages ) { |
|
| 127 | + protected function updateAnnunci ( array $pages ) { |
|
| 128 | 128 | $this->getLogger()->info( 'Updating annunci' ); |
| 129 | 129 | $section = 1; |
| 130 | 130 | |
| 131 | - $names = []; |
|
| 131 | + $names = [ ]; |
|
| 132 | 132 | $text = ''; |
| 133 | 133 | foreach ( $pages as $page ) { |
| 134 | 134 | $user = $page->getUser()->getName(); |
| 135 | - $names[] = $user; |
|
| 135 | + $names[ ] = $user; |
|
| 136 | 136 | $text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " . |
| 137 | 137 | "non è stato riconfermato [[WP:A|amministratore]].}}\n"; |
| 138 | 138 | } |
@@ -167,16 +167,16 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @param PageRiconferma[] $pages |
| 169 | 169 | */ |
| 170 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 170 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 171 | 171 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 172 | 172 | $notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) ); |
| 173 | 173 | |
| 174 | - $names = []; |
|
| 174 | + $names = [ ]; |
|
| 175 | 175 | $text = ''; |
| 176 | 176 | foreach ( $pages as $page ) { |
| 177 | 177 | $user = $page->getUser()->getName(); |
| 178 | 178 | $title = $page->getTitle(); |
| 179 | - $names[] = $user; |
|
| 179 | + $names[ ] = $user; |
|
| 180 | 180 | $text .= "*'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " . |
| 181 | 181 | "[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{subst:NUMBEROFADMINS}} - 1}}.\n"; |
| 182 | 182 | } |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function runInternal() : int { |
|
| 18 | + public function runInternal () : int { |
|
| 19 | 19 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 20 | 20 | |
| 21 | 21 | if ( !$pages ) { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @param PageRiconferma[] $pages |
| 39 | 39 | */ |
| 40 | - protected function addToMainPage( array $pages ) { |
|
| 40 | + protected function addToMainPage ( array $pages ) { |
|
| 41 | 41 | $this->getLogger()->info( |
| 42 | 42 | 'Adding the following to main: ' . implode( ', ', $pages ) |
| 43 | 43 | ); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @param PageRiconferma[] $pages |
| 66 | 66 | */ |
| 67 | - protected function addToVotazioni( array $pages ) { |
|
| 67 | + protected function addToVotazioni ( array $pages ) { |
|
| 68 | 68 | $this->getLogger()->info( |
| 69 | 69 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
| 70 | 70 | ); |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 94 | 94 | // Replace semicolon with full stop |
| 95 | 95 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 96 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 ); |
|
| 96 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $summary = $this->msg( 'vote-page-summary' ) |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @param int $amount |
| 114 | 114 | */ |
| 115 | - protected function addToNews( int $amount ) { |
|
| 115 | + protected function addToNews ( int $amount ) { |
|
| 116 | 116 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 117 | 117 | $newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) ); |
| 118 | 118 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | throw new TaskException( 'Param not found in news page' ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $newNum = (int)$matches[2] + $amount; |
|
| 128 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 129 | 129 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 130 | 130 | |
| 131 | 131 | $summary = $this->msg( 'news-page-summary' ) |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function runInternal() : int { |
|
| 17 | + public function runInternal () : int { |
|
| 18 | 18 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 19 | 19 | |
| 20 | 20 | if ( !$pages ) { |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | * @param PageRiconferma[] $pages |
| 34 | 34 | * @see UpdatesAround::addToMainPage() |
| 35 | 35 | */ |
| 36 | - protected function removeFromMainPage( array $pages ) { |
|
| 36 | + protected function removeFromMainPage ( array $pages ) { |
|
| 37 | 37 | $this->getLogger()->info( |
| 38 | 38 | 'Removing from main: ' . implode( ', ', $pages ) |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | $mainPage = new Page( $this->getConfig()->get( 'main-page-title' ) ); |
| 42 | - $remove = []; |
|
| 42 | + $remove = [ ]; |
|
| 43 | 43 | foreach ( $pages as $page ) { |
| 44 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
| 44 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $summary = $this->msg( 'close-main-summary' ) |
@@ -59,17 +59,17 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @param PageRiconferma[] $pages |
| 61 | 61 | */ |
| 62 | - protected function addToArchive( array $pages ) { |
|
| 62 | + protected function addToArchive ( array $pages ) { |
|
| 63 | 63 | $this->getLogger()->info( |
| 64 | 64 | 'Adding to archive: ' . implode( ', ', $pages ) |
| 65 | 65 | ); |
| 66 | 66 | |
| 67 | - $simple = $votes = []; |
|
| 67 | + $simple = $votes = [ ]; |
|
| 68 | 68 | foreach ( $pages as $page ) { |
| 69 | 69 | if ( $page->isVote() ) { |
| 70 | - $votes[] = $page; |
|
| 70 | + $votes[ ] = $page; |
|
| 71 | 71 | } else { |
| 72 | - $simple[] = $page; |
|
| 72 | + $simple[ ] = $page; |
|
| 73 | 73 | } |
| 74 | 74 | } |
| 75 | 75 | |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | * @param string $archiveTitle |
| 87 | 87 | * @param array $pages |
| 88 | 88 | */ |
| 89 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 89 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 90 | 90 | $archivePage = new Page( "$archiveTitle/" . date( 'Y' ) ); |
| 91 | 91 | |
| 92 | 92 | $append = "\n"; |
| 93 | - $archivedList = []; |
|
| 93 | + $archivedList = [ ]; |
|
| 94 | 94 | foreach ( $pages as $page ) { |
| 95 | 95 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 96 | - $archivedList[] = $page->getUserNum(); |
|
| 96 | + $archivedList[ ] = $page->getUserNum(); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | $summary = $this->msg( 'close-archive-summary' ) |