@@ -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 @@ 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() ) { |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 91 | 91 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 92 | 92 | |
| 93 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 94 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 93 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 94 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 95 | 95 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content ); |
| 96 | 96 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 97 | 97 | |
@@ -109,21 +109,21 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param bool[] $outcomes |
| 111 | 111 | */ |
| 112 | - protected function updateAdminList( array $outcomes ) { |
|
| 112 | + protected function updateAdminList ( array $outcomes ) { |
|
| 113 | 113 | $this->getLogger()->info( 'Updating admin list' ); |
| 114 | 114 | $adminsPage = new Page( $this->getConfig()->get( 'admins-list-title' ) ); |
| 115 | 115 | $newContent = $adminsPage->getContent(); |
| 116 | 116 | |
| 117 | - $riconfNames = $removeNames = []; |
|
| 117 | + $riconfNames = $removeNames = [ ]; |
|
| 118 | 118 | foreach ( $outcomes as $user => $confirmed ) { |
| 119 | 119 | $userReg = ( new User( $user ) )->getRegex(); |
| 120 | 120 | $reg = "!(\{\{Amministratore\/riga\|$userReg.+\| *)\d+( *\|[ \w]*\}\}.*\n)!"; |
| 121 | 121 | if ( $confirmed ) { |
| 122 | 122 | $newContent = preg_replace( $reg, '${1}{{subst:#time:Ymd|+1 year}}$2', $newContent ); |
| 123 | - $riconfNames[] = $user; |
|
| 123 | + $riconfNames[ ] = $user; |
|
| 124 | 124 | } else { |
| 125 | 125 | $newContent = preg_replace( $reg, '', $newContent ); |
| 126 | - $removeNames[] = $user; |
|
| 126 | + $removeNames[ ] = $user; |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -143,21 +143,21 @@ discard block |
||
| 143 | 143 | /** |
| 144 | 144 | * @param bool[] $outcomes |
| 145 | 145 | */ |
| 146 | - protected function updateCUList( array $outcomes ) { |
|
| 146 | + protected function updateCUList ( array $outcomes ) { |
|
| 147 | 147 | $this->getLogger()->info( 'Updating CU list.' ); |
| 148 | 148 | $cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) ); |
| 149 | 149 | $newContent = $cuList->getContent(); |
| 150 | 150 | |
| 151 | - $riconfNames = $removeNames = []; |
|
| 151 | + $riconfNames = $removeNames = [ ]; |
|
| 152 | 152 | foreach ( $outcomes as $user => $confirmed ) { |
| 153 | 153 | $userReg = ( new User( $user ) )->getRegex(); |
| 154 | 154 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
| 155 | 155 | if ( $confirmed ) { |
| 156 | 156 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
| 157 | - $riconfNames[] = $user; |
|
| 157 | + $riconfNames[ ] = $user; |
|
| 158 | 158 | } else { |
| 159 | 159 | $newContent = preg_replace( $reg, '', $newContent ); |
| 160 | - $removeNames[] = $user; |
|
| 160 | + $removeNames[ ] = $user; |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -181,8 +181,8 @@ discard block |
||
| 181 | 181 | * @param PageRiconferma[] $pages |
| 182 | 182 | * @return bool[] |
| 183 | 183 | */ |
| 184 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
| 185 | - $ret = []; |
|
| 184 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
| 185 | + $ret = [ ]; |
|
| 186 | 186 | foreach ( $pages as $page ) { |
| 187 | 187 | $user = $page->getUser(); |
| 188 | 188 | 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 | - $actualPages = []; |
|
| 40 | + protected function processPages ( array $pages ) : int { |
|
| 41 | + $actualPages = [ ]; |
|
| 42 | 42 | foreach ( $pages as $page ) { |
| 43 | 43 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 44 | 44 | $this->openVote( $page ); |
| 45 | - $actualPages[] = $page; |
|
| 45 | + $actualPages[ ] = $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 ); |