@@ -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 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | /** @var WikiController */ |
| 19 | 19 | private $controller; |
| 20 | 20 | |
| 21 | - public function __construct() { |
|
| 21 | + public function __construct () { |
|
| 22 | 22 | $this->setLogger( new Logger ); |
| 23 | 23 | $this->setConfig( Config::getInstance() ); |
| 24 | 24 | $this->setController( new WikiController ); |
@@ -27,42 +27,42 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @return LoggerInterface |
| 29 | 29 | */ |
| 30 | - protected function getLogger() : LoggerInterface { |
|
| 30 | + protected function getLogger () : LoggerInterface { |
|
| 31 | 31 | return $this->logger; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - public function setLogger( LoggerInterface $logger ) { |
|
| 37 | + public function setLogger ( LoggerInterface $logger ) { |
|
| 38 | 38 | $this->logger = $logger; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * @return Config |
| 43 | 43 | */ |
| 44 | - protected function getConfig() : Config { |
|
| 44 | + protected function getConfig () : Config { |
|
| 45 | 45 | return $this->config; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * @param Config $cfg |
| 50 | 50 | */ |
| 51 | - protected function setConfig( Config $cfg ) { |
|
| 51 | + protected function setConfig ( Config $cfg ) { |
|
| 52 | 52 | $this->config = $cfg; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | 56 | * @return WikiController |
| 57 | 57 | */ |
| 58 | - protected function getController() : WikiController { |
|
| 58 | + protected function getController () : WikiController { |
|
| 59 | 59 | return $this->controller; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
| 63 | 63 | * @param WikiController $controller |
| 64 | 64 | */ |
| 65 | - protected function setController( WikiController $controller ) { |
|
| 65 | + protected function setController ( WikiController $controller ) { |
|
| 66 | 66 | $this->controller = $controller; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * @param string $key |
| 73 | 73 | * @return Message |
| 74 | 74 | */ |
| 75 | - protected function msg( string $key ) : Message { |
|
| 75 | + protected function msg ( string $key ) : Message { |
|
| 76 | 76 | return new Message( $key ); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -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 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @param string $key |
| 16 | 16 | */ |
| 17 | - public function __construct( string $key ) { |
|
| 17 | + public function __construct ( string $key ) { |
|
| 18 | 18 | $this->key = $key; |
| 19 | 19 | $this->value = Config::getInstance()->get( $key ); |
| 20 | 20 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param string[] $args |
| 24 | 24 | * @return self |
| 25 | 25 | */ |
| 26 | - public function params( $args ) : self { |
|
| 26 | + public function params ( $args ) : self { |
|
| 27 | 27 | $this->value = strtr( $this->value, $args ); |
| 28 | 28 | return $this; |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public function text() : string { |
|
| 34 | + public function text () : string { |
|
| 35 | 35 | $this->parsePlurals(); |
| 36 | 36 | return $this->value; |
| 37 | 37 | } |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Replace {{$plur|<amount>|sing|plur}} |
| 41 | 41 | */ |
| 42 | - protected function parsePlurals() { |
|
| 42 | + protected function parsePlurals () { |
|
| 43 | 43 | $this->value = preg_replace_callback( |
| 44 | 44 | '!\{\{$plur|(?P<amount>\d+)|(?P<sing>[^}|]+)|(?P<plur>[^|}]+)}}!', |
| 45 | 45 | function ( $matches ) { |
| 46 | - return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
| 46 | + return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
| 47 | 47 | }, |
| 48 | 48 | $this->value |
| 49 | 49 | ); |
@@ -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,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 UpdatesAround' ); |
| 19 | 19 | |
| 20 | 20 | $pages = $this->getDataProvider()->getCreatedPages(); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @param PageRiconferma[] $pages |
| 40 | 40 | */ |
| 41 | - protected function addToMainPage( array $pages ) { |
|
| 41 | + protected function addToMainPage ( array $pages ) { |
|
| 42 | 42 | $this->getLogger()->info( |
| 43 | 43 | 'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 44 | 44 | ); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param PageRiconferma[] $pages |
| 67 | 67 | */ |
| 68 | - protected function addVote( array $pages ) { |
|
| 68 | + protected function addVote ( array $pages ) { |
|
| 69 | 69 | $this->getLogger()->info( |
| 70 | 70 | 'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 71 | 71 | ); |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 ); |
| 87 | 87 | } else { |
| 88 | 88 | // Start section |
| 89 | - $matches = []; |
|
| 89 | + $matches = [ ]; |
|
| 90 | 90 | if ( preg_match( $introReg, $content, $matches ) === false ) { |
| 91 | 91 | throw new TaskException( 'Intro not found in vote page' ); |
| 92 | 92 | } |
| 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( 'ric-vote-page-summary' ) |
@@ -113,19 +113,19 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @param int $amount |
| 115 | 115 | */ |
| 116 | - protected function addNews( int $amount ) { |
|
| 116 | + protected function addNews ( int $amount ) { |
|
| 117 | 117 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 118 | 118 | $newsPage = $this->getConfig()->get( 'ric-news-page' ); |
| 119 | 119 | |
| 120 | 120 | $content = $this->getController()->getPageContent( $newsPage ); |
| 121 | 121 | $reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 122 | 122 | |
| 123 | - $matches = []; |
|
| 123 | + $matches = [ ]; |
|
| 124 | 124 | if ( preg_match( $reg, $content, $matches ) === false ) { |
| 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( 'ric-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; |
| 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 StartVote' ); |
| 19 | 19 | |
| 20 | 20 | $pages = $this->getDataProvider()->getOpenPages(); |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @param PageRiconferma[] $pages |
| 34 | 34 | */ |
| 35 | - protected function processPages( array $pages ) { |
|
| 36 | - $actualPages = []; |
|
| 35 | + protected function processPages ( array $pages ) { |
|
| 36 | + $actualPages = [ ]; |
|
| 37 | 37 | foreach ( $pages as $page ) { |
| 38 | 38 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 39 | 39 | $this->openVote( $page ); |
| 40 | - $actualPages[] = $page; |
|
| 40 | + $actualPages[ ] = $page; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param PageRiconferma $page |
| 56 | 56 | */ |
| 57 | - protected function openVote( PageRiconferma $page ) { |
|
| 57 | + protected function openVote ( PageRiconferma $page ) { |
|
| 58 | 58 | $this->getLogger()->info( "Starting vote on $page" ); |
| 59 | 59 | |
| 60 | 60 | $content = $page->getContent(); |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | * @see ClosePages::updateVote() |
| 94 | 94 | * @see UpdatesAround::addVote() |
| 95 | 95 | */ |
| 96 | - protected function updateVotePage( array $pages ) { |
|
| 96 | + protected function updateVotePage ( array $pages ) { |
|
| 97 | 97 | $votePage = $this->getConfig()->get( 'ric-vote-page' ); |
| 98 | 98 | $content = $this->getController()->getPageContent( $votePage ); |
| 99 | 99 | |
| 100 | - $titles = []; |
|
| 100 | + $titles = [ ]; |
|
| 101 | 101 | foreach ( $pages as $page ) { |
| 102 | - $titles[] = preg_quote( $page->getTitle() ); |
|
| 102 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
| 103 | 103 | } |
| 104 | 104 | $titleReg = implode( '|', array_map( 'preg_quote', $titles ) ); |
| 105 | 105 | $search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm"; |
@@ -122,14 +122,14 @@ discard block |
||
| 122 | 122 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 ); |
| 123 | 123 | } else { |
| 124 | 124 | // Start section |
| 125 | - $matches = []; |
|
| 125 | + $matches = [ ]; |
|
| 126 | 126 | if ( preg_match( $introReg, $content, $matches ) === false ) { |
| 127 | 127 | throw new TaskException( 'Intro not found in vote page' ); |
| 128 | 128 | } |
| 129 | 129 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 130 | 130 | // Replace semicolon with full stop |
| 131 | 131 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 132 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 ); |
|
| 132 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 ); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | $summary = $this->msg( 'vote-start-vote-page-summary' ) |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @see UpdatesAround::addNews() |
| 153 | 153 | * @see ClosePages::updateNews() |
| 154 | 154 | */ |
| 155 | - protected function updateNews( int $amount ) { |
|
| 155 | + protected function updateNews ( int $amount ) { |
|
| 156 | 156 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 157 | 157 | $newsPage = $this->getConfig()->get( 'ric-news-page' ); |
| 158 | 158 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 161 | 161 | $regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!'; |
| 162 | 162 | |
| 163 | - $tacMatches = $votMatches = []; |
|
| 163 | + $tacMatches = $votMatches = [ ]; |
|
| 164 | 164 | if ( preg_match( $regTac, $content, $tacMatches ) === false ) { |
| 165 | 165 | throw new TaskException( 'Param "tacite" not found in news page' ); |
| 166 | 166 | } |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - $newTac = (int)$tacMatches[2] - $amount ?: ''; |
|
| 172 | - $newVot = (int)$votMatches[2] + $amount ?: ''; |
|
| 171 | + $newTac = (int)$tacMatches[ 2 ] - $amount ?: ''; |
|
| 172 | + $newVot = (int)$votMatches[ 2 ] + $amount ?: ''; |
|
| 173 | 173 | |
| 174 | 174 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 175 | 175 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |
@@ -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,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->getPagesList(); |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return PageRiconferma[] |
| 53 | 53 | */ |
| 54 | - protected function getPagesList() : array { |
|
| 54 | + protected function getPagesList () : array { |
|
| 55 | 55 | $allPages = $this->getDataProvider()->getOpenPages(); |
| 56 | - $ret = []; |
|
| 56 | + $ret = [ ]; |
|
| 57 | 57 | foreach ( $allPages as $page ) { |
| 58 | 58 | if ( time() > $page->getEndTimestamp() ) { |
| 59 | - $ret[] = $page; |
|
| 59 | + $ret[ ] = $page; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | return $ret; |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | * @param PageRiconferma[] $pages |
| 69 | 69 | * @return PageRiconferma[] |
| 70 | 70 | */ |
| 71 | - private function getFailures( array $pages ) : array { |
|
| 72 | - $ret = []; |
|
| 71 | + private function getFailures ( array $pages ) : array { |
|
| 72 | + $ret = [ ]; |
|
| 73 | 73 | foreach ( $pages as $page ) { |
| 74 | 74 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 75 | - $ret[] = $page; |
|
| 75 | + $ret[ ] = $page; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | return $ret; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @param PageRiconferma $page |
| 83 | 83 | */ |
| 84 | - protected function addVoteCloseText( PageRiconferma $page ) { |
|
| 84 | + protected function addVoteCloseText ( PageRiconferma $page ) { |
|
| 85 | 85 | $content = $page->getContent(); |
| 86 | 86 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!'; |
| 87 | 87 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | * @param PageRiconferma[] $pages |
| 100 | 100 | * @see UpdatesAround::addToMainPage() |
| 101 | 101 | */ |
| 102 | - protected function removeFromMainPage( array $pages ) { |
|
| 102 | + protected function removeFromMainPage ( array $pages ) { |
|
| 103 | 103 | $this->getLogger()->info( |
| 104 | 104 | 'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | $mainPage = $this->getConfig()->get( 'ric-main-page' ); |
| 108 | 108 | $content = $this->getController()->getPageContent( $mainPage ); |
| 109 | - $translations = []; |
|
| 109 | + $translations = [ ]; |
|
| 110 | 110 | foreach ( $pages as $page ) { |
| 111 | 111 | $translations[ '{{' . $page->getTitle() . '}}' ] = ''; |
| 112 | 112 | } |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param PageRiconferma[] $pages |
| 126 | 126 | */ |
| 127 | - protected function addToArchive( array $pages ) { |
|
| 127 | + protected function addToArchive ( array $pages ) { |
|
| 128 | 128 | $this->getLogger()->info( |
| 129 | 129 | 'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | - $simple = $votes = []; |
|
| 132 | + $simple = $votes = [ ]; |
|
| 133 | 133 | foreach ( $pages as $page ) { |
| 134 | 134 | if ( $page->isVote() ) { |
| 135 | - $votes[] = $page; |
|
| 135 | + $votes[ ] = $page; |
|
| 136 | 136 | } else { |
| 137 | - $simple[] = $page; |
|
| 137 | + $simple[ ] = $page; |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -151,21 +151,21 @@ discard block |
||
| 151 | 151 | * @param string $archiveTitle |
| 152 | 152 | * @param array $pages |
| 153 | 153 | */ |
| 154 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 154 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 155 | 155 | $curTitle = "$archiveTitle/" . date( 'Y' ); |
| 156 | 156 | |
| 157 | 157 | $append = ''; |
| 158 | - $archivedList = []; |
|
| 158 | + $archivedList = [ ]; |
|
| 159 | 159 | foreach ( $pages as $page ) { |
| 160 | 160 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 161 | - $archivedList[] = $page->getUserNum(); |
|
| 161 | + $archivedList[ ] = $page->getUserNum(); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if ( count( $archivedList ) > 1 ) { |
| 165 | 165 | $last = array_pop( $archivedList ); |
| 166 | 166 | $userNums = implode( ', ', $archivedList ) . " e $last"; |
| 167 | 167 | } else { |
| 168 | - $userNums = $archivedList[0]; |
|
| 168 | + $userNums = $archivedList[ 0 ]; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -184,14 +184,13 @@ discard block |
||
| 184 | 184 | * @param PageRiconferma $page |
| 185 | 185 | * @see CreatePages::updateBasePage() |
| 186 | 186 | */ |
| 187 | - protected function updateBasePage( PageRiconferma $page ) { |
|
| 187 | + protected function updateBasePage ( PageRiconferma $page ) { |
|
| 188 | 188 | $this->getLogger()->info( "Updating base page for $page" ); |
| 189 | 189 | |
| 190 | 190 | $current = $this->getController()->getPageContent( $page->getBaseTitle() ); |
| 191 | 191 | |
| 192 | 192 | $outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ? |
| 193 | - 'non riconfermato' : |
|
| 194 | - 'riconfermato'; |
|
| 193 | + 'non riconfermato' : 'riconfermato'; |
|
| 195 | 194 | $text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita'; |
| 196 | 195 | |
| 197 | 196 | $newContent = str_replace( 'riconferma in corso', $text, $current ); |
@@ -208,16 +207,16 @@ discard block |
||
| 208 | 207 | * @param PageRiconferma[] $pages |
| 209 | 208 | * @see UpdatesAround::addVote() |
| 210 | 209 | */ |
| 211 | - protected function updateVote( array $pages ) { |
|
| 210 | + protected function updateVote ( array $pages ) { |
|
| 212 | 211 | $this->getLogger()->info( |
| 213 | 212 | 'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 214 | 213 | ); |
| 215 | 214 | $votePage = $this->getConfig()->get( 'ric-vote-page' ); |
| 216 | 215 | $content = $this->getController()->getPageContent( $votePage ); |
| 217 | 216 | |
| 218 | - $titles = []; |
|
| 217 | + $titles = [ ]; |
|
| 219 | 218 | foreach ( $pages as $page ) { |
| 220 | - $titles[] = preg_quote( $page->getTitle() ); |
|
| 219 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
| 221 | 220 | } |
| 222 | 221 | |
| 223 | 222 | $titleReg = implode( '|', array_map( 'preg_quote', $titles ) ); |
@@ -249,7 +248,7 @@ discard block |
||
| 249 | 248 | * @param array $pages |
| 250 | 249 | * @see UpdatesAround::addNews() |
| 251 | 250 | */ |
| 252 | - protected function updateNews( array $pages ) { |
|
| 251 | + protected function updateNews ( array $pages ) { |
|
| 253 | 252 | $simpleAmount = $voteAmount = 0; |
| 254 | 253 | foreach ( $pages as $page ) { |
| 255 | 254 | if ( $page->isVote() ) { |
@@ -269,12 +268,12 @@ discard block |
||
| 269 | 268 | $simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 270 | 269 | $voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!'; |
| 271 | 270 | |
| 272 | - $simpleMatches = $voteMatches = []; |
|
| 271 | + $simpleMatches = $voteMatches = [ ]; |
|
| 273 | 272 | preg_match( $simpleReg, $content, $simpleMatches ); |
| 274 | 273 | preg_match( $voteReg, $content, $voteMatches ); |
| 275 | 274 | |
| 276 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 277 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 275 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 276 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 278 | 277 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content ); |
| 279 | 278 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 280 | 279 | |
@@ -295,7 +294,7 @@ discard block |
||
| 295 | 294 | * |
| 296 | 295 | * @param PageRiconferma[] $pages |
| 297 | 296 | */ |
| 298 | - protected function updateAdminList( array $pages ) { |
|
| 297 | + protected function updateAdminList ( array $pages ) { |
|
| 299 | 298 | $this->getLogger()->info( |
| 300 | 299 | 'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 301 | 300 | ); |
@@ -303,17 +302,17 @@ discard block |
||
| 303 | 302 | $newContent = $this->getController()->getPageContent( $listTitle ); |
| 304 | 303 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 305 | 304 | |
| 306 | - $riconfNames = $removeNames = []; |
|
| 305 | + $riconfNames = $removeNames = [ ]; |
|
| 307 | 306 | foreach ( $pages as $page ) { |
| 308 | 307 | $user = $page->getUser(); |
| 309 | 308 | $reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!"; |
| 310 | 309 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 311 | 310 | // Remove the line |
| 312 | 311 | $newContent = preg_replace( $reg, '', $newContent ); |
| 313 | - $removeNames[] = $user; |
|
| 312 | + $removeNames[ ] = $user; |
|
| 314 | 313 | } else { |
| 315 | 314 | $newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent ); |
| 316 | - $riconfNames[] = $user; |
|
| 315 | + $riconfNames[ ] = $user; |
|
| 317 | 316 | } |
| 318 | 317 | } |
| 319 | 318 | |
@@ -321,7 +320,7 @@ discard block |
||
| 321 | 320 | $lastUser = array_pop( $riconfNames ); |
| 322 | 321 | $riconfList = implode( ', ', $riconfNames ) . " e $lastUser"; |
| 323 | 322 | } elseif ( $riconfNames ) { |
| 324 | - $riconfList = $riconfNames[0]; |
|
| 323 | + $riconfList = $riconfNames[ 0 ]; |
|
| 325 | 324 | } else { |
| 326 | 325 | $riconfList = 'nessuno'; |
| 327 | 326 | } |
@@ -330,7 +329,7 @@ discard block |
||
| 330 | 329 | $lastUser = array_pop( $removeNames ); |
| 331 | 330 | $removeList = implode( ', ', $removeNames ) . " e $lastUser"; |
| 332 | 331 | } elseif ( $removeNames ) { |
| 333 | - $removeList = $removeNames[0]; |
|
| 332 | + $removeList = $removeNames[ 0 ]; |
|
| 334 | 333 | } else { |
| 335 | 334 | $removeList = 'nessuno'; |
| 336 | 335 | } |
@@ -354,14 +353,14 @@ discard block |
||
| 354 | 353 | /** |
| 355 | 354 | * @param PageRiconferma[] $pages |
| 356 | 355 | */ |
| 357 | - protected function updateCUList( array $pages ) { |
|
| 356 | + protected function updateCUList ( array $pages ) { |
|
| 358 | 357 | $this->getLogger()->info( 'Checking if CU list needs updating.' ); |
| 359 | 358 | $cuListTitle = $this->getConfig()->get( 'cu-list-title' ); |
| 360 | 359 | $listTitle = $this->getConfig()->get( 'list-title' ); |
| 361 | 360 | $admins = json_decode( $this->getController()->getPageContent( $listTitle ), true ); |
| 362 | 361 | $newContent = $this->getController()->getPageContent( $cuListTitle ); |
| 363 | 362 | |
| 364 | - $riconfNames = $removeNames = []; |
|
| 363 | + $riconfNames = $removeNames = [ ]; |
|
| 365 | 364 | foreach ( $pages as $page ) { |
| 366 | 365 | $user = $page->getUser(); |
| 367 | 366 | if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) { |
@@ -369,10 +368,10 @@ discard block |
||
| 369 | 368 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 370 | 369 | // Remove the line |
| 371 | 370 | $newContent = preg_replace( $reg, '', $newContent ); |
| 372 | - $removeNames[] = $user; |
|
| 371 | + $removeNames[ ] = $user; |
|
| 373 | 372 | } else { |
| 374 | 373 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 375 | - $riconfNames[] = $user; |
|
| 374 | + $riconfNames[ ] = $user; |
|
| 376 | 375 | } |
| 377 | 376 | } |
| 378 | 377 | } |
@@ -389,7 +388,7 @@ discard block |
||
| 389 | 388 | $lastUser = array_pop( $riconfNames ); |
| 390 | 389 | $riconfList = implode( ', ', $riconfNames ) . " e $lastUser"; |
| 391 | 390 | } elseif ( $riconfNames ) { |
| 392 | - $riconfList = $riconfNames[0]; |
|
| 391 | + $riconfList = $riconfNames[ 0 ]; |
|
| 393 | 392 | } else { |
| 394 | 393 | $riconfList = 'nessuno'; |
| 395 | 394 | } |
@@ -398,7 +397,7 @@ discard block |
||
| 398 | 397 | $lastUser = array_pop( $removeNames ); |
| 399 | 398 | $removeList = implode( ', ', $removeNames ) . " e $lastUser"; |
| 400 | 399 | } elseif ( $removeNames ) { |
| 401 | - $removeList = $removeNames[0]; |
|
| 400 | + $removeList = $removeNames[ 0 ]; |
|
| 402 | 401 | } else { |
| 403 | 402 | $removeList = 'nessuno'; |
| 404 | 403 | } |
@@ -421,18 +420,18 @@ discard block |
||
| 421 | 420 | /** |
| 422 | 421 | * @param PageRiconferma[] $pages |
| 423 | 422 | */ |
| 424 | - protected function updateBurList( array $pages ) { |
|
| 423 | + protected function updateBurList ( array $pages ) { |
|
| 425 | 424 | $this->getLogger()->info( 'Checking if bur list needs updating.' ); |
| 426 | 425 | $listTitle = $this->getConfig()->get( 'list-title' ); |
| 427 | 426 | $admins = json_decode( $this->getController()->getPageContent( $listTitle ), true ); |
| 428 | 427 | |
| 429 | - $remove = []; |
|
| 428 | + $remove = [ ]; |
|
| 430 | 429 | foreach ( $pages as $page ) { |
| 431 | 430 | $user = $page->getUser(); |
| 432 | 431 | if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) && |
| 433 | 432 | $page->getOutcome() & PageRiconferma::OUTCOME_FAIL |
| 434 | 433 | ) { |
| 435 | - $remove[] = $user; |
|
| 434 | + $remove[ ] = $user; |
|
| 436 | 435 | } |
| 437 | 436 | } |
| 438 | 437 | |
@@ -451,7 +450,7 @@ discard block |
||
| 451 | 450 | $lastUser = array_pop( $remove ); |
| 452 | 451 | $removeList = implode( ', ', $remove ) . " e $lastUser"; |
| 453 | 452 | } else { |
| 454 | - $removeList = $remove[0]; |
|
| 453 | + $removeList = $remove[ 0 ]; |
|
| 455 | 454 | } |
| 456 | 455 | |
| 457 | 456 | $summary = $this->msg( 'bur-list-update-summary' ) |
@@ -471,7 +470,7 @@ discard block |
||
| 471 | 470 | * |
| 472 | 471 | * @param PageRiconferma[] $pages |
| 473 | 472 | */ |
| 474 | - protected function requestRemoval( array $pages ) { |
|
| 473 | + protected function requestRemoval ( array $pages ) { |
|
| 475 | 474 | $this->getLogger()->info( |
| 476 | 475 | 'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 477 | 476 | ); |
@@ -516,15 +515,15 @@ discard block |
||
| 516 | 515 | * |
| 517 | 516 | * @param PageRiconferma[] $pages |
| 518 | 517 | */ |
| 519 | - protected function updateAnnunci( array $pages ) { |
|
| 518 | + protected function updateAnnunci ( array $pages ) { |
|
| 520 | 519 | $this->getLogger()->info( 'Updating annunci' ); |
| 521 | 520 | $title = $this->getConfig()->get( 'annunci-title' ); |
| 522 | 521 | |
| 523 | - $names = []; |
|
| 522 | + $names = [ ]; |
|
| 524 | 523 | $text = ''; |
| 525 | 524 | foreach ( $pages as $page ) { |
| 526 | 525 | $user = $page->getUser(); |
| 527 | - $names[] = $user; |
|
| 526 | + $names[ ] = $user; |
|
| 528 | 527 | $text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " . |
| 529 | 528 | "non è stato riconfermato [[WP:A|amministratore]].}}\n"; |
| 530 | 529 | } |
@@ -546,7 +545,7 @@ discard block |
||
| 546 | 545 | $lastUser = array_pop( $names ); |
| 547 | 546 | $namesList = implode( ', ', $names ) . " e $lastUser"; |
| 548 | 547 | } else { |
| 549 | - $namesList = $names[0]; |
|
| 548 | + $namesList = $names[ 0 ]; |
|
| 550 | 549 | } |
| 551 | 550 | |
| 552 | 551 | $summary = $this->msg( 'flag-removal-summary' ) |
@@ -566,16 +565,16 @@ discard block |
||
| 566 | 565 | * |
| 567 | 566 | * @param PageRiconferma[] $pages |
| 568 | 567 | */ |
| 569 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 568 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 570 | 569 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 571 | 570 | $title = $this->getConfig()->get( 'ultimenotizie-title' ); |
| 572 | 571 | |
| 573 | - $names = []; |
|
| 572 | + $names = [ ]; |
|
| 574 | 573 | $text = ''; |
| 575 | 574 | foreach ( $pages as $page ) { |
| 576 | 575 | $user = $page->getUser(); |
| 577 | 576 | $title = $page->getTitle(); |
| 578 | - $names[] = $user; |
|
| 577 | + $names[ ] = $user; |
|
| 579 | 578 | $text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " . |
| 580 | 579 | '[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.'; |
| 581 | 580 | } |
@@ -594,7 +593,7 @@ discard block |
||
| 594 | 593 | $lastUser = array_pop( $names ); |
| 595 | 594 | $namesList = implode( ', ', $names ) . " e $lastUser"; |
| 596 | 595 | } else { |
| 597 | - $namesList = $names[0]; |
|
| 596 | + $namesList = $names[ 0 ]; |
|
| 598 | 597 | } |
| 599 | 598 | |
| 600 | 599 | $summary = $this->msg( 'ultimenotizie-summary' ) |