@@ -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,7 +11,7 @@ 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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $mode |
| 22 | 22 | * @param string|null $name |
| 23 | 23 | */ |
| 24 | - private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) { |
|
| 24 | + private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) { |
|
| 25 | 25 | $activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name"; |
| 26 | 26 | $this->logger->info( "Running $activity" ); |
| 27 | 27 | $manager = new TaskManager; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Entry point for the whole process |
| 39 | 39 | */ |
| 40 | - public function runAll() { |
|
| 40 | + public function runAll () { |
|
| 41 | 41 | $this->run(); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @param string $task |
| 48 | 48 | */ |
| 49 | - public function runTask( string $task ) { |
|
| 49 | + public function runTask ( string $task ) { |
|
| 50 | 50 | $this->run( TaskManager::MODE_TASK, $task ); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param string $subtask |
| 57 | 57 | */ |
| 58 | - public function runSubtask( string $subtask ) { |
|
| 58 | + public function runSubtask ( string $subtask ) { |
|
| 59 | 59 | $this->run( TaskManager::MODE_SUBTASK, $subtask ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -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()->getCreatedPages(); |
| 19 | 19 | |
| 20 | 20 | if ( !$pages ) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param PageRiconferma[] $pages |
| 38 | 38 | */ |
| 39 | - protected function addToMainPage( array $pages ) { |
|
| 39 | + protected function addToMainPage ( array $pages ) { |
|
| 40 | 40 | $this->getLogger()->info( |
| 41 | 41 | 'Adding the following to main: ' . implode( ', ', $pages ) |
| 42 | 42 | ); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @param PageRiconferma[] $pages |
| 65 | 65 | */ |
| 66 | - protected function addToVotazioni( array $pages ) { |
|
| 66 | + protected function addToVotazioni ( array $pages ) { |
|
| 67 | 67 | $this->getLogger()->info( |
| 68 | 68 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
| 69 | 69 | ); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @param int $amount |
| 97 | 97 | * @throws TaskException |
| 98 | 98 | */ |
| 99 | - protected function addToNews( int $amount ) { |
|
| 99 | + protected function addToNews ( int $amount ) { |
|
| 100 | 100 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 101 | 101 | $newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) ); |
| 102 | 102 | |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | throw new TaskException( 'Param not found in news page' ); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - $newNum = (int)$matches[2] + $amount; |
|
| 112 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 113 | 113 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 114 | 114 | |
| 115 | 115 | $summary = $this->msg( 'news-page-summary' ) |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Exception; |
| 4 | 4 | |
@@ -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 | |
@@ -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; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param string[] $groups |
| 33 | 33 | * @return int|null |
| 34 | 34 | */ |
| 35 | - public static function getOverrideTimestamp( array $groups ) : ?int { |
|
| 35 | + public static function getOverrideTimestamp ( array $groups ) : ?int { |
|
| 36 | 36 | if ( array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) { |
| 37 | 37 | // A one-time override takes precedence |
| 38 | 38 | $day = $groups[ 'override' ] ?? $groups[ 'override-perm' ]; |
@@ -48,17 +48,15 @@ discard block |
||
| 48 | 48 | * @param array $groups |
| 49 | 49 | * @return int |
| 50 | 50 | */ |
| 51 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
| 52 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
| 53 | - \DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
| 54 | - 0; |
|
| 55 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
| 56 | - \DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
| 57 | - 0; |
|
| 51 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
| 52 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
| 53 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 54 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
| 55 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 58 | 56 | |
| 59 | 57 | $timestamp = max( $bureaucrat, $checkuser ); |
| 60 | 58 | if ( $timestamp === 0 ) { |
| 61 | - $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
| 59 | + $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
| 62 | 60 | } |
| 63 | 61 | return $timestamp; |
| 64 | 62 | } |
@@ -68,7 +66,7 @@ discard block |
||
| 68 | 66 | * |
| 69 | 67 | * @return array[] |
| 70 | 68 | */ |
| 71 | - public function getAdminsList() : array { |
|
| 69 | + public function getAdminsList () : array { |
|
| 72 | 70 | return json_decode( $this->getContent(), true ); |
| 73 | 71 | } |
| 74 | 72 | } |
@@ -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 | $newContent = str_replace( $remove, '', $mainPage->getContent() ); |
@@ -70,17 +70,17 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param PageRiconferma[] $pages |
| 72 | 72 | */ |
| 73 | - protected function addToArchive( array $pages ) { |
|
| 73 | + protected function addToArchive ( array $pages ) { |
|
| 74 | 74 | $this->getLogger()->info( |
| 75 | 75 | 'Adding to archive: ' . implode( ', ', $pages ) |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $simple = $votes = []; |
|
| 78 | + $simple = $votes = [ ]; |
|
| 79 | 79 | foreach ( $pages as $page ) { |
| 80 | 80 | if ( $page->isVote() ) { |
| 81 | - $votes[] = $page; |
|
| 81 | + $votes[ ] = $page; |
|
| 82 | 82 | } else { |
| 83 | - $simple[] = $page; |
|
| 83 | + $simple[ ] = $page; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | * @param string $archiveTitle |
| 102 | 102 | * @param array $pages |
| 103 | 103 | */ |
| 104 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 104 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 105 | 105 | $archivePage = new Page( "$archiveTitle/" . date( 'Y' ) ); |
| 106 | 106 | $exists = $archivePage->exists(); |
| 107 | 107 | |
| 108 | 108 | $append = "\n"; |
| 109 | - $archivedList = []; |
|
| 109 | + $archivedList = [ ]; |
|
| 110 | 110 | foreach ( $pages as $page ) { |
| 111 | 111 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 112 | - $archivedList[] = $page->getUserNum(); |
|
| 112 | + $archivedList[ ] = $page->getUserNum(); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @param string $archiveTitle |
| 132 | 132 | */ |
| 133 | - private function addArchiveYear( string $archiveTitle ) { |
|
| 133 | + private function addArchiveYear ( string $archiveTitle ) { |
|
| 134 | 134 | $page = new Page( $archiveTitle ); |
| 135 | 135 | $year = date( 'Y' ); |
| 136 | 136 | |
@@ -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 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param string $title |
| 23 | 23 | * @param string $domain The site where the page lives, if different from default |
| 24 | 24 | */ |
| 25 | - public function __construct( string $title, string $domain = DEFAULT_URL ) { |
|
| 25 | + public function __construct ( string $title, string $domain = DEFAULT_URL ) { |
|
| 26 | 26 | $this->title = $title; |
| 27 | 27 | $this->controller = new Controller( $domain ); |
| 28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getTitle() : string { |
|
| 33 | + public function getTitle () : string { |
|
| 34 | 34 | return $this->title; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param int|null $section A section number to retrieve the content of that section |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | - public function getContent( int $section = null ) : string { |
|
| 43 | + public function getContent ( int $section = null ) : string { |
|
| 44 | 44 | if ( $this->content === null ) { |
| 45 | 45 | $this->content = $this->controller->getPageContent( $this->title, $section ); |
| 46 | 46 | } |
@@ -52,16 +52,16 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @param array $params |
| 54 | 54 | */ |
| 55 | - public function edit( array $params ) { |
|
| 55 | + public function edit ( array $params ) { |
|
| 56 | 56 | $params = [ |
| 57 | 57 | 'title' => $this->getTitle() |
| 58 | 58 | ] + $params; |
| 59 | 59 | |
| 60 | 60 | $this->controller->editPage( $params ); |
| 61 | - if ( isset( $params['text'] ) ) { |
|
| 62 | - $this->content = $params['text']; |
|
| 63 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 64 | - $this->content .= $params['appendtext']; |
|
| 61 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 62 | + $this->content = $params[ 'text' ]; |
|
| 63 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 64 | + $this->content .= $params[ 'appendtext' ]; |
|
| 65 | 65 | } else { |
| 66 | 66 | // Clear the cache anyway |
| 67 | 67 | ( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - public function exists() : bool { |
|
| 77 | + public function exists () : bool { |
|
| 78 | 78 | $res = RequestBase::newFromParams( [ |
| 79 | 79 | 'action' => 'query', |
| 80 | 80 | 'titles' => $this->getTitle() |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @param string $regex |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function matches( string $regex ) : bool { |
|
| 92 | + public function matches ( string $regex ) : bool { |
|
| 93 | 93 | return (bool)preg_match( $regex, $this->getContent() ); |
| 94 | 94 | } |
| 95 | 95 | |
@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | * @return string[] |
| 102 | 102 | * @throws \Exception |
| 103 | 103 | */ |
| 104 | - public function getMatch( string $regex ) : array { |
|
| 105 | - $ret = []; |
|
| 104 | + public function getMatch ( string $regex ) : array { |
|
| 105 | + $ret = [ ]; |
|
| 106 | 106 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 107 | 107 | throw new \Exception( 'The content does not match the given regex' ); |
| 108 | 108 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @inheritDoc |
| 116 | 116 | */ |
| 117 | - public function getRegex() : string { |
|
| 117 | + public function getRegex () : string { |
|
| 118 | 118 | return str_replace( ' ', '[ _]', preg_quote( $this->title ) ); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return string |
| 125 | 125 | */ |
| 126 | - public function __toString() { |
|
| 126 | + public function __toString () { |
|
| 127 | 127 | return $this->getTitle(); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -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 | $bureaucrats = $this->getFailedBureaucrats( $failed ); |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return PageRiconferma[] |
| 38 | 38 | */ |
| 39 | - private function getFailures() : array { |
|
| 40 | - $ret = []; |
|
| 39 | + private function getFailures () : array { |
|
| 40 | + $ret = [ ]; |
|
| 41 | 41 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 42 | 42 | foreach ( $allPages as $page ) { |
| 43 | 43 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 44 | - $ret[] = $page; |
|
| 44 | + $ret[ ] = $page; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | return $ret; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @param User[] $users |
| 52 | 52 | */ |
| 53 | - protected function updateBurList( array $users ) { |
|
| 53 | + protected function updateBurList ( array $users ) { |
|
| 54 | 54 | $this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) ); |
| 55 | 55 | $remList = Element::regexFromArray( $users ); |
| 56 | 56 | $burList = new Page( $this->getConfig()->get( 'bur-list-title' ) ); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @param PageRiconferma[] $pages |
| 75 | 75 | */ |
| 76 | - protected function requestRemoval( array $pages ) { |
|
| 76 | + protected function requestRemoval ( array $pages ) { |
|
| 77 | 77 | $this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) ); |
| 78 | 78 | |
| 79 | 79 | $flagRemPage = new Page( |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param PageRiconferma[] $pages |
| 111 | 111 | */ |
| 112 | - protected function updateAnnunci( array $pages ) { |
|
| 112 | + protected function updateAnnunci ( array $pages ) { |
|
| 113 | 113 | $this->getLogger()->info( 'Updating annunci' ); |
| 114 | 114 | $section = 1; |
| 115 | 115 | |
| 116 | - $names = []; |
|
| 116 | + $names = [ ]; |
|
| 117 | 117 | $text = ''; |
| 118 | 118 | foreach ( $pages as $page ) { |
| 119 | 119 | $user = $page->getUser()->getName(); |
| 120 | - $names[] = $user; |
|
| 120 | + $names[ ] = $user; |
|
| 121 | 121 | $text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text(); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @param PageRiconferma[] $pages |
| 151 | 151 | */ |
| 152 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 152 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 153 | 153 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 154 | 154 | $notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-page-title' ) ); |
| 155 | 155 | |
| 156 | - $names = []; |
|
| 156 | + $names = [ ]; |
|
| 157 | 157 | $text = ''; |
| 158 | 158 | $msg = $this->msg( 'ultimenotizie-text' ); |
| 159 | 159 | foreach ( $pages as $page ) { |
| 160 | 160 | $user = $page->getUser()->getName(); |
| 161 | - $names[] = $user; |
|
| 161 | + $names[ ] = $user; |
|
| 162 | 162 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | * @param PageRiconferma[] $pages |
| 188 | 188 | * @return User[] |
| 189 | 189 | */ |
| 190 | - private function getFailedBureaucrats( array $pages ) : array { |
|
| 191 | - $ret = []; |
|
| 190 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
| 191 | + $ret = [ ]; |
|
| 192 | 192 | foreach ( $pages as $page ) { |
| 193 | 193 | $user = $page->getUser(); |
| 194 | 194 | if ( $user->inGroup( 'bureaucrat' ) ) { |
| 195 | - $ret[] = $user; |
|
| 195 | + $ret[ ] = $user; |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | 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\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 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 21 | 21 | |
| 22 | 22 | if ( !$pages ) { |
@@ -38,15 +38,15 @@ discard block |
||
| 38 | 38 | * @param PageRiconferma[] $pages |
| 39 | 39 | * @see UpdatesAround::addToVotazioni() |
| 40 | 40 | */ |
| 41 | - protected function updateVotazioni( array $pages ) { |
|
| 41 | + protected function updateVotazioni ( array $pages ) { |
|
| 42 | 42 | $this->getLogger()->info( |
| 43 | 43 | 'Updating votazioni: ' . implode( ', ', $pages ) |
| 44 | 44 | ); |
| 45 | 45 | $votePage = new Page( $this->getConfig()->get( 'vote-page-title' ) ); |
| 46 | 46 | |
| 47 | - $users = []; |
|
| 47 | + $users = [ ]; |
|
| 48 | 48 | foreach ( $pages as $page ) { |
| 49 | - $users[] = $page->getUser(); |
|
| 49 | + $users[ ] = $page->getUser(); |
|
| 50 | 50 | } |
| 51 | 51 | $usersReg = Element::regexFromArray( $users ); |
| 52 | 52 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param array $pages |
| 68 | 68 | * @see UpdatesAround::addToNews() |
| 69 | 69 | */ |
| 70 | - protected function updateNews( array $pages ) { |
|
| 70 | + protected function updateNews ( array $pages ) { |
|
| 71 | 71 | $simpleAmount = $voteAmount = 0; |
| 72 | 72 | foreach ( $pages as $page ) { |
| 73 | 73 | if ( $page->isVote() ) { |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 88 | 88 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 89 | 89 | |
| 90 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 91 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 90 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 91 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 92 | 92 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() ); |
| 93 | 93 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 94 | 94 | |
@@ -106,21 +106,21 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param bool[] $outcomes |
| 108 | 108 | */ |
| 109 | - protected function updateAdminList( array $outcomes ) { |
|
| 109 | + protected function updateAdminList ( array $outcomes ) { |
|
| 110 | 110 | $this->getLogger()->info( 'Updating admin list' ); |
| 111 | 111 | $adminsPage = new Page( $this->getConfig()->get( 'admins-list-title' ) ); |
| 112 | 112 | $newContent = $adminsPage->getContent(); |
| 113 | 113 | |
| 114 | - $riconfNames = $removeNames = []; |
|
| 114 | + $riconfNames = $removeNames = [ ]; |
|
| 115 | 115 | foreach ( $outcomes as $user => $confirmed ) { |
| 116 | 116 | $userReg = ( new User( $user ) )->getRegex(); |
| 117 | 117 | $reg = "!(\{\{Amministratore\/riga\|$userReg.+\| *)\d+( *\|[ \w]*\}\}.*\n)!"; |
| 118 | 118 | if ( $confirmed ) { |
| 119 | 119 | $newContent = preg_replace( $reg, '${1}{{subst:#time:Ymd|+1 year}}$2', $newContent ); |
| 120 | - $riconfNames[] = $user; |
|
| 120 | + $riconfNames[ ] = $user; |
|
| 121 | 121 | } else { |
| 122 | 122 | $newContent = preg_replace( $reg, '', $newContent ); |
| 123 | - $removeNames[] = $user; |
|
| 123 | + $removeNames[ ] = $user; |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | |
@@ -140,21 +140,21 @@ discard block |
||
| 140 | 140 | /** |
| 141 | 141 | * @param bool[] $outcomes |
| 142 | 142 | */ |
| 143 | - protected function updateCUList( array $outcomes ) { |
|
| 143 | + protected function updateCUList ( array $outcomes ) { |
|
| 144 | 144 | $this->getLogger()->info( 'Updating CU list.' ); |
| 145 | 145 | $cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) ); |
| 146 | 146 | $newContent = $cuList->getContent(); |
| 147 | 147 | |
| 148 | - $riconfNames = $removeNames = []; |
|
| 148 | + $riconfNames = $removeNames = [ ]; |
|
| 149 | 149 | foreach ( $outcomes as $user => $confirmed ) { |
| 150 | 150 | $userReg = ( new User( $user ) )->getRegex(); |
| 151 | 151 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
| 152 | 152 | if ( $confirmed ) { |
| 153 | 153 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
| 154 | - $riconfNames[] = $user; |
|
| 154 | + $riconfNames[ ] = $user; |
|
| 155 | 155 | } else { |
| 156 | 156 | $newContent = preg_replace( $reg, '', $newContent ); |
| 157 | - $removeNames[] = $user; |
|
| 157 | + $removeNames[ ] = $user; |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | * @param PageRiconferma[] $pages |
| 179 | 179 | * @return bool[] |
| 180 | 180 | */ |
| 181 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
| 182 | - $ret = []; |
|
| 181 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
| 182 | + $ret = [ ]; |
|
| 183 | 183 | foreach ( $pages as $page ) { |
| 184 | 184 | $user = $page->getUser(); |
| 185 | 185 | if ( $user->inGroup( $group ) ) { |
@@ -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,15 +15,15 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - protected function getSubtasksMap(): array { |
|
| 18 | + protected function getSubtasksMap (): array { |
|
| 19 | 19 | // Everything is done here. |
| 20 | - return []; |
|
| 20 | + return [ ]; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @inheritDoc |
| 25 | 25 | */ |
| 26 | - public function runInternal() : int { |
|
| 26 | + public function runInternal () : int { |
|
| 27 | 27 | $pages = $this->getDataProvider()->getOpenPages(); |
| 28 | 28 | |
| 29 | 29 | if ( !$pages ) { |
@@ -37,12 +37,12 @@ discard block |
||
| 37 | 37 | * @param PageRiconferma[] $pages |
| 38 | 38 | * @return int a STATUS_* constant |
| 39 | 39 | */ |
| 40 | - protected function processPages( array $pages ) : int { |
|
| 41 | - $donePages = []; |
|
| 40 | + protected function processPages ( array $pages ) : int { |
|
| 41 | + $donePages = [ ]; |
|
| 42 | 42 | foreach ( $pages as $page ) { |
| 43 | 43 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 44 | 44 | $this->openVote( $page ); |
| 45 | - $donePages[] = $page; |
|
| 45 | + $donePages[ ] = $page; |
|
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param PageRiconferma $page |
| 62 | 62 | */ |
| 63 | - protected function openVote( PageRiconferma $page ) { |
|
| 63 | + protected function openVote ( PageRiconferma $page ) { |
|
| 64 | 64 | $this->getLogger()->info( "Starting vote on $page" ); |
| 65 | 65 | |
| 66 | 66 | $content = $page->getContent(); |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * @see SimpleUpdates::updateVotazioni() |
| 100 | 100 | * @see UpdatesAround::addToVotazioni() |
| 101 | 101 | */ |
| 102 | - protected function updateVotazioni( array $pages ) { |
|
| 102 | + protected function updateVotazioni ( array $pages ) { |
|
| 103 | 103 | $votePage = new Page( $this->getConfig()->get( 'vote-page-title' ) ); |
| 104 | 104 | |
| 105 | - $users = []; |
|
| 105 | + $users = [ ]; |
|
| 106 | 106 | foreach ( $pages as $page ) { |
| 107 | - $users[] = $page->getUser(); |
|
| 107 | + $users[ ] = $page->getUser(); |
|
| 108 | 108 | } |
| 109 | 109 | $usersReg = Element::regexFromArray( $users ); |
| 110 | 110 | |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @see SimpleUpdates::updateNews() |
| 143 | 143 | * @throws TaskException |
| 144 | 144 | */ |
| 145 | - protected function updateNews( int $amount ) { |
|
| 145 | + protected function updateNews ( int $amount ) { |
|
| 146 | 146 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 147 | 147 | $newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) ); |
| 148 | 148 | |
@@ -157,8 +157,8 @@ discard block |
||
| 157 | 157 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - $newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: ''; |
|
| 161 | - $newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: ''; |
|
| 160 | + $newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: ''; |
|
| 161 | + $newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: ''; |
|
| 162 | 162 | |
| 163 | 163 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 164 | 164 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |