@@ -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 | |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | const VERSION = 1.0; |
| 13 | 13 | |
| 14 | - public function __construct() { |
|
| 14 | + public function __construct () { |
|
| 15 | 15 | $this->logger = new Logger; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Entry point for the whole process |
| 20 | 20 | */ |
| 21 | - public function run() { |
|
| 21 | + public function run () { |
|
| 22 | 22 | $this->logger->info( 'Starting full process.' ); |
| 23 | 23 | $manager = new TaskManager; |
| 24 | 24 | $res = $manager->run( TaskManager::MODE_COMPLETE ); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param string $task |
| 37 | 37 | */ |
| 38 | - public function runTask( string $task ) { |
|
| 38 | + public function runTask ( string $task ) { |
|
| 39 | 39 | $this->logger->info( "Starting single task $task." ); |
| 40 | 40 | $manager = new TaskManager; |
| 41 | 41 | $res = $manager->run( TaskManager::MODE_TASK, $task ); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param string $subtask |
| 54 | 54 | */ |
| 55 | - public function runSubtask( string $subtask ) { |
|
| 55 | + public function runSubtask ( string $subtask ) { |
|
| 56 | 56 | $this->logger->info( "Starting single subtask $subtask." ); |
| 57 | 57 | $manager = new TaskManager; |
| 58 | 58 | $res = $manager->run( TaskManager::MODE_SUBTASK, $subtask ); |
@@ -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 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK |
| 48 | 48 | * @return TaskResult |
| 49 | 49 | */ |
| 50 | - public function run( int $mode, string $name = null ) : TaskResult { |
|
| 50 | + public function run ( int $mode, string $name = null ) : TaskResult { |
|
| 51 | 51 | $this->provider = new TaskDataProvider; |
| 52 | 52 | |
| 53 | 53 | if ( $mode === self::MODE_COMPLETE ) { |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return TaskResult |
| 66 | 66 | */ |
| 67 | - protected function runAllTasks() : TaskResult { |
|
| 67 | + protected function runAllTasks () : TaskResult { |
|
| 68 | 68 | if ( self::getLastFullRunDate() === date( 'd/m/Y' ) ) { |
| 69 | 69 | // Really avoid executing twice the same day |
| 70 | 70 | return new TaskResult( TaskResult::STATUS_ERROR, [ 'A full run was already executed today.' ] ); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $name |
| 96 | 96 | * @return TaskResult |
| 97 | 97 | */ |
| 98 | - protected function runTask( string $name ) : TaskResult { |
|
| 98 | + protected function runTask ( string $name ) : TaskResult { |
|
| 99 | 99 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 100 | 100 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
| 101 | 101 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param string $name |
| 111 | 111 | * @return TaskResult |
| 112 | 112 | */ |
| 113 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 113 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 114 | 114 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 115 | 115 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 116 | 116 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @return string|null d/m/Y or null if no last run registered |
| 125 | 125 | * @fixme Is this even necessary? |
| 126 | 126 | */ |
| 127 | - public static function getLastFullRunDate() : ?string { |
|
| 127 | + public static function getLastFullRunDate () : ?string { |
|
| 128 | 128 | if ( file_exists( self::LOG_FILE ) ) { |
| 129 | 129 | return file_get_contents( self::LOG_FILE ) ?: null; |
| 130 | 130 | } else { |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @param string $class |
| 139 | 139 | * @return Task |
| 140 | 140 | */ |
| 141 | - private function getTaskInstance( string $class ) : Task { |
|
| 141 | + private function getTaskInstance ( string $class ) : Task { |
|
| 142 | 142 | return new $class( $this->provider ); |
| 143 | 143 | } |
| 144 | 144 | |
@@ -148,11 +148,11 @@ discard block |
||
| 148 | 148 | * @param string $class |
| 149 | 149 | * @return Subtask |
| 150 | 150 | */ |
| 151 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 151 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 152 | 152 | return new $class( $this->provider ); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public static function setLastFullRunDate() { |
|
| 155 | + public static function setLastFullRunDate () { |
|
| 156 | 156 | file_put_contents( self::LOG_FILE, date( 'd/m/Y' ) ); |
| 157 | 157 | } |
| 158 | 158 | } |
@@ -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->run(); |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function run() : TaskResult { |
|
| 18 | + public function run () : TaskResult { |
|
| 19 | 19 | $orderedList = [ |
| 20 | 20 | 'close-pages', |
| 21 | 21 | 'archive-pages', |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - protected function getSubtasksMap(): array { |
|
| 37 | + protected function getSubtasksMap (): array { |
|
| 38 | 38 | return [ |
| 39 | 39 | 'archive-pages' => ArchivePages::class, |
| 40 | 40 | 'close-pages' => ClosePages::class, |
@@ -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 run() : TaskResult { |
|
| 17 | + public function run () : TaskResult { |
|
| 18 | 18 | $this->getLogger()->info( 'Starting task ClosePages' ); |
| 19 | 19 | |
| 20 | 20 | $pages = $this->getDataProvider()->getPagesToClose(); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @param PageRiconferma $page |
| 36 | 36 | */ |
| 37 | - protected function addVoteCloseText( PageRiconferma $page ) { |
|
| 37 | + protected function addVoteCloseText ( PageRiconferma $page ) { |
|
| 38 | 38 | $content = $page->getContent(); |
| 39 | 39 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!'; |
| 40 | 40 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -50,15 +50,14 @@ discard block |
||
| 50 | 50 | * @param PageRiconferma $page |
| 51 | 51 | * @see CreatePages::updateBasePage() |
| 52 | 52 | */ |
| 53 | - protected function updateBasePage( PageRiconferma $page ) { |
|
| 53 | + protected function updateBasePage ( PageRiconferma $page ) { |
|
| 54 | 54 | $this->getLogger()->info( "Updating base page for $page" ); |
| 55 | 55 | |
| 56 | 56 | $basePage = new Page( $page->getBaseTitle() ); |
| 57 | 57 | $current = $basePage->getContent(); |
| 58 | 58 | |
| 59 | 59 | $outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ? |
| 60 | - 'non riconfermato' : |
|
| 61 | - 'riconfermato'; |
|
| 60 | + 'non riconfermato' : 'riconfermato'; |
|
| 62 | 61 | $text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita'; |
| 63 | 62 | |
| 64 | 63 | $newContent = str_replace( 'riconferma in corso', $text, $current ); |
@@ -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 | |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | /** @var array[] */ |
| 16 | 16 | private $allUsers; |
| 17 | 17 | /** @var PageRiconferma[] */ |
| 18 | - private $createdPages = []; |
|
| 18 | + private $createdPages = [ ]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Get the full content of the JSON users list |
| 22 | 22 | * |
| 23 | 23 | * @return array[] |
| 24 | 24 | */ |
| 25 | - public function getUsersList() : array { |
|
| 25 | + public function getUsersList () : array { |
|
| 26 | 26 | if ( $this->allUsers === null ) { |
| 27 | 27 | $this->getLogger()->debug( 'Retrieving users list' ); |
| 28 | 28 | $this->allUsers = PageBotList::get()->getAdminsList(); |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return array[] |
| 38 | 38 | */ |
| 39 | - public function getUsersToProcess() : array { |
|
| 39 | + public function getUsersToProcess () : array { |
|
| 40 | 40 | if ( $this->processUsers === null ) { |
| 41 | - $this->processUsers = []; |
|
| 41 | + $this->processUsers = [ ]; |
|
| 42 | 42 | foreach ( $this->getUsersList() as $user => $groups ) { |
| 43 | 43 | $timestamp = $this->getValidTimestamp( $groups ); |
| 44 | 44 | |
@@ -60,13 +60,11 @@ discard block |
||
| 60 | 60 | * @param array $groups |
| 61 | 61 | * @return int |
| 62 | 62 | */ |
| 63 | - private function getValidTimestamp( array $groups ) : int { |
|
| 63 | + private function getValidTimestamp ( array $groups ) : int { |
|
| 64 | 64 | $checkuser = isset( $groups[ 'checkuser' ] ) ? |
| 65 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : |
|
| 66 | - 0; |
|
| 65 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 67 | 66 | $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
| 68 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : |
|
| 69 | - 0; |
|
| 67 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 70 | 68 | |
| 71 | 69 | $timestamp = max( $bureaucrat, $checkuser ); |
| 72 | 70 | if ( $timestamp === 0 ) { |
@@ -80,7 +78,7 @@ discard block |
||
| 80 | 78 | * |
| 81 | 79 | * @return PageRiconferma[] |
| 82 | 80 | */ |
| 83 | - public function getOpenPages() : array { |
|
| 81 | + public function getOpenPages () : array { |
|
| 84 | 82 | static $list = null; |
| 85 | 83 | if ( $list === null ) { |
| 86 | 84 | $baseTitle = $this->getConfig()->get( 'ric-main-page' ); |
@@ -94,10 +92,10 @@ discard block |
||
| 94 | 92 | |
| 95 | 93 | $res = RequestBase::newFromParams( $params )->execute(); |
| 96 | 94 | $pages = $res->query->pages; |
| 97 | - $list = []; |
|
| 95 | + $list = [ ]; |
|
| 98 | 96 | foreach ( reset( $pages )->templates as $page ) { |
| 99 | 97 | if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) { |
| 100 | - $list[] = new PageRiconferma( $page->title ); |
|
| 98 | + $list[ ] = new PageRiconferma( $page->title ); |
|
| 101 | 99 | } |
| 102 | 100 | } |
| 103 | 101 | } |
@@ -110,14 +108,14 @@ discard block |
||
| 110 | 108 | * |
| 111 | 109 | * @return PageRiconferma[] |
| 112 | 110 | */ |
| 113 | - public function getPagesToClose() : array { |
|
| 111 | + public function getPagesToClose () : array { |
|
| 114 | 112 | static $list = null; |
| 115 | 113 | if ( $list === null ) { |
| 116 | 114 | $allPages = $this->getOpenPages(); |
| 117 | - $list = []; |
|
| 115 | + $list = [ ]; |
|
| 118 | 116 | foreach ( $allPages as $page ) { |
| 119 | 117 | if ( time() > $page->getEndTimestamp() ) { |
| 120 | - $list[] = $page; |
|
| 118 | + $list[ ] = $page; |
|
| 121 | 119 | } |
| 122 | 120 | } |
| 123 | 121 | } |
@@ -129,21 +127,21 @@ discard block |
||
| 129 | 127 | * |
| 130 | 128 | * @param string $name |
| 131 | 129 | */ |
| 132 | - public function removeUser( string $name ) { |
|
| 130 | + public function removeUser ( string $name ) { |
|
| 133 | 131 | unset( $this->processUsers[ $name ] ); |
| 134 | 132 | } |
| 135 | 133 | |
| 136 | 134 | /** |
| 137 | 135 | * @return PageRiconferma[] |
| 138 | 136 | */ |
| 139 | - public function getCreatedPages() : array { |
|
| 137 | + public function getCreatedPages () : array { |
|
| 140 | 138 | return $this->createdPages; |
| 141 | 139 | } |
| 142 | 140 | |
| 143 | 141 | /** |
| 144 | 142 | * @param PageRiconferma $page |
| 145 | 143 | */ |
| 146 | - public function addCreatedPages( PageRiconferma $page ) { |
|
| 147 | - $this->createdPages[] = $page; |
|
| 144 | + public function addCreatedPages ( PageRiconferma $page ) { |
|
| 145 | + $this->createdPages[ ] = $page; |
|
| 148 | 146 | } |
| 149 | 147 | } |
@@ -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 | |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * @inheritDoc |
| 21 | 21 | */ |
| 22 | - protected function getSubtasksMap(): array { |
|
| 22 | + protected function getSubtasksMap (): array { |
|
| 23 | 23 | // Everything is done here. |
| 24 | - return []; |
|
| 24 | + return [ ]; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @inheritDoc |
| 29 | 29 | */ |
| 30 | - public function run() : TaskResult { |
|
| 30 | + public function run () : TaskResult { |
|
| 31 | 31 | $this->getLogger()->info( 'Starting task UpdateList' ); |
| 32 | 32 | $this->actualList = $this->getActualAdmins(); |
| 33 | 33 | $this->botList = $this->getDataProvider()->getUsersList(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @return array |
| 69 | 69 | */ |
| 70 | - protected function getActualAdmins() : array { |
|
| 70 | + protected function getActualAdmins () : array { |
|
| 71 | 71 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 72 | 72 | $params = [ |
| 73 | 73 | 'action' => 'query', |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @param \stdClass $data |
| 86 | 86 | * @return array |
| 87 | 87 | */ |
| 88 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 89 | - $ret = []; |
|
| 88 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 89 | + $ret = [ ]; |
|
| 90 | 90 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 91 | 91 | foreach ( $data->query->allusers as $u ) { |
| 92 | 92 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -103,22 +103,22 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return array[] |
| 105 | 105 | */ |
| 106 | - protected function getMissingGroups() : array { |
|
| 107 | - $missing = []; |
|
| 106 | + protected function getMissingGroups () : array { |
|
| 107 | + $missing = [ ]; |
|
| 108 | 108 | foreach ( $this->actualList as $adm => $groups ) { |
| 109 | - $groupsList = []; |
|
| 109 | + $groupsList = [ ]; |
|
| 110 | 110 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 111 | 111 | $groupsList = $groups; |
| 112 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 112 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 113 | 113 | // Only some groups are missing |
| 114 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 114 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | foreach ( $groupsList as $group ) { |
| 118 | 118 | try { |
| 119 | 119 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 120 | 120 | } catch ( TaskException $e ) { |
| 121 | - $this->errors[] = $e->getMessage(); |
|
| 121 | + $this->errors[ ] = $e->getMessage(); |
|
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @return string |
| 134 | 134 | * @throws TaskException |
| 135 | 135 | */ |
| 136 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 136 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 137 | 137 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 138 | 138 | |
| 139 | 139 | $url = DEFAULT_URL; |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param string $group |
| 169 | 169 | * @return string|null |
| 170 | 170 | */ |
| 171 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 171 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 172 | 172 | $ts = null; |
| 173 | 173 | foreach ( $data->query->logevents as $entry ) { |
| 174 | 174 | if ( !isset( $entry->params ) ) { |
@@ -190,8 +190,8 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return array[] |
| 192 | 192 | */ |
| 193 | - protected function getExtraGroups() : array { |
|
| 194 | - $extra = []; |
|
| 193 | + protected function getExtraGroups () : array { |
|
| 194 | + $extra = [ ]; |
|
| 195 | 195 | foreach ( $this->botList as $name => $groups ) { |
| 196 | 196 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 197 | 197 | $extra[ $name ] = $groups; |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @param array[] $extra |
| 210 | 210 | * @return array[] |
| 211 | 211 | */ |
| 212 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 212 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 213 | 213 | $newContent = $this->botList; |
| 214 | 214 | foreach ( $newContent as $user => $groups ) { |
| 215 | 215 | if ( isset( $missing[ $user ] ) ) { |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Page; |
| 4 | 4 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @private Use self::get() |
| 13 | 13 | */ |
| 14 | - public function __construct() { |
|
| 14 | + public function __construct () { |
|
| 15 | 15 | parent::__construct( Config::getInstance()->get( 'list-title' ) ); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return self |
| 22 | 22 | */ |
| 23 | - public static function get() : self { |
|
| 23 | + public static function get () : self { |
|
| 24 | 24 | static $instance = null; |
| 25 | 25 | if ( $instance === null ) { |
| 26 | 26 | $instance = new self; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return array[] |
| 35 | 35 | */ |
| 36 | - public function getAdminsList() : array { |
|
| 36 | + public function getAdminsList () : array { |
|
| 37 | 37 | return json_decode( $this->getContent(), true ); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -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 run() : TaskResult { |
|
| 18 | + public function run () : TaskResult { |
|
| 19 | 19 | $this->getLogger()->info( 'Starting task UpdatesAround' ); |
| 20 | 20 | |
| 21 | 21 | $pages = $this->getDataProvider()->getCreatedPages(); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @param PageRiconferma[] $pages |
| 41 | 41 | */ |
| 42 | - protected function addToMainPage( array $pages ) { |
|
| 42 | + protected function addToMainPage ( array $pages ) { |
|
| 43 | 43 | $this->getLogger()->info( |
| 44 | 44 | 'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 45 | 45 | ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param PageRiconferma[] $pages |
| 68 | 68 | */ |
| 69 | - protected function addVote( array $pages ) { |
|
| 69 | + protected function addVote ( array $pages ) { |
|
| 70 | 70 | $this->getLogger()->info( |
| 71 | 71 | 'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 72 | 72 | ); |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 96 | 96 | // Replace semicolon with full stop |
| 97 | 97 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 98 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 ); |
|
| 98 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 ); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $summary = $this->msg( 'ric-vote-page-summary' ) |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @param int $amount |
| 116 | 116 | */ |
| 117 | - protected function addNews( int $amount ) { |
|
| 117 | + protected function addNews ( int $amount ) { |
|
| 118 | 118 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 119 | 119 | $newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) ); |
| 120 | 120 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | throw new TaskException( 'Param not found in news page' ); |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - $newNum = (int)$matches[2] + $amount; |
|
| 130 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 131 | 131 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 132 | 132 | |
| 133 | 133 | $summary = $this->msg( 'ric-news-page-summary' ) |