@@ -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 StartVote' ); |
| 18 | 18 | |
| 19 | 19 | $pages = $this->getDataProvider()->getOpenPages(); |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @param string[] $pages |
| 33 | 33 | */ |
| 34 | - protected function processPages( array $pages ) { |
|
| 35 | - $actualPages = []; |
|
| 34 | + protected function processPages ( array $pages ) { |
|
| 35 | + $actualPages = [ ]; |
|
| 36 | 36 | foreach ( $pages as $page ) { |
| 37 | 37 | if ( WikiController::hasOpposition( $page ) ) { |
| 38 | 38 | try { |
| 39 | 39 | $this->openVote( $page ); |
| 40 | - $actualPages[] = $page; |
|
| 40 | + $actualPages[ ] = $page; |
|
| 41 | 41 | } catch ( TaskException $e ) { |
| 42 | 42 | $this->getLogger()->warning( $e->getMessage() ); |
| 43 | 43 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param string $title |
| 59 | 59 | * @throws TaskException |
| 60 | 60 | */ |
| 61 | - protected function openVote( string $title ) { |
|
| 61 | + protected function openVote ( string $title ) { |
|
| 62 | 62 | $this->getLogger()->info( "Starting vote on $title" ); |
| 63 | 63 | |
| 64 | 64 | $content = $this->getController()->getPageContent( $title ); |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @see ClosePages::updateVote() |
| 102 | 102 | * @see UpdatesAround::addVote() |
| 103 | 103 | */ |
| 104 | - protected function updateVotePage( array $titles ) { |
|
| 104 | + protected function updateVotePage ( array $titles ) { |
|
| 105 | 105 | $votePage = $this->getConfig()->get( 'ric-vote-page' ); |
| 106 | 106 | $content = $this->getController()->getPageContent( $votePage ); |
| 107 | 107 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | $newLines = ''; |
| 117 | 117 | $time = WikiController::getTimeWithArticle( time() + ( 60 * 60 * 24 * 14 ) ); |
| 118 | 118 | foreach ( $titles as $title ) { |
| 119 | - $user = explode( '/', $title )[2]; |
|
| 119 | + $user = explode( '/', $title )[ 2 ]; |
|
| 120 | 120 | $newLines .= "*[[Utente:$user|]]. La [[$title|votazione]] termina $time;\n"; |
| 121 | 121 | } |
| 122 | 122 | |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 ); |
| 127 | 127 | } else { |
| 128 | 128 | // Start section |
| 129 | - $matches = []; |
|
| 129 | + $matches = [ ]; |
|
| 130 | 130 | if ( preg_match( $introReg, $content, $matches ) === false ) { |
| 131 | 131 | throw new TaskException( 'Intro not found in vote page' ); |
| 132 | 132 | } |
| 133 | 133 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 134 | 134 | // Replace semicolon with full stop |
| 135 | 135 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 136 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 ); |
|
| 136 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | $summary = strtr( |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $summary = preg_replace_callback( |
| 144 | 144 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 145 | 145 | function ( $matches ) { |
| 146 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 146 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 147 | 147 | }, |
| 148 | 148 | $summary |
| 149 | 149 | ); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @see UpdatesAround::addNews() |
| 165 | 165 | * @see ClosePages::updateNews() |
| 166 | 166 | */ |
| 167 | - protected function updateNews( int $amount ) { |
|
| 167 | + protected function updateNews ( int $amount ) { |
|
| 168 | 168 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 169 | 169 | $newsPage = $this->getConfig()->get( 'ric-news-page' ); |
| 170 | 170 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 173 | 173 | $regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!'; |
| 174 | 174 | |
| 175 | - $tacMatches = $votMatches = []; |
|
| 175 | + $tacMatches = $votMatches = [ ]; |
|
| 176 | 176 | if ( preg_match( $regTac, $content, $tacMatches ) === false ) { |
| 177 | 177 | throw new TaskException( 'Param "tacite" not found in news page' ); |
| 178 | 178 | } |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - $newTac = (int)$tacMatches[2] - $amount; |
|
| 184 | - $newVot = (int)$votMatches[2] + $amount; |
|
| 183 | + $newTac = (int)$tacMatches[ 2 ] - $amount; |
|
| 184 | + $newVot = (int)$votMatches[ 2 ] + $amount; |
|
| 185 | 185 | |
| 186 | 186 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 187 | 187 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $summary = preg_replace_callback( |
| 194 | 194 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 195 | 195 | function ( $matches ) { |
| 196 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 196 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 197 | 197 | }, |
| 198 | 198 | $summary |
| 199 | 199 | ); |