@@ -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 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @inheritDoc |
| 19 | 19 | */ |
| 20 | - public function runInternal() : int { |
|
| 20 | + public function runInternal () : int { |
|
| 21 | 21 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 22 | 22 | |
| 23 | 23 | if ( !$pages ) { |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | * @param PageRiconferma[] $pages |
| 40 | 40 | * @see OpenUpdates::addToVotazioni() |
| 41 | 41 | */ |
| 42 | - protected function updateVotazioni( array $pages ) { |
|
| 42 | + protected function updateVotazioni ( array $pages ) { |
|
| 43 | 43 | $this->getLogger()->info( |
| 44 | 44 | 'Updating votazioni: ' . implode( ', ', $pages ) |
| 45 | 45 | ); |
| 46 | 46 | $votePage = new Page( $this->getOpt( 'vote-page-title' ) ); |
| 47 | 47 | |
| 48 | - $users = []; |
|
| 48 | + $users = [ ]; |
|
| 49 | 49 | foreach ( $pages as $page ) { |
| 50 | - $users[] = $page->getUser(); |
|
| 50 | + $users[ ] = $page->getUser(); |
|
| 51 | 51 | } |
| 52 | 52 | $usersReg = Element::regexFromArray( $users ); |
| 53 | 53 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param array $pages |
| 69 | 69 | * @see OpenUpdates::addToNews() |
| 70 | 70 | */ |
| 71 | - protected function updateNews( array $pages ) { |
|
| 71 | + protected function updateNews ( array $pages ) { |
|
| 72 | 72 | $simpleAmount = $voteAmount = 0; |
| 73 | 73 | foreach ( $pages as $page ) { |
| 74 | 74 | if ( $page->isVote() ) { |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 89 | 89 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 90 | 90 | |
| 91 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 92 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 91 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 92 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 93 | 93 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() ); |
| 94 | 94 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 95 | 95 | |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @param bool[] $outcomes |
| 109 | 109 | */ |
| 110 | - protected function updateAdminList( array $outcomes ) { |
|
| 110 | + protected function updateAdminList ( array $outcomes ) { |
|
| 111 | 111 | $this->getLogger()->info( 'Updating admin list' ); |
| 112 | 112 | $adminsPage = new Page( $this->getOpt( 'admins-list-title' ) ); |
| 113 | 113 | $newContent = $adminsPage->getContent(); |
| 114 | 114 | |
| 115 | - $riconfNames = $removeNames = []; |
|
| 115 | + $riconfNames = $removeNames = [ ]; |
|
| 116 | 116 | foreach ( $outcomes as $username => $confirmed ) { |
| 117 | 117 | $user = new User( $username ); |
| 118 | 118 | $userReg = $user->getRegex(); |
@@ -120,10 +120,10 @@ discard block |
||
| 120 | 120 | if ( $confirmed ) { |
| 121 | 121 | $nextDate = date( 'Ymd', $this->getNextTs( $user ) ); |
| 122 | 122 | $newContent = preg_replace( $reg, '${1}' . $nextDate . '$2', $newContent ); |
| 123 | - $riconfNames[] = $username; |
|
| 123 | + $riconfNames[ ] = $username; |
|
| 124 | 124 | } else { |
| 125 | 125 | $newContent = preg_replace( $reg, '', $newContent ); |
| 126 | - $removeNames[] = $username; |
|
| 126 | + $removeNames[ ] = $username; |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
@@ -146,16 +146,16 @@ discard block |
||
| 146 | 146 | * @param User $user |
| 147 | 147 | * @return int |
| 148 | 148 | */ |
| 149 | - private function getNextTs( User $user ) : int { |
|
| 149 | + private function getNextTs ( User $user ) : int { |
|
| 150 | 150 | // If there's an "override", we ignore it, supposing that it's been already used for |
| 151 | 151 | // this time, but not yet removed in UpdateList. This will also discard "override"s added |
| 152 | 152 | // for the next year before the procedure is closed. |
| 153 | 153 | // @todo Avoid the limitation above |
| 154 | 154 | $groups = $user->getGroups(); |
| 155 | - if ( isset( $groups['override-perm'] ) ) { |
|
| 155 | + if ( isset( $groups[ 'override-perm' ] ) ) { |
|
| 156 | 156 | $date = \DateTime::createFromFormat( |
| 157 | 157 | 'd/m/Y', |
| 158 | - $groups['override-perm'] . '/' . date( 'Y' ) |
|
| 158 | + $groups[ 'override-perm' ] . '/' . date( 'Y' ) |
|
| 159 | 159 | ); |
| 160 | 160 | if ( $date < new \DateTime ) { |
| 161 | 161 | $date->modify( '+1 year' ); |
@@ -168,21 +168,21 @@ discard block |
||
| 168 | 168 | /** |
| 169 | 169 | * @param bool[] $outcomes |
| 170 | 170 | */ |
| 171 | - protected function updateCUList( array $outcomes ) { |
|
| 171 | + protected function updateCUList ( array $outcomes ) { |
|
| 172 | 172 | $this->getLogger()->info( 'Updating CU list.' ); |
| 173 | 173 | $cuList = new Page( $this->getOpt( 'cu-list-title' ) ); |
| 174 | 174 | $newContent = $cuList->getContent(); |
| 175 | 175 | |
| 176 | - $riconfNames = $removeNames = []; |
|
| 176 | + $riconfNames = $removeNames = [ ]; |
|
| 177 | 177 | foreach ( $outcomes as $user => $confirmed ) { |
| 178 | 178 | $userReg = ( new User( $user ) )->getRegex(); |
| 179 | 179 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
| 180 | 180 | if ( $confirmed ) { |
| 181 | 181 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
| 182 | - $riconfNames[] = $user; |
|
| 182 | + $riconfNames[ ] = $user; |
|
| 183 | 183 | } else { |
| 184 | 184 | $newContent = preg_replace( $reg, '', $newContent ); |
| 185 | - $removeNames[] = $user; |
|
| 185 | + $removeNames[ ] = $user; |
|
| 186 | 186 | } |
| 187 | 187 | } |
| 188 | 188 | |
@@ -206,8 +206,8 @@ discard block |
||
| 206 | 206 | * @param PageRiconferma[] $pages |
| 207 | 207 | * @return bool[] |
| 208 | 208 | */ |
| 209 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
| 210 | - $ret = []; |
|
| 209 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
| 210 | + $ret = [ ]; |
|
| 211 | 211 | foreach ( $pages as $page ) { |
| 212 | 212 | $user = $page->getUser(); |
| 213 | 213 | if ( $user->inGroup( $group ) ) { |