@@ -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,13 +11,13 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function run() : TaskResult { |
|
| 14 | + public function run () : TaskResult { |
|
| 15 | 15 | $this->getLogger()->info( 'Starting task UserNotice' ); |
| 16 | 16 | |
| 17 | 17 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | if ( $pages && $users ) { |
| 20 | - $ricNums = []; |
|
| 20 | + $ricNums = [ ]; |
|
| 21 | 21 | foreach ( $pages as $page ) { |
| 22 | 22 | $bits = explode( '/', $page ); |
| 23 | 23 | $num = intval( array_pop( $bits ) ); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @param string $user |
| 42 | 42 | * @param int $ricNum |
| 43 | 43 | */ |
| 44 | - protected function addMsg( string $user, int $ricNum ) { |
|
| 44 | + protected function addMsg ( string $user, int $ricNum ) { |
|
| 45 | 45 | $this->getLogger()->info( "Leaving msg to $user" ); |
| 46 | 46 | $msg = str_replace( '$num', "$ricNum", $this->getConfig()->get( 'user-notice-msg' ) ); |
| 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\Task; |
| 4 | 4 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function run() : TaskResult { |
|
| 16 | + public function run () : TaskResult { |
|
| 17 | 17 | $this->getLogger()->info( 'Starting task CreatePages' ); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param string $user |
| 36 | 36 | * @param array $groups |
| 37 | 37 | */ |
| 38 | - protected function processUser( string $user, array $groups ) { |
|
| 38 | + protected function processUser ( string $user, array $groups ) { |
|
| 39 | 39 | try { |
| 40 | 40 | $num = $this->getLastPageNum( $user ) + 1; |
| 41 | 41 | } catch ( TaskException $e ) { |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @return int |
| 66 | 66 | * @throws TaskException |
| 67 | 67 | */ |
| 68 | - protected function getLastPageNum( string $user ) : int { |
|
| 68 | + protected function getLastPageNum ( string $user ) : int { |
|
| 69 | 69 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 70 | - $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1]; |
|
| 70 | + $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ]; |
|
| 71 | 71 | $params = [ |
| 72 | 72 | 'action' => 'query', |
| 73 | 73 | 'list' => 'allpages', |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | * @param string $user |
| 103 | 103 | * @param array $groups |
| 104 | 104 | */ |
| 105 | - protected function createPage( string $title, string $user, array $groups ) { |
|
| 105 | + protected function createPage ( string $title, string $user, array $groups ) { |
|
| 106 | 106 | $this->getLogger()->info( "Creating page $title" ); |
| 107 | 107 | $text = $this->getConfig()->get( 'ric-page-text' ); |
| 108 | 108 | $textParams = [ |
| 109 | 109 | '$user' => $user, |
| 110 | - '$date' => $groups['sysop'], |
|
| 111 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 112 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 110 | + '$date' => $groups[ 'sysop' ], |
|
| 111 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 112 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 113 | 113 | ]; |
| 114 | 114 | $text = strtr( $text, $textParams ); |
| 115 | 115 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @param string $title |
| 129 | 129 | * @param string $newText |
| 130 | 130 | */ |
| 131 | - protected function createBasePage( string $title, string $newText ) { |
|
| 131 | + protected function createBasePage ( string $title, string $newText ) { |
|
| 132 | 132 | $this->getLogger()->info( "Creating base page $title" ); |
| 133 | 133 | |
| 134 | 134 | $params = [ |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * @param string $title |
| 146 | 146 | * @param string $newText |
| 147 | 147 | */ |
| 148 | - protected function updateBasePage( string $title, string $newText ) { |
|
| 148 | + protected function updateBasePage ( string $title, string $newText ) { |
|
| 149 | 149 | $this->getLogger()->info( "Updating base page $title" ); |
| 150 | 150 | |
| 151 | 151 | $params = [ |
@@ -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 string[] */ |
| 20 | 20 | private $tokens; |
| 21 | 21 | |
| 22 | - public function __construct() { |
|
| 22 | + public function __construct () { |
|
| 23 | 23 | $this->logger = new Logger; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * @return string |
| 31 | 31 | * @throws MissingPageException |
| 32 | 32 | */ |
| 33 | - public function getPageContent( string $title ) : string { |
|
| 33 | + public function getPageContent ( string $title ) : string { |
|
| 34 | 34 | $this->logger->debug( "Retrieving page $title" ); |
| 35 | 35 | $params = [ |
| 36 | 36 | 'action' => 'query', |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | throw new MissingPageException( $title ); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - return $page->revisions[0]->slots->main->{ '*' }; |
|
| 50 | + return $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param array $params |
| 57 | 57 | * @throws EditException |
| 58 | 58 | */ |
| 59 | - public function editPage( array $params ) { |
|
| 59 | + public function editPage ( array $params ) { |
|
| 60 | 60 | $this->login(); |
| 61 | 61 | |
| 62 | 62 | $params = [ |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 76 | 76 | * @throws LoginException |
| 77 | 77 | */ |
| 78 | - public function login() { |
|
| 78 | + public function login () { |
|
| 79 | 79 | if ( self::$loggedIn ) { |
| 80 | 80 | $this->logger->debug( 'Already logged in' ); |
| 81 | 81 | return; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | self::$loggedIn = true; |
| 104 | 104 | // Clear tokens cache |
| 105 | - $this->tokens = []; |
|
| 105 | + $this->tokens = [ ]; |
|
| 106 | 106 | $this->logger->info( 'Login succeeded' ); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * @param string $type |
| 113 | 113 | * @return string |
| 114 | 114 | */ |
| 115 | - public function getToken( string $type ) : string { |
|
| 115 | + public function getToken ( string $type ) : string { |
|
| 116 | 116 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 117 | 117 | $params = [ |
| 118 | 118 | 'action' => 'query', |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | * @param string $title |
| 136 | 136 | * @return int |
| 137 | 137 | */ |
| 138 | - public function getPageCreationTS( string $title ) : int { |
|
| 138 | + public function getPageCreationTS ( string $title ) : int { |
|
| 139 | 139 | $params = [ |
| 140 | 140 | 'action' => 'query', |
| 141 | 141 | 'prop' => 'revisions', |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $res = ( RequestBase::newFromParams( $params ) )->execute(); |
| 150 | 150 | $data = $res->query->pages; |
| 151 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 151 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $title |
| 158 | 158 | * @param string $reason |
| 159 | 159 | */ |
| 160 | - public function protectPage( string $title, string $reason ) { |
|
| 160 | + public function protectPage ( string $title, string $reason ) { |
|
| 161 | 161 | $this->logger->info( "Protecting page $title" ); |
| 162 | 162 | $this->login(); |
| 163 | 163 | |
@@ -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 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @inheritDoc |
| 14 | 14 | */ |
| 15 | - public function run() : TaskResult { |
|
| 15 | + public function run () : TaskResult { |
|
| 16 | 16 | $this->getLogger()->info( 'Starting task UpdatesAround' ); |
| 17 | 17 | |
| 18 | 18 | $pages = $this->getDataProvider()->getCreatedPages(); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param string[] $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 | ); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $summary = preg_replace_callback( |
| 54 | 54 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 55 | 55 | function ( $matches ) { |
| 56 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 56 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 57 | 57 | }, |
| 58 | 58 | $summary |
| 59 | 59 | ); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param string[] $pages |
| 74 | 74 | */ |
| 75 | - protected function addVote( array $pages ) { |
|
| 75 | + protected function addVote ( array $pages ) { |
|
| 76 | 76 | $this->getLogger()->info( |
| 77 | 77 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
| 78 | 78 | ); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $time = $this->getTimeWithArticle(); |
| 84 | 84 | $newLines = ''; |
| 85 | 85 | foreach ( $pages as $page ) { |
| 86 | - $user = explode( '/', $page )[2]; |
|
| 86 | + $user = explode( '/', $page )[ 2 ]; |
|
| 87 | 87 | $newLines .= "*[[Utente:$user|]]. La [[$page|procedura]] termina $time;\n"; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -93,14 +93,14 @@ discard block |
||
| 93 | 93 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 ); |
| 94 | 94 | } else { |
| 95 | 95 | // Start section |
| 96 | - $matches = []; |
|
| 96 | + $matches = [ ]; |
|
| 97 | 97 | if ( preg_match( $introReg, $content, $matches ) === false ) { |
| 98 | 98 | throw new TaskException( 'Intro not found in vote page' ); |
| 99 | 99 | } |
| 100 | 100 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 101 | 101 | // Replace semicolon with full stop |
| 102 | 102 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 103 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 ); |
|
| 103 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $summary = strtr( |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $summary = preg_replace_callback( |
| 111 | 111 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 112 | 112 | function ( $matches ) { |
| 113 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 113 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 114 | 114 | }, |
| 115 | 115 | $summary |
| 116 | 116 | ); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * |
| 130 | 130 | * @return string |
| 131 | 131 | */ |
| 132 | - private function getTimeWithArticle() : string { |
|
| 132 | + private function getTimeWithArticle () : string { |
|
| 133 | 133 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 134 | 134 | $endTS = time() + ( 60 * 60 * 24 * 7 ); |
| 135 | 135 | $endTime = strftime( '%e %B alle %R', $endTS ); |
@@ -146,26 +146,26 @@ discard block |
||
| 146 | 146 | * |
| 147 | 147 | * @param int $amount |
| 148 | 148 | */ |
| 149 | - protected function addNews( int $amount ) { |
|
| 149 | + protected function addNews ( int $amount ) { |
|
| 150 | 150 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 151 | 151 | $newsPage = $this->getConfig()->get( 'ric-news-page' ); |
| 152 | 152 | |
| 153 | 153 | $content = $this->getController()->getPageContent( $newsPage ); |
| 154 | 154 | $reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 155 | 155 | |
| 156 | - $matches = []; |
|
| 156 | + $matches = [ ]; |
|
| 157 | 157 | if ( preg_match( $reg, $content, $matches ) === false ) { |
| 158 | 158 | throw new TaskException( 'Param not found in news page' ); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - $newNum = (int)$matches[2] + $amount; |
|
| 161 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 162 | 162 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 163 | 163 | |
| 164 | 164 | $summary = strtr( $this->getConfig()->get( 'ric-news-page-summary' ), [ '$num' => $amount ] ); |
| 165 | 165 | $summary = preg_replace_callback( |
| 166 | 166 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 167 | 167 | function ( $matches ) { |
| 168 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 168 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 169 | 169 | }, |
| 170 | 170 | $summary |
| 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\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 | $this->getLogger()->info( 'Starting task ClosePages' ); |
| 20 | 20 | |
| 21 | 21 | $titles = $this->getPagesList(); |
@@ -40,13 +40,13 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return string[] |
| 42 | 42 | */ |
| 43 | - protected function getPagesList() : array { |
|
| 43 | + protected function getPagesList () : array { |
|
| 44 | 44 | $allPages = $this->getTranscludedPages(); |
| 45 | - $ret = []; |
|
| 45 | + $ret = [ ]; |
|
| 46 | 46 | foreach ( $allPages as $page ) { |
| 47 | 47 | $created = $this->getController()->getPageCreationTS( $page ); |
| 48 | 48 | if ( time() - $created <= 60 * 60 * 24 * 7 && !$this->hasOpposition( $page ) ) { |
| 49 | - $ret[] = $page; |
|
| 49 | + $ret[ ] = $page; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | return $ret; |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return string[] |
| 59 | 59 | */ |
| 60 | - protected function getTranscludedPages() : array { |
|
| 60 | + protected function getTranscludedPages () : array { |
|
| 61 | 61 | $baseTitle = $this->getConfig()->get( 'ric-main-page' ); |
| 62 | 62 | $params = [ |
| 63 | 63 | 'action' => 'query', |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $res = RequestBase::newFromParams( $params )->execute(); |
| 71 | 71 | $pages = $res->query->pages; |
| 72 | - $ret = []; |
|
| 72 | + $ret = [ ]; |
|
| 73 | 73 | foreach ( reset( $pages )->templates as $page ) { |
| 74 | 74 | if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) { |
| 75 | - $ret[] = $page->title; |
|
| 75 | + $ret[ ] = $page->title; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | return $ret; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param string $page |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - protected function hasOpposition( string $page ) : bool { |
|
| 85 | + protected function hasOpposition ( string $page ) : bool { |
|
| 86 | 86 | $params = [ |
| 87 | 87 | 'action' => 'query', |
| 88 | 88 | 'prop' => 'revisions', |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | ]; |
| 94 | 94 | $res = RequestBase::newFromParams( $params )->execute(); |
| 95 | 95 | $page = reset( $res->query->pages ); |
| 96 | - $content = $page->revisions[0]->slots->main->{ '*' }; |
|
| 96 | + $content = $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 97 | 97 | // Let's hope that this is good enough... |
| 98 | 98 | $votes = substr_count( $content, "\n\# *(?![#*])" ); |
| 99 | 99 | return $votes >= 15; |
@@ -104,12 +104,12 @@ discard block |
||
| 104 | 104 | * @param string[] $titles |
| 105 | 105 | * @see UpdatesAround::addToMainPage() |
| 106 | 106 | */ |
| 107 | - protected function removeFromMainPage( array $titles ) { |
|
| 107 | + protected function removeFromMainPage ( array $titles ) { |
|
| 108 | 108 | $this->getLogger()->info( 'Removing from main: ' . implode( ', ', $titles ) ); |
| 109 | 109 | |
| 110 | 110 | $mainPage = $this->getConfig()->get( 'ric-main-page' ); |
| 111 | 111 | $content = $this->getController()->getPageContent( $mainPage ); |
| 112 | - $translations = []; |
|
| 112 | + $translations = [ ]; |
|
| 113 | 113 | foreach ( $titles as $title ) { |
| 114 | 114 | $translations[ '{{' . $title . '}}' ] = ''; |
| 115 | 115 | } |
@@ -127,24 +127,24 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @param string[] $titles |
| 129 | 129 | */ |
| 130 | - protected function addToArchive( array $titles ) { |
|
| 130 | + protected function addToArchive ( array $titles ) { |
|
| 131 | 131 | $this->getLogger()->info( 'Adding to archive: ' . implode( ', ', $titles ) ); |
| 132 | 132 | |
| 133 | 133 | $archiveTitle = $this->getConfig()->get( 'close-archive-title' ); |
| 134 | 134 | $archiveTitle = "$archiveTitle/" . date( 'Y' ); |
| 135 | 135 | |
| 136 | 136 | $append = ''; |
| 137 | - $archivedList = []; |
|
| 137 | + $archivedList = [ ]; |
|
| 138 | 138 | foreach ( $titles as $page ) { |
| 139 | 139 | $append .= '{{' . $page . "}}\n"; |
| 140 | - $archivedList[] = explode( '/', $page, 3 )[2]; |
|
| 140 | + $archivedList[ ] = explode( '/', $page, 3 )[ 2 ]; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if ( count( $archivedList ) > 1 ) { |
| 144 | 144 | $last = array_pop( $archivedList ); |
| 145 | 145 | $userNums = implode( ', ', $archivedList ) . " e $last"; |
| 146 | 146 | } else { |
| 147 | - $userNums = $archivedList[0]; |
|
| 147 | + $userNums = $archivedList[ 0 ]; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $summary = strtr( |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param string $title |
| 166 | 166 | * @see CreatePages::updateBasePage() |
| 167 | 167 | */ |
| 168 | - protected function updateBasePage( string $title ) { |
|
| 168 | + protected function updateBasePage ( string $title ) { |
|
| 169 | 169 | $this->getLogger()->info( "Updating base page $title" ); |
| 170 | 170 | |
| 171 | 171 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal WTF Phan what's wrong w/ u? |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | * @param string[] $titles |
| 187 | 187 | * @see UpdatesAround::addVote() |
| 188 | 188 | */ |
| 189 | - protected function updateVote( array $titles ) { |
|
| 189 | + protected function updateVote ( array $titles ) { |
|
| 190 | 190 | $votePage = $this->getConfig()->get( 'ric-vote-page' ); |
| 191 | 191 | $content = $this->getController()->getPageContent( $votePage ); |
| 192 | 192 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $summary = preg_replace_callback( |
| 206 | 206 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 207 | 207 | function ( $matches ) { |
| 208 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 208 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 209 | 209 | }, |
| 210 | 210 | $summary |
| 211 | 211 | ); |
@@ -224,19 +224,19 @@ discard block |
||
| 224 | 224 | * @throws TaskException |
| 225 | 225 | * @see UpdatesAround::addNews() |
| 226 | 226 | */ |
| 227 | - protected function updateNews( int $amount ) { |
|
| 227 | + protected function updateNews ( int $amount ) { |
|
| 228 | 228 | $this->getLogger()->info( "Decreasing the news counter by $amount" ); |
| 229 | 229 | $newsPage = $this->getConfig()->get( 'ric-news-page' ); |
| 230 | 230 | |
| 231 | 231 | $content = $this->getController()->getPageContent( $newsPage ); |
| 232 | 232 | $reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 233 | 233 | |
| 234 | - $matches = []; |
|
| 234 | + $matches = [ ]; |
|
| 235 | 235 | if ( preg_match( $reg, $content, $matches ) === false ) { |
| 236 | 236 | throw new TaskException( 'Param not found in news page' ); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - $newNum = (int)$matches[2] - $amount; |
|
| 239 | + $newNum = (int)$matches[ 2 ] - $amount; |
|
| 240 | 240 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 241 | 241 | |
| 242 | 242 | $summary = strtr( |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | $summary = preg_replace_callback( |
| 247 | 247 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 248 | 248 | function ( $matches ) { |
| 249 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 249 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 250 | 250 | }, |
| 251 | 251 | $summary |
| 252 | 252 | ); |
@@ -265,15 +265,15 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @param string[] $titles |
| 267 | 267 | */ |
| 268 | - protected function updateAdminList( array $titles ) { |
|
| 268 | + protected function updateAdminList ( array $titles ) { |
|
| 269 | 269 | $listTitle = $this->getConfig()->get( 'admins-list' ); |
| 270 | 270 | $content = $this->getController()->getPageContent( $listTitle ); |
| 271 | 271 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 272 | 272 | |
| 273 | - $names = []; |
|
| 273 | + $names = [ ]; |
|
| 274 | 274 | foreach ( $titles as $title ) { |
| 275 | - $user = explode( '/', $title )[2]; |
|
| 276 | - $names[] = $user; |
|
| 275 | + $user = explode( '/', $title )[ 2 ]; |
|
| 276 | + $names[ ] = $user; |
|
| 277 | 277 | $reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+(?= *\|(?: *pausa)? *\}\})!"; |
| 278 | 278 | $content = preg_replace( $reg, '$1' . $newDate, $content ); |
| 279 | 279 | } |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | $lastUser = array_pop( $names ); |
| 283 | 283 | $usersList = implode( ', ', $names ) . " e $lastUser"; |
| 284 | 284 | } else { |
| 285 | - $usersList = $names[0]; |
|
| 285 | + $usersList = $names[ 0 ]; |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | $summary = strtr( |