@@ -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 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @inheritDoc |
| 14 | 14 | */ |
| 15 | - public function runInternal() : int { |
|
| 15 | + public function runInternal () : int { |
|
| 16 | 16 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 17 | 17 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | return TaskResult::STATUS_NOTHING; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $ricNums = []; |
|
| 23 | + $ricNums = [ ]; |
|
| 24 | 24 | foreach ( $pages as $page ) { |
| 25 | 25 | $ricNums[ $page->getUser()->getName() ] = $page->getNum(); |
| 26 | 26 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param User $user |
| 39 | 39 | * @param int $ricNum |
| 40 | 40 | */ |
| 41 | - protected function addMsg( User $user, int $ricNum ) : void { |
|
| 41 | + protected function addMsg ( User $user, int $ricNum ) : void { |
|
| 42 | 42 | $this->getLogger()->info( "Leaving msg to $user" ); |
| 43 | 43 | $msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text(); |
| 44 | 44 | |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function runInternal() : int { |
|
| 16 | + public function runInternal () : int { |
|
| 17 | 17 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 18 | 18 | |
| 19 | 19 | if ( !$pages ) { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param PageRiconferma[] $pages |
| 37 | 37 | */ |
| 38 | - protected function addToMainPage( array $pages ) : void { |
|
| 38 | + protected function addToMainPage ( array $pages ) : void { |
|
| 39 | 39 | $this->getLogger()->info( |
| 40 | 40 | 'Adding the following to main: ' . implode( ', ', $pages ) |
| 41 | 41 | ); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @param PageRiconferma[] $pages |
| 70 | 70 | */ |
| 71 | - protected function addToVotazioni( array $pages ) : void { |
|
| 71 | + protected function addToVotazioni ( array $pages ) : void { |
|
| 72 | 72 | $this->getLogger()->info( |
| 73 | 73 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
| 74 | 74 | ); |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param int $amount |
| 106 | 106 | * @throws TaskException |
| 107 | 107 | */ |
| 108 | - protected function addToNews( int $amount ) : void { |
|
| 108 | + protected function addToNews ( int $amount ) : void { |
|
| 109 | 109 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 110 | 110 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
| 111 | 111 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | $matches = $newsPage->getMatch( $reg ); |
| 120 | 120 | |
| 121 | - $newNum = (int)$matches[2] + $amount; |
|
| 121 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 122 | 122 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 123 | 123 | |
| 124 | 124 | $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 OpenUpdates::addToVotazioni() |
| 40 | 40 | */ |
| 41 | - protected function updateVotazioni( array $pages ) : void { |
|
| 41 | + protected function updateVotazioni ( array $pages ) : void { |
|
| 42 | 42 | $this->getLogger()->info( |
| 43 | 43 | 'Updating votazioni: ' . implode( ', ', $pages ) |
| 44 | 44 | ); |
| 45 | 45 | $votePage = $this->getPage( $this->getOpt( '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 OpenUpdates::addToNews() |
| 69 | 69 | */ |
| 70 | - protected function updateNews( array $pages ) : void { |
|
| 70 | + protected function updateNews ( array $pages ) : void { |
|
| 71 | 71 | $simpleAmount = $voteAmount = 0; |
| 72 | 72 | foreach ( $pages as $page ) { |
| 73 | 73 | if ( $page->isVote() ) { |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 88 | 88 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 89 | 89 | |
| 90 | - $newSimp = ( (int)$simpleMatches[2] - $simpleAmount ) ?: ''; |
|
| 91 | - $newVote = ( (int)$voteMatches[2] - $voteAmount ) ?: ''; |
|
| 90 | + $newSimp = ( (int)$simpleMatches[ 2 ] - $simpleAmount ) ?: ''; |
|
| 91 | + $newVote = ( (int)$voteMatches[ 2 ] - $voteAmount ) ?: ''; |
|
| 92 | 92 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() ); |
| 93 | 93 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 94 | 94 | |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param bool[] $outcomes |
| 108 | 108 | */ |
| 109 | - protected function updateAdminList( array $outcomes ) : void { |
|
| 109 | + protected function updateAdminList ( array $outcomes ) : void { |
|
| 110 | 110 | $this->getLogger()->info( 'Updating admin list' ); |
| 111 | 111 | $adminsPage = $this->getPage( $this->getOpt( 'admins-list-title' ) ); |
| 112 | 112 | $newContent = $adminsPage->getContent(); |
| 113 | 113 | |
| 114 | - $riconfNames = $removeNames = []; |
|
| 114 | + $riconfNames = $removeNames = [ ]; |
|
| 115 | 115 | foreach ( $outcomes as $username => $confirmed ) { |
| 116 | 116 | $user = $this->getUser( $username ); |
| 117 | 117 | $userReg = $user->getRegex( '!' ); |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | '${1}{{subst:#timel:Ymd}}|' . $nextDate . '$2', |
| 124 | 124 | $newContent |
| 125 | 125 | ); |
| 126 | - $riconfNames[] = $username; |
|
| 126 | + $riconfNames[ ] = $username; |
|
| 127 | 127 | } else { |
| 128 | 128 | $newContent = preg_replace( $reg, '', $newContent ); |
| 129 | - $removeNames[] = $username; |
|
| 129 | + $removeNames[ ] = $username; |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -149,17 +149,17 @@ discard block |
||
| 149 | 149 | * @param User $user |
| 150 | 150 | * @return int |
| 151 | 151 | */ |
| 152 | - private function getNextTs( User $user ) : int { |
|
| 152 | + private function getNextTs ( User $user ) : int { |
|
| 153 | 153 | $userInfo = $user->getUserInfo(); |
| 154 | - if ( isset( $userInfo['override-perm'] ) ) { |
|
| 154 | + if ( isset( $userInfo[ 'override-perm' ] ) ) { |
|
| 155 | 155 | $date = \DateTime::createFromFormat( |
| 156 | 156 | 'd/m/Y', |
| 157 | - $userInfo['override-perm'] . '/' . date( 'Y' ) |
|
| 157 | + $userInfo[ 'override-perm' ] . '/' . date( 'Y' ) |
|
| 158 | 158 | ); |
| 159 | 159 | } else { |
| 160 | 160 | $date = null; |
| 161 | - if ( isset( $userInfo['override'] ) ) { |
|
| 162 | - $date = \DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] ); |
|
| 161 | + if ( isset( $userInfo[ 'override' ] ) ) { |
|
| 162 | + $date = \DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] ); |
|
| 163 | 163 | } |
| 164 | 164 | if ( !$date || $date <= new \DateTime ) { |
| 165 | 165 | $ts = PageBotList::getValidFlagTimestamp( $userInfo ); |
@@ -175,21 +175,21 @@ discard block |
||
| 175 | 175 | /** |
| 176 | 176 | * @param bool[] $outcomes |
| 177 | 177 | */ |
| 178 | - protected function updateCUList( array $outcomes ) : void { |
|
| 178 | + protected function updateCUList ( array $outcomes ) : void { |
|
| 179 | 179 | $this->getLogger()->info( 'Updating CU list.' ); |
| 180 | 180 | $cuList = $this->getPage( $this->getOpt( 'cu-list-title' ) ); |
| 181 | 181 | $newContent = $cuList->getContent(); |
| 182 | 182 | |
| 183 | - $riconfNames = $removeNames = []; |
|
| 183 | + $riconfNames = $removeNames = [ ]; |
|
| 184 | 184 | foreach ( $outcomes as $user => $confirmed ) { |
| 185 | 185 | $userReg = $this->getUser( $user )->getRegex( '!' ); |
| 186 | 186 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
| 187 | 187 | if ( $confirmed ) { |
| 188 | 188 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
| 189 | - $riconfNames[] = $user; |
|
| 189 | + $riconfNames[ ] = $user; |
|
| 190 | 190 | } else { |
| 191 | 191 | $newContent = preg_replace( $reg, '', $newContent ); |
| 192 | - $removeNames[] = $user; |
|
| 192 | + $removeNames[ ] = $user; |
|
| 193 | 193 | } |
| 194 | 194 | } |
| 195 | 195 | |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | * @param PageRiconferma[] $pages |
| 214 | 214 | * @return bool[] |
| 215 | 215 | */ |
| 216 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
| 217 | - $ret = []; |
|
| 216 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
| 217 | + $ret = [ ]; |
|
| 218 | 218 | foreach ( $pages as $page ) { |
| 219 | 219 | $user = $page->getUser(); |
| 220 | 220 | 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\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 | $failed = $this->getFailures(); |
| 22 | 22 | if ( !$failed ) { |
| 23 | 23 | return TaskResult::STATUS_NOTHING; |
@@ -39,12 +39,12 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @return PageRiconferma[] |
| 41 | 41 | */ |
| 42 | - private function getFailures() : array { |
|
| 43 | - $ret = []; |
|
| 42 | + private function getFailures () : array { |
|
| 43 | + $ret = [ ]; |
|
| 44 | 44 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 45 | 45 | foreach ( $allPages as $page ) { |
| 46 | 46 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 47 | - $ret[] = $page; |
|
| 47 | + $ret[ ] = $page; |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | return $ret; |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @param User[] $users |
| 55 | 55 | */ |
| 56 | - protected function updateBurList( array $users ) : void { |
|
| 56 | + protected function updateBurList ( array $users ) : void { |
|
| 57 | 57 | $this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) ); |
| 58 | 58 | $remList = Element::regexFromArray( $users, '!' ); |
| 59 | 59 | $burList = $this->getPage( $this->getOpt( 'bur-list-title' ) ); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @param PageRiconferma[] $pages |
| 78 | 78 | */ |
| 79 | - protected function requestRemoval( array $pages ) : void { |
|
| 79 | + protected function requestRemoval ( array $pages ) : void { |
|
| 80 | 80 | $this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) ); |
| 81 | 81 | |
| 82 | 82 | $metaWiki = new Wiki( $this->getLogger(), META_URL ); |
@@ -113,15 +113,15 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @param PageRiconferma[] $pages |
| 115 | 115 | */ |
| 116 | - protected function updateAnnunci( array $pages ) : void { |
|
| 116 | + protected function updateAnnunci ( array $pages ) : void { |
|
| 117 | 117 | $this->getLogger()->info( 'Updating annunci' ); |
| 118 | 118 | $section = 1; |
| 119 | 119 | |
| 120 | - $names = []; |
|
| 120 | + $names = [ ]; |
|
| 121 | 121 | $text = ''; |
| 122 | 122 | foreach ( $pages as $page ) { |
| 123 | 123 | $user = $page->getUser()->getName(); |
| 124 | - $names[] = $user; |
|
| 124 | + $names[ ] = $user; |
|
| 125 | 125 | $text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text(); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -153,16 +153,16 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @param PageRiconferma[] $pages |
| 155 | 155 | */ |
| 156 | - protected function updateUltimeNotizie( array $pages ) : void { |
|
| 156 | + protected function updateUltimeNotizie ( array $pages ) : void { |
|
| 157 | 157 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 158 | 158 | $notiziePage = $this->getPage( $this->getOpt( 'ultimenotizie-page-title' ) ); |
| 159 | 159 | |
| 160 | - $names = []; |
|
| 160 | + $names = [ ]; |
|
| 161 | 161 | $text = ''; |
| 162 | 162 | $msg = $this->msg( 'ultimenotizie-text' ); |
| 163 | 163 | foreach ( $pages as $page ) { |
| 164 | 164 | $user = $page->getUser()->getName(); |
| 165 | - $names[] = $user; |
|
| 165 | + $names[ ] = $user; |
|
| 166 | 166 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -191,12 +191,12 @@ discard block |
||
| 191 | 191 | * @param PageRiconferma[] $pages |
| 192 | 192 | * @return User[] |
| 193 | 193 | */ |
| 194 | - private function getFailedBureaucrats( array $pages ) : array { |
|
| 195 | - $ret = []; |
|
| 194 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
| 195 | + $ret = [ ]; |
|
| 196 | 196 | foreach ( $pages as $page ) { |
| 197 | 197 | $user = $page->getUser(); |
| 198 | 198 | if ( $user->inGroup( 'bureaucrat' ) ) { |
| 199 | - $ret[] = $user; |
|
| 199 | + $ret[ ] = $user; |
|
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | return $ret; |
@@ -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 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 21 | 21 | |
| 22 | 22 | if ( !$users ) { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * |
| 36 | 36 | * @param User $user |
| 37 | 37 | */ |
| 38 | - protected function processUser( User $user ) : void { |
|
| 38 | + protected function processUser ( User $user ) : void { |
|
| 39 | 39 | $this->getLogger()->info( "Processing user $user" ); |
| 40 | 40 | try { |
| 41 | 41 | $num = $this->getLastPageNum( $user ) + 1; |
@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | * @return int |
| 71 | 71 | * @throws TaskException |
| 72 | 72 | */ |
| 73 | - protected function getLastPageNum( User $user ) : int { |
|
| 73 | + protected function getLastPageNum ( User $user ) : int { |
|
| 74 | 74 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 75 | 75 | |
| 76 | - $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1]; |
|
| 76 | + $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ]; |
|
| 77 | 77 | |
| 78 | 78 | $prefixes = [ "$unprefixedTitle/$user/" ]; |
| 79 | 79 | foreach ( $user->getAliases() as $alias ) { |
| 80 | - $prefixes[] = "$unprefixedTitle/$alias/"; |
|
| 80 | + $prefixes[ ] = "$unprefixedTitle/$alias/"; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | $params = [ |
@@ -111,14 +111,14 @@ discard block |
||
| 111 | 111 | * @param string $title |
| 112 | 112 | * @param User $user |
| 113 | 113 | */ |
| 114 | - protected function createPage( string $title, User $user ) : void { |
|
| 114 | + protected function createPage ( string $title, User $user ) : void { |
|
| 115 | 115 | $this->getLogger()->info( "Creating page $title" ); |
| 116 | 116 | $groups = $user->getGroupsWithDates(); |
| 117 | 117 | $textParams = [ |
| 118 | 118 | '$user' => $user->getName(), |
| 119 | - '$date' => $groups['sysop'], |
|
| 120 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 121 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 119 | + '$date' => $groups[ 'sysop' ], |
|
| 120 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 121 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 122 | 122 | ]; |
| 123 | 123 | |
| 124 | 124 | $params = [ |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @param Page $basePage |
| 137 | 137 | * @param string $newText |
| 138 | 138 | */ |
| 139 | - protected function createBasePage( Page $basePage, string $newText ) : void { |
|
| 139 | + protected function createBasePage ( Page $basePage, string $newText ) : void { |
|
| 140 | 140 | $this->getLogger()->info( "Creating base page $basePage" ); |
| 141 | 141 | |
| 142 | 142 | $params = [ |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param Page $basePage |
| 153 | 153 | * @param string $newText |
| 154 | 154 | */ |
| 155 | - protected function updateBasePage( Page $basePage, string $newText ) : void { |
|
| 155 | + protected function updateBasePage ( Page $basePage, string $newText ) : void { |
|
| 156 | 156 | $this->getLogger()->info( "Updating base page $basePage" ); |
| 157 | 157 | |
| 158 | 158 | $params = [ |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function runInternal() : int { |
|
| 16 | + public function runInternal () : int { |
|
| 17 | 17 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 18 | 18 | |
| 19 | 19 | if ( !$pages ) { |
@@ -32,18 +32,18 @@ discard block |
||
| 32 | 32 | * @param PageRiconferma[] $pages |
| 33 | 33 | * @see OpenUpdates::addToMainPage() |
| 34 | 34 | */ |
| 35 | - protected function removeFromMainPage( array $pages ) : void { |
|
| 35 | + protected function removeFromMainPage ( array $pages ) : void { |
|
| 36 | 36 | $this->getLogger()->info( |
| 37 | 37 | 'Removing from main: ' . implode( ', ', $pages ) |
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | $mainPage = $this->getPage( $this->getOpt( 'main-page-title' ) ); |
| 41 | - $remove = []; |
|
| 41 | + $remove = [ ]; |
|
| 42 | 42 | foreach ( $pages as $page ) { |
| 43 | 43 | // Order matters here. It's not guaranteed that there'll be a newline, but avoid |
| 44 | 44 | // regexps for that single character. |
| 45 | - $remove[] = '{{' . $page->getTitle() . "}}\n"; |
|
| 46 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
| 45 | + $remove[ ] = '{{' . $page->getTitle() . "}}\n"; |
|
| 46 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $newContent = str_replace( $remove, '', $mainPage->getContent() ); |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @param PageRiconferma[] $pages |
| 74 | 74 | */ |
| 75 | - protected function addToArchive( array $pages ) : void { |
|
| 75 | + protected function addToArchive ( array $pages ) : void { |
|
| 76 | 76 | $this->getLogger()->info( |
| 77 | 77 | 'Adding to archive: ' . implode( ', ', $pages ) |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | - $simple = $votes = []; |
|
| 80 | + $simple = $votes = [ ]; |
|
| 81 | 81 | foreach ( $pages as $page ) { |
| 82 | 82 | if ( $page->isVote() ) { |
| 83 | - $votes[] = $page; |
|
| 83 | + $votes[ ] = $page; |
|
| 84 | 84 | } else { |
| 85 | - $simple[] = $page; |
|
| 85 | + $simple[ ] = $page; |
|
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
@@ -103,15 +103,15 @@ discard block |
||
| 103 | 103 | * @param string $archiveTitle |
| 104 | 104 | * @param PageRiconferma[] $pages |
| 105 | 105 | */ |
| 106 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) : void { |
|
| 106 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) : void { |
|
| 107 | 107 | $archivePage = $this->getPage( "$archiveTitle/" . date( 'Y' ) ); |
| 108 | 108 | $existed = $archivePage->exists(); |
| 109 | 109 | |
| 110 | 110 | $append = "\n"; |
| 111 | - $archivedList = []; |
|
| 111 | + $archivedList = [ ]; |
|
| 112 | 112 | foreach ( $pages as $page ) { |
| 113 | 113 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 114 | - $archivedList[] = $page->getUserNum(); |
|
| 114 | + $archivedList[ ] = $page->getUserNum(); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | * |
| 133 | 133 | * @param string $archiveTitle |
| 134 | 134 | */ |
| 135 | - private function addArchiveYear( string $archiveTitle ) : void { |
|
| 135 | + private function addArchiveYear ( string $archiveTitle ) : void { |
|
| 136 | 136 | $page = $this->getPage( $archiveTitle ); |
| 137 | 137 | $year = date( 'Y' ); |
| 138 | 138 | |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @inheritDoc |
| 15 | 15 | */ |
| 16 | - public function runInternal() : int { |
|
| 16 | + public function runInternal () : int { |
|
| 17 | 17 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 18 | 18 | |
| 19 | 19 | if ( !$pages ) { |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | /** |
| 36 | 36 | * @param PageRiconferma $page |
| 37 | 37 | */ |
| 38 | - protected function addVoteCloseText( PageRiconferma $page ) : void { |
|
| 38 | + protected function addVoteCloseText ( PageRiconferma $page ) : void { |
|
| 39 | 39 | $content = $page->getContent(); |
| 40 | 40 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!u'; |
| 41 | 41 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @param PageRiconferma $page |
| 51 | 51 | * @see CreatePages::updateBasePage() |
| 52 | 52 | */ |
| 53 | - protected function updateBasePage( PageRiconferma $page ) : void { |
|
| 53 | + protected function updateBasePage ( PageRiconferma $page ) : void { |
|
| 54 | 54 | $this->getLogger()->info( "Updating base page for $page" ); |
| 55 | 55 | |
| 56 | 56 | if ( $page->getNum() === 1 ) { |
@@ -62,8 +62,7 @@ discard block |
||
| 62 | 62 | $current = $basePage->getContent(); |
| 63 | 63 | |
| 64 | 64 | $outcomeText = ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) ? |
| 65 | - 'non riconfermato' : |
|
| 66 | - 'riconfermato'; |
|
| 65 | + 'non riconfermato' : 'riconfermato'; |
|
| 67 | 66 | $text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita'; |
| 68 | 67 | |
| 69 | 68 | $newContent = str_replace( 'riconferma in corso', $text, $current ); |
@@ -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 | |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | /** |
| 20 | 20 | * @inheritDoc |
| 21 | 21 | */ |
| 22 | - protected function getSubtasksMap(): array { |
|
| 22 | + protected function getSubtasksMap (): array { |
|
| 23 | 23 | // Everything is done here. |
| 24 | - return []; |
|
| 24 | + return [ ]; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * @inheritDoc |
| 29 | 29 | */ |
| 30 | - public function runInternal() : int { |
|
| 30 | + public function runInternal () : int { |
|
| 31 | 31 | $this->actualList = $this->getActualAdmins(); |
| 32 | 32 | $pageBotList = PageBotList::get( $this->getWiki() ); |
| 33 | 33 | $this->botList = $pageBotList->getDecodedContent(); |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | - protected function getActualAdmins() : array { |
|
| 57 | + protected function getActualAdmins () : array { |
|
| 58 | 58 | $params = [ |
| 59 | 59 | 'action' => 'query', |
| 60 | 60 | 'list' => 'allusers', |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * @param \stdClass $data |
| 72 | 72 | * @return array |
| 73 | 73 | */ |
| 74 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 75 | - $ret = []; |
|
| 74 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 75 | + $ret = [ ]; |
|
| 76 | 76 | $blacklist = $this->getOpt( 'exclude-admins' ); |
| 77 | 77 | foreach ( $data->query->allusers as $u ) { |
| 78 | 78 | if ( in_array( $u->name, $blacklist, true ) ) { |
@@ -89,16 +89,16 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return array[] |
| 91 | 91 | */ |
| 92 | - protected function getMissingGroups() : array { |
|
| 93 | - $missing = []; |
|
| 92 | + protected function getMissingGroups () : array { |
|
| 93 | + $missing = [ ]; |
|
| 94 | 94 | foreach ( $this->actualList as $adm => $groups ) { |
| 95 | - $curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) ); |
|
| 95 | + $curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) ); |
|
| 96 | 96 | |
| 97 | 97 | foreach ( $curMissing as $group ) { |
| 98 | 98 | try { |
| 99 | 99 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 100 | 100 | } catch ( TaskException $e ) { |
| 101 | - $this->errors[] = $e->getMessage(); |
|
| 101 | + $this->errors[ ] = $e->getMessage(); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return string |
| 114 | 114 | * @throws TaskException |
| 115 | 115 | */ |
| 116 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 116 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 117 | 117 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 118 | 118 | |
| 119 | 119 | $url = DEFAULT_URL; |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param string $group |
| 150 | 150 | * @return string|null |
| 151 | 151 | */ |
| 152 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 152 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 153 | 153 | $ts = null; |
| 154 | 154 | foreach ( $data->query->logevents as $entry ) { |
| 155 | 155 | if ( |
@@ -168,8 +168,8 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return array[] |
| 170 | 170 | */ |
| 171 | - protected function getExtraGroups() : array { |
|
| 172 | - $extra = []; |
|
| 171 | + protected function getExtraGroups () : array { |
|
| 172 | + $extra = [ ]; |
|
| 173 | 173 | foreach ( $this->botList as $name => $groups ) { |
| 174 | 174 | $groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ); |
| 175 | 175 | if ( !isset( $this->actualList[ $name ] ) ) { |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @param string[] $names |
| 186 | 186 | * @return \stdClass |
| 187 | 187 | */ |
| 188 | - private function getRenameEntries( array $names ) : \stdClass { |
|
| 188 | + private function getRenameEntries ( array $names ) : \stdClass { |
|
| 189 | 189 | $titles = array_map( static function ( $x ) { |
| 190 | 190 | return "Utente:$x"; |
| 191 | 191 | }, $names ); |
@@ -209,14 +209,14 @@ discard block |
||
| 209 | 209 | * @param string[] $names |
| 210 | 210 | * @return string[] [ old_name => new_name ] |
| 211 | 211 | */ |
| 212 | - protected function getRenamedUsers( array $names ) : array { |
|
| 212 | + protected function getRenamedUsers ( array $names ) : array { |
|
| 213 | 213 | if ( !$names ) { |
| 214 | - return []; |
|
| 214 | + return [ ]; |
|
| 215 | 215 | } |
| 216 | 216 | $this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) ); |
| 217 | 217 | |
| 218 | 218 | $data = $this->getRenameEntries( $names ); |
| 219 | - $ret = []; |
|
| 219 | + $ret = [ ]; |
|
| 220 | 220 | foreach ( $data->query->logevents as $entry ) { |
| 221 | 221 | // 1 month is arbitrary |
| 222 | 222 | if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) { |
@@ -234,18 +234,18 @@ discard block |
||
| 234 | 234 | * @param array &$newContent |
| 235 | 235 | * @param array $removed |
| 236 | 236 | */ |
| 237 | - private function handleRenames( array &$newContent, array $removed ) : void { |
|
| 237 | + private function handleRenames ( array &$newContent, array $removed ) : void { |
|
| 238 | 238 | $renameMap = $this->getRenamedUsers( array_keys( $removed ) ); |
| 239 | 239 | foreach ( $removed as $oldName => $info ) { |
| 240 | 240 | if ( |
| 241 | 241 | array_key_exists( $oldName, $renameMap ) && |
| 242 | - array_key_exists( $renameMap[$oldName], $newContent ) |
|
| 242 | + array_key_exists( $renameMap[ $oldName ], $newContent ) |
|
| 243 | 243 | ) { |
| 244 | 244 | // This user was renamed! Add this name as alias, if they're still listed |
| 245 | 245 | $newName = $renameMap[ $oldName ]; |
| 246 | 246 | $this->getLogger()->info( "Found rename $oldName -> $newName" ); |
| 247 | - $aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) ); |
|
| 248 | - $newContent[ $newName ]['aliases'] = $aliases; |
|
| 247 | + $aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) ); |
|
| 248 | + $newContent[ $newName ][ 'aliases' ] = $aliases; |
|
| 249 | 249 | // Transfer overrides to the new name. |
| 250 | 250 | $overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] ); |
| 251 | 251 | $newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides ); |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | * @param array[] $extra |
| 260 | 260 | * @return string[] Removed users |
| 261 | 261 | */ |
| 262 | - private function handleExtraAndMissing( |
|
| 262 | + private function handleExtraAndMissing ( |
|
| 263 | 263 | array &$newContent, |
| 264 | 264 | array $missing, |
| 265 | 265 | array $extra |
| 266 | 266 | ) : array { |
| 267 | - $removed = []; |
|
| 267 | + $removed = [ ]; |
|
| 268 | 268 | foreach ( $newContent as $user => $groups ) { |
| 269 | 269 | if ( isset( $missing[ $user ] ) ) { |
| 270 | 270 | $newContent[ $user ] = array_merge( $groups, $missing[ $user ] ); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) { |
| 275 | 275 | $newContent[ $user ] = $newGroups; |
| 276 | 276 | } else { |
| 277 | - $removed[$user] = $newContent[$user]; |
|
| 277 | + $removed[ $user ] = $newContent[ $user ]; |
|
| 278 | 278 | unset( $newContent[ $user ] ); |
| 279 | 279 | } |
| 280 | 280 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param array[] $extra |
| 292 | 292 | * @return array[] |
| 293 | 293 | */ |
| 294 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 294 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 295 | 295 | $newContent = $this->botList; |
| 296 | 296 | |
| 297 | 297 | $removed = $this->handleExtraAndMissing( $newContent, $missing, $extra ); |
@@ -311,12 +311,12 @@ discard block |
||
| 311 | 311 | * |
| 312 | 312 | * @param array[] &$newContent |
| 313 | 313 | */ |
| 314 | - protected function removeOverrides( array &$newContent ) : void { |
|
| 315 | - $removed = []; |
|
| 314 | + protected function removeOverrides ( array &$newContent ) : void { |
|
| 315 | + $removed = [ ]; |
|
| 316 | 316 | foreach ( $newContent as $user => $groups ) { |
| 317 | 317 | if ( PageBotList::isOverrideExpired( $groups ) ) { |
| 318 | 318 | unset( $newContent[ $user ][ 'override' ] ); |
| 319 | - $removed[] = $user; |
|
| 319 | + $removed[ ] = $user; |
|
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | |
@@ -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,15 +14,15 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - protected function getSubtasksMap(): array { |
|
| 17 | + protected function getSubtasksMap (): array { |
|
| 18 | 18 | // Everything is done here. |
| 19 | - return []; |
|
| 19 | + return [ ]; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @inheritDoc |
| 24 | 24 | */ |
| 25 | - public function runInternal() : int { |
|
| 25 | + public function runInternal () : int { |
|
| 26 | 26 | $pages = $this->getDataProvider()->getOpenPages(); |
| 27 | 27 | |
| 28 | 28 | if ( !$pages ) { |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | * @param PageRiconferma[] $pages |
| 37 | 37 | * @return int a STATUS_* constant |
| 38 | 38 | */ |
| 39 | - protected function processPages( array $pages ) : int { |
|
| 40 | - $donePages = []; |
|
| 39 | + protected function processPages ( array $pages ) : int { |
|
| 40 | + $donePages = [ ]; |
|
| 41 | 41 | foreach ( $pages as $page ) { |
| 42 | 42 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 43 | 43 | $this->openVote( $page ); |
| 44 | - $donePages[] = $page; |
|
| 44 | + $donePages[ ] = $page; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @param PageRiconferma $page |
| 61 | 61 | */ |
| 62 | - protected function openVote( PageRiconferma $page ) : void { |
|
| 62 | + protected function openVote ( PageRiconferma $page ) : void { |
|
| 63 | 63 | $this->getLogger()->info( "Starting vote on $page" ); |
| 64 | 64 | |
| 65 | 65 | $content = $page->getContent(); |
@@ -98,12 +98,12 @@ discard block |
||
| 98 | 98 | * @see SimpleUpdates::updateVotazioni() |
| 99 | 99 | * @see OpenUpdates::addToVotazioni() |
| 100 | 100 | */ |
| 101 | - protected function updateVotazioni( array $pages ) : void { |
|
| 101 | + protected function updateVotazioni ( array $pages ) : void { |
|
| 102 | 102 | $votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) ); |
| 103 | 103 | |
| 104 | - $users = []; |
|
| 104 | + $users = [ ]; |
|
| 105 | 105 | foreach ( $pages as $page ) { |
| 106 | - $users[] = $page->getUser(); |
|
| 106 | + $users[ ] = $page->getUser(); |
|
| 107 | 107 | } |
| 108 | 108 | $usersReg = Element::regexFromArray( $users, '!' ); |
| 109 | 109 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @see SimpleUpdates::updateNews() |
| 142 | 142 | * @see OpenUpdates::addToNews() |
| 143 | 143 | */ |
| 144 | - protected function updateNews( int $amount ) : void { |
|
| 144 | + protected function updateNews ( int $amount ) : void { |
|
| 145 | 145 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 146 | 146 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
| 147 | 147 | |
@@ -156,8 +156,8 @@ discard block |
||
| 156 | 156 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - $newTac = ( (int)$newsPage->getMatch( $regTac )[2] - $amount ) ?: ''; |
|
| 160 | - $newVot = ( (int)$newsPage->getMatch( $regVot )[2] + $amount ) ?: ''; |
|
| 159 | + $newTac = ( (int)$newsPage->getMatch( $regTac )[ 2 ] - $amount ) ?: ''; |
|
| 160 | + $newVot = ( (int)$newsPage->getMatch( $regVot )[ 2 ] + $amount ) ?: ''; |
|
| 161 | 161 | |
| 162 | 162 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 163 | 163 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |