@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Wiki; |
| 4 | 4 | |
@@ -16,25 +16,25 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @param string $name |
| 18 | 18 | */ |
| 19 | - public function __construct( string $name ) { |
|
| 19 | + public function __construct ( string $name ) { |
|
| 20 | 20 | $this->name = $name; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public function getName() : string { |
|
| 26 | + public function getName () : string { |
|
| 27 | 27 | return $this->name; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @return string[] |
| 32 | 32 | */ |
| 33 | - public function getGroups() : array { |
|
| 33 | + public function getGroups () : array { |
|
| 34 | 34 | return array_keys( $this->getGroupsWithDates() ); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function getGroupsWithDates() : array { |
|
| 37 | + public function getGroupsWithDates () : array { |
|
| 38 | 38 | if ( $this->groups === null ) { |
| 39 | 39 | $usersList = PageBotList::get()->getAdminsList(); |
| 40 | 40 | $this->groups = $usersList[ $this->name ]; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $groupName |
| 49 | 49 | * @return bool |
| 50 | 50 | */ |
| 51 | - public function inGroup( string $groupName ) : bool { |
|
| 51 | + public function inGroup ( string $groupName ) : bool { |
|
| 52 | 52 | return in_array( $groupName, $this->getGroups() ); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @inheritDoc |
| 59 | 59 | */ |
| 60 | - public function getRegex() : string { |
|
| 60 | + public function getRegex () : string { |
|
| 61 | 61 | return str_replace( ' ', '[ _]', preg_quote( $this->name ) ); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
| 65 | 65 | * @return string |
| 66 | 66 | */ |
| 67 | - public function __toString() { |
|
| 67 | + public function __toString () { |
|
| 68 | 68 | return $this->name; |
| 69 | 69 | } |
| 70 | 70 | } |
@@ -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(); |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | '${1}' . date( 'Ymd' ) . '|' . $nextDate . '$2', |
| 125 | 125 | $newContent |
| 126 | 126 | ); |
| 127 | - $riconfNames[] = $username; |
|
| 127 | + $riconfNames[ ] = $username; |
|
| 128 | 128 | } else { |
| 129 | 129 | $newContent = preg_replace( $reg, '', $newContent ); |
| 130 | - $removeNames[] = $username; |
|
| 130 | + $removeNames[ ] = $username; |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
@@ -150,16 +150,16 @@ discard block |
||
| 150 | 150 | * @param User $user |
| 151 | 151 | * @return int |
| 152 | 152 | */ |
| 153 | - private function getNextTs( User $user ) : int { |
|
| 153 | + private function getNextTs ( User $user ) : int { |
|
| 154 | 154 | // If there's an "override", we ignore it, supposing that it's been already used for |
| 155 | 155 | // this time, but not yet removed in UpdateList. This will also discard "override"s added |
| 156 | 156 | // for the next year before the procedure is closed. |
| 157 | 157 | // @todo Avoid the limitation above |
| 158 | 158 | $groups = $user->getGroupsWithDates(); |
| 159 | - if ( isset( $groups['override-perm'] ) ) { |
|
| 159 | + if ( isset( $groups[ 'override-perm' ] ) ) { |
|
| 160 | 160 | $date = \DateTime::createFromFormat( |
| 161 | 161 | 'd/m/Y', |
| 162 | - $groups['override-perm'] . '/' . date( 'Y' ) |
|
| 162 | + $groups[ 'override-perm' ] . '/' . date( 'Y' ) |
|
| 163 | 163 | ); |
| 164 | 164 | if ( $date < new \DateTime ) { |
| 165 | 165 | $date->modify( '+1 year' ); |
@@ -172,21 +172,21 @@ discard block |
||
| 172 | 172 | /** |
| 173 | 173 | * @param bool[] $outcomes |
| 174 | 174 | */ |
| 175 | - protected function updateCUList( array $outcomes ) { |
|
| 175 | + protected function updateCUList ( array $outcomes ) { |
|
| 176 | 176 | $this->getLogger()->info( 'Updating CU list.' ); |
| 177 | 177 | $cuList = new Page( $this->getOpt( 'cu-list-title' ) ); |
| 178 | 178 | $newContent = $cuList->getContent(); |
| 179 | 179 | |
| 180 | - $riconfNames = $removeNames = []; |
|
| 180 | + $riconfNames = $removeNames = [ ]; |
|
| 181 | 181 | foreach ( $outcomes as $user => $confirmed ) { |
| 182 | 182 | $userReg = ( new User( $user ) )->getRegex(); |
| 183 | 183 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
| 184 | 184 | if ( $confirmed ) { |
| 185 | 185 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
| 186 | - $riconfNames[] = $user; |
|
| 186 | + $riconfNames[ ] = $user; |
|
| 187 | 187 | } else { |
| 188 | 188 | $newContent = preg_replace( $reg, '', $newContent ); |
| 189 | - $removeNames[] = $user; |
|
| 189 | + $removeNames[ ] = $user; |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | |
@@ -210,8 +210,8 @@ discard block |
||
| 210 | 210 | * @param PageRiconferma[] $pages |
| 211 | 211 | * @return bool[] |
| 212 | 212 | */ |
| 213 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
| 214 | - $ret = []; |
|
| 213 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
| 214 | + $ret = [ ]; |
|
| 215 | 215 | foreach ( $pages as $page ) { |
| 216 | 216 | $user = $page->getUser(); |
| 217 | 217 | if ( $user->inGroup( $group ) ) { |