@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @param string $key |
| 16 | 16 | */ |
| 17 | - public function __construct( string $key ) { |
|
| 17 | + public function __construct ( string $key ) { |
|
| 18 | 18 | $this->key = $key; |
| 19 | 19 | $this->value = Config::getInstance()->getWikiMessage( $key ); |
| 20 | 20 | } |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * @param array $args |
| 24 | 24 | * @return self |
| 25 | 25 | */ |
| 26 | - public function params( array $args ) : self { |
|
| 26 | + public function params ( array $args ) : self { |
|
| 27 | 27 | $this->value = strtr( $this->value, $args ); |
| 28 | 28 | return $this; |
| 29 | 29 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | /** |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public function text() : string { |
|
| 34 | + public function text () : string { |
|
| 35 | 35 | $this->parsePlurals(); |
| 36 | 36 | return $this->value; |
| 37 | 37 | } |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Replace {{$plur|<amount>|sing|plur}} |
| 41 | 41 | */ |
| 42 | - protected function parsePlurals() { |
|
| 42 | + protected function parsePlurals () { |
|
| 43 | 43 | $this->value = preg_replace_callback( |
| 44 | 44 | '!\{\{$plur|(?P<amount>\d+)|(?P<sing>[^}|]+)|(?P<plur>[^|}]+)}}!', |
| 45 | 45 | function ( $matches ) { |
| 46 | - return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
| 46 | + return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
| 47 | 47 | }, |
| 48 | 48 | $this->value |
| 49 | 49 | ); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * @param int $timestamp |
| 56 | 56 | * @return string |
| 57 | 57 | */ |
| 58 | - public static function getTimeWithArticle( int $timestamp ) : string { |
|
| 58 | + public static function getTimeWithArticle ( int $timestamp ) : string { |
|
| 59 | 59 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 60 | 60 | $timeString = strftime( '%e %B alle %R', $timestamp ); |
| 61 | 61 | // Remove the left space if day has a single digit |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | * @return int |
| 74 | 74 | * @todo Is there a better way? |
| 75 | 75 | */ |
| 76 | - public static function getTimestampFromLocalTime( string $timeString ) : int { |
|
| 76 | + public static function getTimestampFromLocalTime ( string $timeString ) : int { |
|
| 77 | 77 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 78 | 78 | $bits = strptime( $timeString, '%e %m %Y alle %H:%M' ); |
| 79 | 79 | $timestamp = mktime( |
| 80 | - $bits['tm_hour'], |
|
| 81 | - $bits['tm_min'], |
|
| 80 | + $bits[ 'tm_hour' ], |
|
| 81 | + $bits[ 'tm_min' ], |
|
| 82 | 82 | 0, |
| 83 | - $bits['tm_mon'] + 1, |
|
| 84 | - $bits['tm_mday'], |
|
| 85 | - $bits['tm_year'] + 1900 |
|
| 83 | + $bits[ 'tm_mon' ] + 1, |
|
| 84 | + $bits[ 'tm_mday' ], |
|
| 85 | + $bits[ 'tm_year' ] + 1900 |
|
| 86 | 86 | ); |
| 87 | 87 | setlocale( LC_TIME, $oldLoc ); |
| 88 | 88 | |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | * @param string $emptyText |
| 98 | 98 | * @return string |
| 99 | 99 | */ |
| 100 | - public static function commaList( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 100 | + public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 101 | 101 | if ( count( $data ) > 1 ) { |
| 102 | 102 | $last = array_pop( $data ); |
| 103 | 103 | $ret = implode( ', ', $data ) . " e $last"; |
| 104 | 104 | } elseif ( $data ) { |
| 105 | - $ret = $data[0]; |
|
| 105 | + $ret = $data[ 0 ]; |
|
| 106 | 106 | } else { |
| 107 | 107 | $ret = $emptyText; |
| 108 | 108 | } |
@@ -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 FailedUpdates' ); |
| 19 | 19 | |
| 20 | 20 | $failed = $this->getFailures(); |
@@ -34,12 +34,12 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return PageRiconferma[] |
| 36 | 36 | */ |
| 37 | - private function getFailures() : array { |
|
| 38 | - $ret = []; |
|
| 37 | + private function getFailures () : array { |
|
| 38 | + $ret = [ ]; |
|
| 39 | 39 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 40 | 40 | foreach ( $allPages as $page ) { |
| 41 | 41 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 42 | - $ret[] = $page; |
|
| 42 | + $ret[ ] = $page; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | return $ret; |
@@ -48,17 +48,17 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * @param PageRiconferma[] $pages |
| 50 | 50 | */ |
| 51 | - protected function updateBurList( array $pages ) { |
|
| 51 | + protected function updateBurList ( array $pages ) { |
|
| 52 | 52 | $this->getLogger()->info( 'Checking if bur list needs updating.' ); |
| 53 | 53 | $admins = $this->getDataProvider()->getUsersList(); |
| 54 | 54 | |
| 55 | - $remove = []; |
|
| 55 | + $remove = [ ]; |
|
| 56 | 56 | foreach ( $pages as $page ) { |
| 57 | 57 | $user = $page->getUser(); |
| 58 | 58 | if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) && |
| 59 | 59 | $page->getOutcome() & PageRiconferma::OUTCOME_FAIL |
| 60 | 60 | ) { |
| 61 | - $remove[] = $user; |
|
| 61 | + $remove[ ] = $user; |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @param PageRiconferma[] $pages |
| 90 | 90 | */ |
| 91 | - protected function requestRemoval( array $pages ) { |
|
| 91 | + protected function requestRemoval ( array $pages ) { |
|
| 92 | 92 | $this->getLogger()->info( |
| 93 | 93 | 'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 94 | 94 | ); |
@@ -130,14 +130,14 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @param PageRiconferma[] $pages |
| 132 | 132 | */ |
| 133 | - protected function updateAnnunci( array $pages ) { |
|
| 133 | + protected function updateAnnunci ( array $pages ) { |
|
| 134 | 134 | $this->getLogger()->info( 'Updating annunci' ); |
| 135 | 135 | |
| 136 | - $names = []; |
|
| 136 | + $names = [ ]; |
|
| 137 | 137 | $text = ''; |
| 138 | 138 | foreach ( $pages as $page ) { |
| 139 | 139 | $user = $page->getUser(); |
| 140 | - $names[] = $user; |
|
| 140 | + $names[ ] = $user; |
|
| 141 | 141 | $text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " . |
| 142 | 142 | "non è stato riconfermato [[WP:A|amministratore]].}}\n"; |
| 143 | 143 | } |
@@ -171,16 +171,16 @@ discard block |
||
| 171 | 171 | * |
| 172 | 172 | * @param PageRiconferma[] $pages |
| 173 | 173 | */ |
| 174 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 174 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 175 | 175 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 176 | 176 | $notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-title' ) ); |
| 177 | 177 | |
| 178 | - $names = []; |
|
| 178 | + $names = [ ]; |
|
| 179 | 179 | $text = ''; |
| 180 | 180 | foreach ( $pages as $page ) { |
| 181 | 181 | $user = $page->getUser(); |
| 182 | 182 | $title = $page->getTitle(); |
| 183 | - $names[] = $user; |
|
| 183 | + $names[ ] = $user; |
|
| 184 | 184 | $text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " . |
| 185 | 185 | '[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.'; |
| 186 | 186 | } |
@@ -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 SimpleUpdates' ); |
| 19 | 19 | |
| 20 | 20 | $pages = $this->getDataProvider()->getPagesToClose(); |
@@ -31,15 +31,15 @@ discard block |
||
| 31 | 31 | * @param PageRiconferma[] $pages |
| 32 | 32 | * @see UpdatesAround::addVote() |
| 33 | 33 | */ |
| 34 | - protected function updateVote( array $pages ) { |
|
| 34 | + protected function updateVote ( array $pages ) { |
|
| 35 | 35 | $this->getLogger()->info( |
| 36 | 36 | 'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 37 | 37 | ); |
| 38 | 38 | $votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) ); |
| 39 | 39 | |
| 40 | - $titles = []; |
|
| 40 | + $titles = [ ]; |
|
| 41 | 41 | foreach ( $pages as $page ) { |
| 42 | - $titles[] = preg_quote( $page->getTitle() ); |
|
| 42 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $titleReg = implode( '|', $titles ); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param array $pages |
| 69 | 69 | * @see UpdatesAround::addNews() |
| 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() ) { |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 92 | 92 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 93 | 93 | |
| 94 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 95 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 94 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 95 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 96 | 96 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content ); |
| 97 | 97 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 98 | 98 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * |
| 111 | 111 | * @param PageRiconferma[] $pages |
| 112 | 112 | */ |
| 113 | - protected function updateAdminList( array $pages ) { |
|
| 113 | + protected function updateAdminList ( array $pages ) { |
|
| 114 | 114 | $this->getLogger()->info( |
| 115 | 115 | 'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 116 | 116 | ); |
@@ -118,17 +118,17 @@ discard block |
||
| 118 | 118 | $newContent = $adminsPage->getContent(); |
| 119 | 119 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 120 | 120 | |
| 121 | - $riconfNames = $removeNames = []; |
|
| 121 | + $riconfNames = $removeNames = [ ]; |
|
| 122 | 122 | foreach ( $pages as $page ) { |
| 123 | 123 | $user = $page->getUser(); |
| 124 | 124 | $reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!"; |
| 125 | 125 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 126 | 126 | // Remove the line |
| 127 | 127 | $newContent = preg_replace( $reg, '', $newContent ); |
| 128 | - $removeNames[] = $user; |
|
| 128 | + $removeNames[ ] = $user; |
|
| 129 | 129 | } else { |
| 130 | 130 | $newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent ); |
| 131 | - $riconfNames[] = $user; |
|
| 131 | + $riconfNames[ ] = $user; |
|
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
@@ -148,13 +148,13 @@ discard block |
||
| 148 | 148 | /** |
| 149 | 149 | * @param PageRiconferma[] $pages |
| 150 | 150 | */ |
| 151 | - protected function updateCUList( array $pages ) { |
|
| 151 | + protected function updateCUList ( array $pages ) { |
|
| 152 | 152 | $this->getLogger()->info( 'Checking if CU list needs updating.' ); |
| 153 | 153 | $cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) ); |
| 154 | 154 | $admins = $this->getDataProvider()->getUsersList(); |
| 155 | 155 | $newContent = $cuList->getContent(); |
| 156 | 156 | |
| 157 | - $riconfNames = $removeNames = []; |
|
| 157 | + $riconfNames = $removeNames = [ ]; |
|
| 158 | 158 | foreach ( $pages as $page ) { |
| 159 | 159 | $user = $page->getUser(); |
| 160 | 160 | if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) { |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 163 | 163 | // Remove the line |
| 164 | 164 | $newContent = preg_replace( $reg, '', $newContent ); |
| 165 | - $removeNames[] = $user; |
|
| 165 | + $removeNames[ ] = $user; |
|
| 166 | 166 | } else { |
| 167 | 167 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 168 | - $riconfNames[] = $user; |
|
| 168 | + $riconfNames[ ] = $user; |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -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 ArchivePages' ); |
| 19 | 19 | |
| 20 | 20 | $pages = $this->getDataProvider()->getPagesToClose(); |
@@ -31,15 +31,15 @@ discard block |
||
| 31 | 31 | * @param PageRiconferma[] $pages |
| 32 | 32 | * @see UpdatesAround::addToMainPage() |
| 33 | 33 | */ |
| 34 | - protected function removeFromMainPage( array $pages ) { |
|
| 34 | + protected function removeFromMainPage ( array $pages ) { |
|
| 35 | 35 | $this->getLogger()->info( |
| 36 | 36 | 'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 37 | 37 | ); |
| 38 | 38 | |
| 39 | 39 | $mainPage = new Page( $this->getConfig()->get( 'ric-main-page' ) ); |
| 40 | - $remove = []; |
|
| 40 | + $remove = [ ]; |
|
| 41 | 41 | foreach ( $pages as $page ) { |
| 42 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
| 42 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $mainPage->edit( [ |
@@ -53,17 +53,17 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @param PageRiconferma[] $pages |
| 55 | 55 | */ |
| 56 | - protected function addToArchive( array $pages ) { |
|
| 56 | + protected function addToArchive ( array $pages ) { |
|
| 57 | 57 | $this->getLogger()->info( |
| 58 | 58 | 'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - $simple = $votes = []; |
|
| 61 | + $simple = $votes = [ ]; |
|
| 62 | 62 | foreach ( $pages as $page ) { |
| 63 | 63 | if ( $page->isVote() ) { |
| 64 | - $votes[] = $page; |
|
| 64 | + $votes[ ] = $page; |
|
| 65 | 65 | } else { |
| 66 | - $simple[] = $page; |
|
| 66 | + $simple[ ] = $page; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | * @param string $archiveTitle |
| 81 | 81 | * @param array $pages |
| 82 | 82 | */ |
| 83 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 83 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 84 | 84 | $archivePage = new Page( "$archiveTitle/" . date( 'Y' ) ); |
| 85 | 85 | |
| 86 | 86 | $append = ''; |
| 87 | - $archivedList = []; |
|
| 87 | + $archivedList = [ ]; |
|
| 88 | 88 | foreach ( $pages as $page ) { |
| 89 | 89 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 90 | - $archivedList[] = $page->getUserNum(); |
|
| 90 | + $archivedList[ ] = $page->getUserNum(); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $summary = $this->msg( 'close-archive-summary' ) |