@@ -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 run() : TaskResult { |
|
| 26 | + public function run () : TaskResult { |
|
| 27 | 27 | $this->getLogger()->info( 'Starting task StartVote' ); |
| 28 | 28 | |
| 29 | 29 | $pages = $this->getDataProvider()->getOpenPages(); |
@@ -41,12 +41,12 @@ discard block |
||
| 41 | 41 | /** |
| 42 | 42 | * @param PageRiconferma[] $pages |
| 43 | 43 | */ |
| 44 | - protected function processPages( array $pages ) { |
|
| 45 | - $actualPages = []; |
|
| 44 | + protected function processPages ( array $pages ) { |
|
| 45 | + $actualPages = [ ]; |
|
| 46 | 46 | foreach ( $pages as $page ) { |
| 47 | 47 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 48 | 48 | $this->openVote( $page ); |
| 49 | - $actualPages[] = $page; |
|
| 49 | + $actualPages[ ] = $page; |
|
| 50 | 50 | } |
| 51 | 51 | } |
| 52 | 52 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @param PageRiconferma $page |
| 65 | 65 | */ |
| 66 | - protected function openVote( PageRiconferma $page ) { |
|
| 66 | + protected function openVote ( PageRiconferma $page ) { |
|
| 67 | 67 | $this->getLogger()->info( "Starting vote on $page" ); |
| 68 | 68 | |
| 69 | 69 | $content = $page->getContent(); |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | * @see ClosePages::updateVote() |
| 103 | 103 | * @see UpdatesAround::addVote() |
| 104 | 104 | */ |
| 105 | - protected function updateVotePage( array $pages ) { |
|
| 105 | + protected function updateVotePage ( array $pages ) { |
|
| 106 | 106 | $votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) ); |
| 107 | 107 | $content = $votePage->getContent(); |
| 108 | 108 | |
| 109 | - $titles = []; |
|
| 109 | + $titles = [ ]; |
|
| 110 | 110 | foreach ( $pages as $page ) { |
| 111 | - $titles[] = preg_quote( $page->getTitle() ); |
|
| 111 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
| 112 | 112 | } |
| 113 | 113 | $titleReg = implode( '|', array_map( 'preg_quote', $titles ) ); |
| 114 | 114 | $search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm"; |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 ); |
| 132 | 132 | } else { |
| 133 | 133 | // Start section |
| 134 | - $matches = []; |
|
| 134 | + $matches = [ ]; |
|
| 135 | 135 | if ( preg_match( $introReg, $content, $matches ) === false ) { |
| 136 | 136 | throw new TaskException( 'Intro not found in vote page' ); |
| 137 | 137 | } |
| 138 | 138 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 139 | 139 | // Replace semicolon with full stop |
| 140 | 140 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 141 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 ); |
|
| 141 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 ); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | $summary = $this->msg( 'vote-start-vote-page-summary' ) |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @see UpdatesAround::addNews() |
| 161 | 161 | * @see ClosePages::updateNews() |
| 162 | 162 | */ |
| 163 | - protected function updateNews( int $amount ) { |
|
| 163 | + protected function updateNews ( int $amount ) { |
|
| 164 | 164 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 165 | 165 | $newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) ); |
| 166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | $regTac = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 169 | 169 | $regVot = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!'; |
| 170 | 170 | |
| 171 | - $tacMatches = $votMatches = []; |
|
| 171 | + $tacMatches = $votMatches = [ ]; |
|
| 172 | 172 | if ( preg_match( $regTac, $content, $tacMatches ) === false ) { |
| 173 | 173 | throw new TaskException( 'Param "tacite" not found in news page' ); |
| 174 | 174 | } |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - $newTac = (int)$tacMatches[2] - $amount ?: ''; |
|
| 180 | - $newVot = (int)$votMatches[2] + $amount ?: ''; |
|
| 179 | + $newTac = (int)$tacMatches[ 2 ] - $amount ?: ''; |
|
| 180 | + $newVot = (int)$votMatches[ 2 ] + $amount ?: ''; |
|
| 181 | 181 | |
| 182 | 182 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 183 | 183 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |
@@ -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 | |
@@ -11,13 +11,13 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function run() : TaskResult { |
|
| 14 | + public function run () : TaskResult { |
|
| 15 | 15 | $this->getLogger()->info( 'Starting task UserNotice' ); |
| 16 | 16 | |
| 17 | 17 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | if ( $pages && $users ) { |
| 20 | - $ricNums = []; |
|
| 20 | + $ricNums = [ ]; |
|
| 21 | 21 | foreach ( $pages as $page ) { |
| 22 | 22 | $ricNums[ $page->getUser() ] = $page->getNum(); |
| 23 | 23 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param string $user |
| 40 | 40 | * @param int $ricNum |
| 41 | 41 | */ |
| 42 | - protected function addMsg( string $user, int $ricNum ) { |
|
| 42 | + protected function addMsg ( string $user, int $ricNum ) { |
|
| 43 | 43 | $this->getLogger()->info( "Leaving msg to $user" ); |
| 44 | 44 | $msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text(); |
| 45 | 45 | |
@@ -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 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function run() : TaskResult { |
|
| 18 | + public function run () : TaskResult { |
|
| 19 | 19 | $this->getLogger()->info( 'Starting task UpdatesAround' ); |
| 20 | 20 | |
| 21 | 21 | $pages = $this->getDataProvider()->getCreatedPages(); |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @param PageRiconferma[] $pages |
| 41 | 41 | */ |
| 42 | - protected function addToMainPage( array $pages ) { |
|
| 42 | + protected function addToMainPage ( array $pages ) { |
|
| 43 | 43 | $this->getLogger()->info( |
| 44 | 44 | 'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 45 | 45 | ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @param PageRiconferma[] $pages |
| 68 | 68 | */ |
| 69 | - protected function addVote( array $pages ) { |
|
| 69 | + protected function addVote ( array $pages ) { |
|
| 70 | 70 | $this->getLogger()->info( |
| 71 | 71 | 'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 72 | 72 | ); |
@@ -87,14 +87,14 @@ discard block |
||
| 87 | 87 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $content, 1 ); |
| 88 | 88 | } else { |
| 89 | 89 | // Start section |
| 90 | - $matches = []; |
|
| 90 | + $matches = [ ]; |
|
| 91 | 91 | if ( preg_match( $introReg, $content, $matches ) === false ) { |
| 92 | 92 | throw new TaskException( 'Intro not found in vote page' ); |
| 93 | 93 | } |
| 94 | 94 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 95 | 95 | // Replace semicolon with full stop |
| 96 | 96 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 97 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 ); |
|
| 97 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 ); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $summary = $this->msg( 'ric-vote-page-summary' ) |
@@ -113,19 +113,19 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @param int $amount |
| 115 | 115 | */ |
| 116 | - protected function addNews( int $amount ) { |
|
| 116 | + protected function addNews ( int $amount ) { |
|
| 117 | 117 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 118 | 118 | $newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) ); |
| 119 | 119 | |
| 120 | 120 | $content = $newsPage->getContent(); |
| 121 | 121 | $reg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 122 | 122 | |
| 123 | - $matches = []; |
|
| 123 | + $matches = [ ]; |
|
| 124 | 124 | if ( preg_match( $reg, $content, $matches ) === false ) { |
| 125 | 125 | throw new TaskException( 'Param not found in news page' ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $newNum = (int)$matches[2] + $amount; |
|
| 128 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 129 | 129 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 130 | 130 | |
| 131 | 131 | $summary = $this->msg( 'ric-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 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function run() : TaskResult { |
|
| 17 | + public function run () : TaskResult { |
|
| 18 | 18 | $this->getLogger()->info( 'Starting task ClosePages' ); |
| 19 | 19 | |
| 20 | 20 | $pages = $this->getPagesList(); |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return PageRiconferma[] |
| 53 | 53 | */ |
| 54 | - protected function getPagesList() : array { |
|
| 54 | + protected function getPagesList () : array { |
|
| 55 | 55 | $allPages = $this->getDataProvider()->getOpenPages(); |
| 56 | - $ret = []; |
|
| 56 | + $ret = [ ]; |
|
| 57 | 57 | foreach ( $allPages as $page ) { |
| 58 | 58 | if ( time() > $page->getEndTimestamp() ) { |
| 59 | - $ret[] = $page; |
|
| 59 | + $ret[ ] = $page; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | return $ret; |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | * @param PageRiconferma[] $pages |
| 69 | 69 | * @return PageRiconferma[] |
| 70 | 70 | */ |
| 71 | - private function getFailures( array $pages ) : array { |
|
| 72 | - $ret = []; |
|
| 71 | + private function getFailures ( array $pages ) : array { |
|
| 72 | + $ret = [ ]; |
|
| 73 | 73 | foreach ( $pages as $page ) { |
| 74 | 74 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 75 | - $ret[] = $page; |
|
| 75 | + $ret[ ] = $page; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | return $ret; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @param PageRiconferma $page |
| 83 | 83 | */ |
| 84 | - protected function addVoteCloseText( PageRiconferma $page ) { |
|
| 84 | + protected function addVoteCloseText ( PageRiconferma $page ) { |
|
| 85 | 85 | $content = $page->getContent(); |
| 86 | 86 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!'; |
| 87 | 87 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | * @param PageRiconferma[] $pages |
| 100 | 100 | * @see UpdatesAround::addToMainPage() |
| 101 | 101 | */ |
| 102 | - protected function removeFromMainPage( array $pages ) { |
|
| 102 | + protected function removeFromMainPage ( array $pages ) { |
|
| 103 | 103 | $this->getLogger()->info( |
| 104 | 104 | 'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | $mainPage = new Page( $this->getConfig()->get( 'ric-main-page' ) ); |
| 108 | - $translations = []; |
|
| 108 | + $translations = [ ]; |
|
| 109 | 109 | foreach ( $pages as $page ) { |
| 110 | 110 | $translations[ '{{' . $page->getTitle() . '}}' ] = ''; |
| 111 | 111 | } |
@@ -123,17 +123,17 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @param PageRiconferma[] $pages |
| 125 | 125 | */ |
| 126 | - protected function addToArchive( array $pages ) { |
|
| 126 | + protected function addToArchive ( array $pages ) { |
|
| 127 | 127 | $this->getLogger()->info( |
| 128 | 128 | 'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 129 | 129 | ); |
| 130 | 130 | |
| 131 | - $simple = $votes = []; |
|
| 131 | + $simple = $votes = [ ]; |
|
| 132 | 132 | foreach ( $pages as $page ) { |
| 133 | 133 | if ( $page->isVote() ) { |
| 134 | - $votes[] = $page; |
|
| 134 | + $votes[ ] = $page; |
|
| 135 | 135 | } else { |
| 136 | - $simple[] = $page; |
|
| 136 | + $simple[ ] = $page; |
|
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
@@ -150,21 +150,21 @@ discard block |
||
| 150 | 150 | * @param string $archiveTitle |
| 151 | 151 | * @param array $pages |
| 152 | 152 | */ |
| 153 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 153 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 154 | 154 | $curTitle = "$archiveTitle/" . date( 'Y' ); |
| 155 | 155 | |
| 156 | 156 | $append = ''; |
| 157 | - $archivedList = []; |
|
| 157 | + $archivedList = [ ]; |
|
| 158 | 158 | foreach ( $pages as $page ) { |
| 159 | 159 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 160 | - $archivedList[] = $page->getUserNum(); |
|
| 160 | + $archivedList[ ] = $page->getUserNum(); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | if ( count( $archivedList ) > 1 ) { |
| 164 | 164 | $last = array_pop( $archivedList ); |
| 165 | 165 | $userNums = implode( ', ', $archivedList ) . " e $last"; |
| 166 | 166 | } else { |
| 167 | - $userNums = $archivedList[0]; |
|
| 167 | + $userNums = $archivedList[ 0 ]; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -183,15 +183,14 @@ discard block |
||
| 183 | 183 | * @param PageRiconferma $page |
| 184 | 184 | * @see CreatePages::updateBasePage() |
| 185 | 185 | */ |
| 186 | - protected function updateBasePage( PageRiconferma $page ) { |
|
| 186 | + protected function updateBasePage ( PageRiconferma $page ) { |
|
| 187 | 187 | $this->getLogger()->info( "Updating base page for $page" ); |
| 188 | 188 | |
| 189 | 189 | $basePage = new Page( $page->getBaseTitle() ); |
| 190 | 190 | $current = $basePage->getContent(); |
| 191 | 191 | |
| 192 | 192 | $outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ? |
| 193 | - 'non riconfermato' : |
|
| 194 | - 'riconfermato'; |
|
| 193 | + 'non riconfermato' : 'riconfermato'; |
|
| 195 | 194 | $text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita'; |
| 196 | 195 | |
| 197 | 196 | $newContent = str_replace( 'riconferma in corso', $text, $current ); |
@@ -207,16 +206,16 @@ discard block |
||
| 207 | 206 | * @param PageRiconferma[] $pages |
| 208 | 207 | * @see UpdatesAround::addVote() |
| 209 | 208 | */ |
| 210 | - protected function updateVote( array $pages ) { |
|
| 209 | + protected function updateVote ( array $pages ) { |
|
| 211 | 210 | $this->getLogger()->info( |
| 212 | 211 | 'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 213 | 212 | ); |
| 214 | 213 | $votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) ); |
| 215 | 214 | $content = $votePage->getContent(); |
| 216 | 215 | |
| 217 | - $titles = []; |
|
| 216 | + $titles = [ ]; |
|
| 218 | 217 | foreach ( $pages as $page ) { |
| 219 | - $titles[] = preg_quote( $page->getTitle() ); |
|
| 218 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
| 220 | 219 | } |
| 221 | 220 | |
| 222 | 221 | $titleReg = implode( '|', array_map( 'preg_quote', $titles ) ); |
@@ -247,7 +246,7 @@ discard block |
||
| 247 | 246 | * @param array $pages |
| 248 | 247 | * @see UpdatesAround::addNews() |
| 249 | 248 | */ |
| 250 | - protected function updateNews( array $pages ) { |
|
| 249 | + protected function updateNews ( array $pages ) { |
|
| 251 | 250 | $simpleAmount = $voteAmount = 0; |
| 252 | 251 | foreach ( $pages as $page ) { |
| 253 | 252 | if ( $page->isVote() ) { |
@@ -267,12 +266,12 @@ discard block |
||
| 267 | 266 | $simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 268 | 267 | $voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!'; |
| 269 | 268 | |
| 270 | - $simpleMatches = $voteMatches = []; |
|
| 269 | + $simpleMatches = $voteMatches = [ ]; |
|
| 271 | 270 | preg_match( $simpleReg, $content, $simpleMatches ); |
| 272 | 271 | preg_match( $voteReg, $content, $voteMatches ); |
| 273 | 272 | |
| 274 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 275 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 273 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 274 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 276 | 275 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content ); |
| 277 | 276 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 278 | 277 | |
@@ -292,7 +291,7 @@ discard block |
||
| 292 | 291 | * |
| 293 | 292 | * @param PageRiconferma[] $pages |
| 294 | 293 | */ |
| 295 | - protected function updateAdminList( array $pages ) { |
|
| 294 | + protected function updateAdminList ( array $pages ) { |
|
| 296 | 295 | $this->getLogger()->info( |
| 297 | 296 | 'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 298 | 297 | ); |
@@ -300,17 +299,17 @@ discard block |
||
| 300 | 299 | $newContent = $adminsPage->getContent(); |
| 301 | 300 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 302 | 301 | |
| 303 | - $riconfNames = $removeNames = []; |
|
| 302 | + $riconfNames = $removeNames = [ ]; |
|
| 304 | 303 | foreach ( $pages as $page ) { |
| 305 | 304 | $user = $page->getUser(); |
| 306 | 305 | $reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!"; |
| 307 | 306 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 308 | 307 | // Remove the line |
| 309 | 308 | $newContent = preg_replace( $reg, '', $newContent ); |
| 310 | - $removeNames[] = $user; |
|
| 309 | + $removeNames[ ] = $user; |
|
| 311 | 310 | } else { |
| 312 | 311 | $newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent ); |
| 313 | - $riconfNames[] = $user; |
|
| 312 | + $riconfNames[ ] = $user; |
|
| 314 | 313 | } |
| 315 | 314 | } |
| 316 | 315 | |
@@ -318,7 +317,7 @@ discard block |
||
| 318 | 317 | $lastUser = array_pop( $riconfNames ); |
| 319 | 318 | $riconfList = implode( ', ', $riconfNames ) . " e $lastUser"; |
| 320 | 319 | } elseif ( $riconfNames ) { |
| 321 | - $riconfList = $riconfNames[0]; |
|
| 320 | + $riconfList = $riconfNames[ 0 ]; |
|
| 322 | 321 | } else { |
| 323 | 322 | $riconfList = 'nessuno'; |
| 324 | 323 | } |
@@ -327,7 +326,7 @@ discard block |
||
| 327 | 326 | $lastUser = array_pop( $removeNames ); |
| 328 | 327 | $removeList = implode( ', ', $removeNames ) . " e $lastUser"; |
| 329 | 328 | } elseif ( $removeNames ) { |
| 330 | - $removeList = $removeNames[0]; |
|
| 329 | + $removeList = $removeNames[ 0 ]; |
|
| 331 | 330 | } else { |
| 332 | 331 | $removeList = 'nessuno'; |
| 333 | 332 | } |
@@ -350,13 +349,13 @@ discard block |
||
| 350 | 349 | /** |
| 351 | 350 | * @param PageRiconferma[] $pages |
| 352 | 351 | */ |
| 353 | - protected function updateCUList( array $pages ) { |
|
| 352 | + protected function updateCUList ( array $pages ) { |
|
| 354 | 353 | $this->getLogger()->info( 'Checking if CU list needs updating.' ); |
| 355 | 354 | $cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) ); |
| 356 | 355 | $admins = $this->getDataProvider()->getUsersList(); |
| 357 | 356 | $newContent = $cuList->getContent(); |
| 358 | 357 | |
| 359 | - $riconfNames = $removeNames = []; |
|
| 358 | + $riconfNames = $removeNames = [ ]; |
|
| 360 | 359 | foreach ( $pages as $page ) { |
| 361 | 360 | $user = $page->getUser(); |
| 362 | 361 | if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) { |
@@ -364,10 +363,10 @@ discard block |
||
| 364 | 363 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 365 | 364 | // Remove the line |
| 366 | 365 | $newContent = preg_replace( $reg, '', $newContent ); |
| 367 | - $removeNames[] = $user; |
|
| 366 | + $removeNames[ ] = $user; |
|
| 368 | 367 | } else { |
| 369 | 368 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 370 | - $riconfNames[] = $user; |
|
| 369 | + $riconfNames[ ] = $user; |
|
| 371 | 370 | } |
| 372 | 371 | } |
| 373 | 372 | } |
@@ -384,7 +383,7 @@ discard block |
||
| 384 | 383 | $lastUser = array_pop( $riconfNames ); |
| 385 | 384 | $riconfList = implode( ', ', $riconfNames ) . " e $lastUser"; |
| 386 | 385 | } elseif ( $riconfNames ) { |
| 387 | - $riconfList = $riconfNames[0]; |
|
| 386 | + $riconfList = $riconfNames[ 0 ]; |
|
| 388 | 387 | } else { |
| 389 | 388 | $riconfList = 'nessuno'; |
| 390 | 389 | } |
@@ -393,7 +392,7 @@ discard block |
||
| 393 | 392 | $lastUser = array_pop( $removeNames ); |
| 394 | 393 | $removeList = implode( ', ', $removeNames ) . " e $lastUser"; |
| 395 | 394 | } elseif ( $removeNames ) { |
| 396 | - $removeList = $removeNames[0]; |
|
| 395 | + $removeList = $removeNames[ 0 ]; |
|
| 397 | 396 | } else { |
| 398 | 397 | $removeList = 'nessuno'; |
| 399 | 398 | } |
@@ -415,17 +414,17 @@ discard block |
||
| 415 | 414 | /** |
| 416 | 415 | * @param PageRiconferma[] $pages |
| 417 | 416 | */ |
| 418 | - protected function updateBurList( array $pages ) { |
|
| 417 | + protected function updateBurList ( array $pages ) { |
|
| 419 | 418 | $this->getLogger()->info( 'Checking if bur list needs updating.' ); |
| 420 | 419 | $admins = $this->getDataProvider()->getUsersList(); |
| 421 | 420 | |
| 422 | - $remove = []; |
|
| 421 | + $remove = [ ]; |
|
| 423 | 422 | foreach ( $pages as $page ) { |
| 424 | 423 | $user = $page->getUser(); |
| 425 | 424 | if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) && |
| 426 | 425 | $page->getOutcome() & PageRiconferma::OUTCOME_FAIL |
| 427 | 426 | ) { |
| 428 | - $remove[] = $user; |
|
| 427 | + $remove[ ] = $user; |
|
| 429 | 428 | } |
| 430 | 429 | } |
| 431 | 430 | |
@@ -444,7 +443,7 @@ discard block |
||
| 444 | 443 | $lastUser = array_pop( $remove ); |
| 445 | 444 | $removeList = implode( ', ', $remove ) . " e $lastUser"; |
| 446 | 445 | } else { |
| 447 | - $removeList = $remove[0]; |
|
| 446 | + $removeList = $remove[ 0 ]; |
|
| 448 | 447 | } |
| 449 | 448 | |
| 450 | 449 | $summary = $this->msg( 'bur-list-update-summary' ) |
@@ -463,7 +462,7 @@ discard block |
||
| 463 | 462 | * |
| 464 | 463 | * @param PageRiconferma[] $pages |
| 465 | 464 | */ |
| 466 | - protected function requestRemoval( array $pages ) { |
|
| 465 | + protected function requestRemoval ( array $pages ) { |
|
| 467 | 466 | $this->getLogger()->info( |
| 468 | 467 | 'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 469 | 468 | ); |
@@ -506,14 +505,14 @@ discard block |
||
| 506 | 505 | * |
| 507 | 506 | * @param PageRiconferma[] $pages |
| 508 | 507 | */ |
| 509 | - protected function updateAnnunci( array $pages ) { |
|
| 508 | + protected function updateAnnunci ( array $pages ) { |
|
| 510 | 509 | $this->getLogger()->info( 'Updating annunci' ); |
| 511 | 510 | |
| 512 | - $names = []; |
|
| 511 | + $names = [ ]; |
|
| 513 | 512 | $text = ''; |
| 514 | 513 | foreach ( $pages as $page ) { |
| 515 | 514 | $user = $page->getUser(); |
| 516 | - $names[] = $user; |
|
| 515 | + $names[ ] = $user; |
|
| 517 | 516 | $text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " . |
| 518 | 517 | "non è stato riconfermato [[WP:A|amministratore]].}}\n"; |
| 519 | 518 | } |
@@ -536,7 +535,7 @@ discard block |
||
| 536 | 535 | $lastUser = array_pop( $names ); |
| 537 | 536 | $namesList = implode( ', ', $names ) . " e $lastUser"; |
| 538 | 537 | } else { |
| 539 | - $namesList = $names[0]; |
|
| 538 | + $namesList = $names[ 0 ]; |
|
| 540 | 539 | } |
| 541 | 540 | |
| 542 | 541 | $summary = $this->msg( 'annunci-summary' ) |
@@ -555,16 +554,16 @@ discard block |
||
| 555 | 554 | * |
| 556 | 555 | * @param PageRiconferma[] $pages |
| 557 | 556 | */ |
| 558 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 557 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 559 | 558 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 560 | 559 | $notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-title' ) ); |
| 561 | 560 | |
| 562 | - $names = []; |
|
| 561 | + $names = [ ]; |
|
| 563 | 562 | $text = ''; |
| 564 | 563 | foreach ( $pages as $page ) { |
| 565 | 564 | $user = $page->getUser(); |
| 566 | 565 | $title = $page->getTitle(); |
| 567 | - $names[] = $user; |
|
| 566 | + $names[ ] = $user; |
|
| 568 | 567 | $text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " . |
| 569 | 568 | '[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.'; |
| 570 | 569 | } |
@@ -583,7 +582,7 @@ discard block |
||
| 583 | 582 | $lastUser = array_pop( $names ); |
| 584 | 583 | $namesList = implode( ', ', $names ) . " e $lastUser"; |
| 585 | 584 | } else { |
| 586 | - $namesList = $names[0]; |
|
| 585 | + $namesList = $names[ 0 ]; |
|
| 587 | 586 | } |
| 588 | 587 | |
| 589 | 588 | $summary = $this->msg( 'ultimenotizie-summary' ) |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task\Subtask; |
| 4 | 4 | |
@@ -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 run() : TaskResult { |
|
| 17 | + public function run () : TaskResult { |
|
| 18 | 18 | $this->getLogger()->info( 'Starting task CreatePages' ); |
| 19 | 19 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 20 | 20 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param string $user |
| 37 | 37 | * @param array $groups |
| 38 | 38 | */ |
| 39 | - protected function processUser( string $user, array $groups ) { |
|
| 39 | + protected function processUser ( string $user, array $groups ) { |
|
| 40 | 40 | try { |
| 41 | 41 | $num = $this->getLastPageNum( $user ) + 1; |
| 42 | 42 | } catch ( TaskException $e ) { |
@@ -68,9 +68,9 @@ discard block |
||
| 68 | 68 | * @return int |
| 69 | 69 | * @throws TaskException |
| 70 | 70 | */ |
| 71 | - protected function getLastPageNum( string $user ) : int { |
|
| 71 | + protected function getLastPageNum ( string $user ) : int { |
|
| 72 | 72 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 73 | - $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1]; |
|
| 73 | + $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ]; |
|
| 74 | 74 | $params = [ |
| 75 | 75 | 'action' => 'query', |
| 76 | 76 | 'list' => 'allpages', |
@@ -105,14 +105,14 @@ discard block |
||
| 105 | 105 | * @param string $user |
| 106 | 106 | * @param array $groups |
| 107 | 107 | */ |
| 108 | - protected function createPage( string $title, string $user, array $groups ) { |
|
| 108 | + protected function createPage ( string $title, string $user, array $groups ) { |
|
| 109 | 109 | $this->getLogger()->info( "Creating page $title" ); |
| 110 | 110 | $text = $this->getConfig()->get( 'ric-page-text' ); |
| 111 | 111 | $textParams = [ |
| 112 | 112 | '$user' => $user, |
| 113 | - '$date' => $groups['sysop'], |
|
| 114 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 115 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 113 | + '$date' => $groups[ 'sysop' ], |
|
| 114 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 115 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 116 | 116 | ]; |
| 117 | 117 | $text = strtr( $text, $textParams ); |
| 118 | 118 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $title |
| 132 | 132 | * @param string $newText |
| 133 | 133 | */ |
| 134 | - protected function createBasePage( string $title, string $newText ) { |
|
| 134 | + protected function createBasePage ( string $title, string $newText ) { |
|
| 135 | 135 | $this->getLogger()->info( "Creating base page $title" ); |
| 136 | 136 | |
| 137 | 137 | $params = [ |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param string $title |
| 149 | 149 | * @param string $newText |
| 150 | 150 | */ |
| 151 | - protected function updateBasePage( string $title, string $newText ) { |
|
| 151 | + protected function updateBasePage ( string $title, string $newText ) { |
|
| 152 | 152 | $this->getLogger()->info( "Updating base page $title" ); |
| 153 | 153 | |
| 154 | 154 | $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; |
| 4 | 4 | |
@@ -18,15 +18,15 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @inheritDoc |
| 20 | 20 | */ |
| 21 | - protected function getSubtasksMap(): array { |
|
| 21 | + protected function getSubtasksMap (): array { |
|
| 22 | 22 | // Everything is done here. |
| 23 | - return []; |
|
| 23 | + return [ ]; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @inheritDoc |
| 28 | 28 | */ |
| 29 | - public function run() : TaskResult { |
|
| 29 | + public function run () : TaskResult { |
|
| 30 | 30 | $this->getLogger()->info( 'Starting task UpdateList' ); |
| 31 | 31 | $this->actualList = $this->getActualAdmins(); |
| 32 | 32 | $this->botList = $this->getDataProvider()->getUsersList(); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | /** |
| 62 | 62 | * @return array |
| 63 | 63 | */ |
| 64 | - protected function getActualAdmins() : array { |
|
| 64 | + protected function getActualAdmins () : array { |
|
| 65 | 65 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 66 | 66 | $params = [ |
| 67 | 67 | 'action' => 'query', |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | * @param \stdClass $data |
| 80 | 80 | * @return array |
| 81 | 81 | */ |
| 82 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 83 | - $ret = []; |
|
| 82 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 83 | + $ret = [ ]; |
|
| 84 | 84 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 85 | 85 | foreach ( $data->query->allusers as $u ) { |
| 86 | 86 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -97,22 +97,22 @@ discard block |
||
| 97 | 97 | * |
| 98 | 98 | * @return array[] |
| 99 | 99 | */ |
| 100 | - protected function getMissingGroups() : array { |
|
| 101 | - $missing = []; |
|
| 100 | + protected function getMissingGroups () : array { |
|
| 101 | + $missing = [ ]; |
|
| 102 | 102 | foreach ( $this->actualList as $adm => $groups ) { |
| 103 | - $groupsList = []; |
|
| 103 | + $groupsList = [ ]; |
|
| 104 | 104 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 105 | 105 | $groupsList = $groups; |
| 106 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 106 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 107 | 107 | // Only some groups are missing |
| 108 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 108 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | foreach ( $groupsList as $group ) { |
| 112 | 112 | try { |
| 113 | 113 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 114 | 114 | } catch ( TaskException $e ) { |
| 115 | - $this->errors[] = $e->getMessage(); |
|
| 115 | + $this->errors[ ] = $e->getMessage(); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return string |
| 128 | 128 | * @throws TaskException |
| 129 | 129 | */ |
| 130 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 130 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 131 | 131 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 132 | 132 | |
| 133 | 133 | $url = DEFAULT_URL; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param string $group |
| 163 | 163 | * @return string|null |
| 164 | 164 | */ |
| 165 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 165 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 166 | 166 | $ts = null; |
| 167 | 167 | foreach ( $data->query->logevents as $entry ) { |
| 168 | 168 | if ( !isset( $entry->params ) ) { |
@@ -184,8 +184,8 @@ discard block |
||
| 184 | 184 | * |
| 185 | 185 | * @return array[] |
| 186 | 186 | */ |
| 187 | - protected function getExtraGroups() : array { |
|
| 188 | - $extra = []; |
|
| 187 | + protected function getExtraGroups () : array { |
|
| 188 | + $extra = [ ]; |
|
| 189 | 189 | foreach ( $this->botList as $name => $groups ) { |
| 190 | 190 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 191 | 191 | $extra[ $name ] = $groups; |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * |
| 202 | 202 | * @param array $newContent |
| 203 | 203 | */ |
| 204 | - protected function doUpdateList( array $newContent ) { |
|
| 204 | + protected function doUpdateList ( array $newContent ) { |
|
| 205 | 205 | $this->getLogger()->info( 'Updating admin list' ); |
| 206 | 206 | |
| 207 | 207 | $params = [ |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @param array[] $extra |
| 221 | 221 | * @return array[] |
| 222 | 222 | */ |
| 223 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 223 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 224 | 224 | $newContent = $this->botList; |
| 225 | 225 | foreach ( $newContent as $user => $groups ) { |
| 226 | 226 | if ( isset( $missing[ $user ] ) ) { |
@@ -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 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | /** |
| 13 | 13 | * @inheritDoc |
| 14 | 14 | */ |
| 15 | - public function run() : TaskResult { |
|
| 15 | + public function run () : TaskResult { |
|
| 16 | 16 | $orderedList = [ |
| 17 | 17 | 'close-pages' |
| 18 | 18 | ]; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @inheritDoc |
| 30 | 30 | */ |
| 31 | - protected function getSubtasksMap(): array { |
|
| 31 | + protected function getSubtasksMap (): array { |
|
| 32 | 32 | return [ |
| 33 | 33 | 'close-pages' => ClosePages::class |
| 34 | 34 | ]; |
@@ -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,13 +14,13 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return string[] |
| 16 | 16 | */ |
| 17 | - abstract protected function getSubtasksMap() : array; |
|
| 17 | + abstract protected function getSubtasksMap () : array; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param string $subtask Defined in self::SUBTASKS_MAP |
| 21 | 21 | * @return TaskResult |
| 22 | 22 | */ |
| 23 | - protected function runSubtask( string $subtask ) : TaskResult { |
|
| 23 | + protected function runSubtask ( string $subtask ) : TaskResult { |
|
| 24 | 24 | $map = $this->getSubtasksMap(); |
| 25 | 25 | if ( !isset( $map[ $subtask ] ) ) { |
| 26 | 26 | throw new \InvalidArgumentException( "'$subtask' is not a valid task." ); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param string $class |
| 37 | 37 | * @return Subtask |
| 38 | 38 | */ |
| 39 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 39 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 40 | 40 | return new $class( $this->getDataProvider() ); |
| 41 | 41 | } |
| 42 | 42 | } |