@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Page; |
| 4 | 4 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param string $title |
| 21 | 21 | * @param string $domain The site where the page lives, if different from default |
| 22 | 22 | */ |
| 23 | - public function __construct( string $title, string $domain = DEFAULT_URL ) { |
|
| 23 | + public function __construct ( string $title, string $domain = DEFAULT_URL ) { |
|
| 24 | 24 | $this->title = $title; |
| 25 | 25 | $this->controller = new WikiController( $domain ); |
| 26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - public function getTitle() : string { |
|
| 31 | + public function getTitle () : string { |
|
| 32 | 32 | return $this->title; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param int|null $section A section number to retrieve the content of that section |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | - public function getContent( int $section = null ) : string { |
|
| 41 | + public function getContent ( int $section = null ) : string { |
|
| 42 | 42 | if ( $this->content === null ) { |
| 43 | 43 | $this->content = $this->controller->getPageContent( $this->title, $section ); |
| 44 | 44 | } |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @param array $params |
| 52 | 52 | */ |
| 53 | - public function edit( array $params ) { |
|
| 53 | + public function edit ( array $params ) { |
|
| 54 | 54 | $params = [ |
| 55 | 55 | 'title' => $this->getTitle() |
| 56 | 56 | ] + $params; |
| 57 | 57 | |
| 58 | 58 | $this->controller->editPage( $params ); |
| 59 | - if ( isset( $params['text'] ) ) { |
|
| 60 | - $this->content = $params['text']; |
|
| 61 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 62 | - $this->content .= $params['appendtext']; |
|
| 59 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 60 | + $this->content = $params[ 'text' ]; |
|
| 61 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 62 | + $this->content .= $params[ 'appendtext' ]; |
|
| 63 | 63 | } else { |
| 64 | 64 | // Clear the cache anyway |
| 65 | 65 | ( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) ); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param string $regex |
| 74 | 74 | * @return bool |
| 75 | 75 | */ |
| 76 | - public function matches( string $regex ) : bool { |
|
| 76 | + public function matches ( string $regex ) : bool { |
|
| 77 | 77 | return preg_match( $regex, $this->getContent() ) !== false; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @return string[] |
| 86 | 86 | * @throws \Exception |
| 87 | 87 | */ |
| 88 | - public function getMatch( string $regex ) : array { |
|
| 89 | - $ret = []; |
|
| 88 | + public function getMatch ( string $regex ) : array { |
|
| 89 | + $ret = [ ]; |
|
| 90 | 90 | if ( preg_match( $regex, $this->getContent(), $ret ) === false ) { |
| 91 | 91 | throw new \Exception; |
| 92 | 92 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | - public function __toString() { |
|
| 101 | + public function __toString () { |
|
| 102 | 102 | return $this->getTitle(); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -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 | |
@@ -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 | $failed = $this->getFailures(); |
| 18 | 18 | if ( $failed ) { |
| 19 | 19 | $this->updateBurList( $failed ); |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return PageRiconferma[] |
| 32 | 32 | */ |
| 33 | - private function getFailures() : array { |
|
| 34 | - $ret = []; |
|
| 33 | + private function getFailures () : array { |
|
| 34 | + $ret = [ ]; |
|
| 35 | 35 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 36 | 36 | foreach ( $allPages as $page ) { |
| 37 | 37 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 38 | - $ret[] = $page; |
|
| 38 | + $ret[ ] = $page; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | return $ret; |
@@ -44,17 +44,17 @@ discard block |
||
| 44 | 44 | /** |
| 45 | 45 | * @param PageRiconferma[] $pages |
| 46 | 46 | */ |
| 47 | - protected function updateBurList( array $pages ) { |
|
| 47 | + protected function updateBurList ( array $pages ) { |
|
| 48 | 48 | $this->getLogger()->info( 'Checking if bur list needs updating.' ); |
| 49 | 49 | $admins = $this->getDataProvider()->getUsersList(); |
| 50 | 50 | |
| 51 | - $remove = []; |
|
| 51 | + $remove = [ ]; |
|
| 52 | 52 | foreach ( $pages as $page ) { |
| 53 | 53 | $user = $page->getUser(); |
| 54 | 54 | if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) && |
| 55 | 55 | $page->getOutcome() & PageRiconferma::OUTCOME_FAIL |
| 56 | 56 | ) { |
| 57 | - $remove[] = $user; |
|
| 57 | + $remove[ ] = $user; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @param PageRiconferma[] $pages |
| 86 | 86 | */ |
| 87 | - protected function requestRemoval( array $pages ) { |
|
| 87 | + protected function requestRemoval ( array $pages ) { |
|
| 88 | 88 | $this->getLogger()->info( |
| 89 | 89 | 'Requesting removal on meta for: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 90 | 90 | ); |
@@ -126,14 +126,14 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @param PageRiconferma[] $pages |
| 128 | 128 | */ |
| 129 | - protected function updateAnnunci( array $pages ) { |
|
| 129 | + protected function updateAnnunci ( array $pages ) { |
|
| 130 | 130 | $this->getLogger()->info( 'Updating annunci' ); |
| 131 | 131 | |
| 132 | - $names = []; |
|
| 132 | + $names = [ ]; |
|
| 133 | 133 | $text = ''; |
| 134 | 134 | foreach ( $pages as $page ) { |
| 135 | 135 | $user = $page->getUser(); |
| 136 | - $names[] = $user; |
|
| 136 | + $names[ ] = $user; |
|
| 137 | 137 | $text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] " . |
| 138 | 138 | "non è stato riconfermato [[WP:A|amministratore]].}}\n"; |
| 139 | 139 | } |
@@ -167,16 +167,16 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @param PageRiconferma[] $pages |
| 169 | 169 | */ |
| 170 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 170 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 171 | 171 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 172 | 172 | $notiziePage = new Page( $this->getConfig()->get( 'ultimenotizie-title' ) ); |
| 173 | 173 | |
| 174 | - $names = []; |
|
| 174 | + $names = [ ]; |
|
| 175 | 175 | $text = ''; |
| 176 | 176 | foreach ( $pages as $page ) { |
| 177 | 177 | $user = $page->getUser(); |
| 178 | 178 | $title = $page->getTitle(); |
| 179 | - $names[] = $user; |
|
| 179 | + $names[ ] = $user; |
|
| 180 | 180 | $text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] " . |
| 181 | 181 | '[[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}.'; |
| 182 | 182 | } |
@@ -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 | $this->updateVote( $pages ); |
| 19 | 19 | $this->updateNews( $pages ); |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * @param PageRiconferma[] $pages |
| 28 | 28 | * @see UpdatesAround::addVote() |
| 29 | 29 | */ |
| 30 | - protected function updateVote( array $pages ) { |
|
| 30 | + protected function updateVote ( array $pages ) { |
|
| 31 | 31 | $this->getLogger()->info( |
| 32 | 32 | 'Updating votazioni: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 33 | 33 | ); |
| 34 | 34 | $votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) ); |
| 35 | 35 | |
| 36 | - $titles = []; |
|
| 36 | + $titles = [ ]; |
|
| 37 | 37 | foreach ( $pages as $page ) { |
| 38 | - $titles[] = preg_quote( $page->getTitle() ); |
|
| 38 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $titleReg = implode( '|', $titles ); |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param array $pages |
| 65 | 65 | * @see UpdatesAround::addNews() |
| 66 | 66 | */ |
| 67 | - protected function updateNews( array $pages ) { |
|
| 67 | + protected function updateNews ( array $pages ) { |
|
| 68 | 68 | $simpleAmount = $voteAmount = 0; |
| 69 | 69 | foreach ( $pages as $page ) { |
| 70 | 70 | 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, $content ); |
| 93 | 93 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 94 | 94 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @param PageRiconferma[] $pages |
| 108 | 108 | */ |
| 109 | - protected function updateAdminList( array $pages ) { |
|
| 109 | + protected function updateAdminList ( array $pages ) { |
|
| 110 | 110 | $this->getLogger()->info( |
| 111 | 111 | 'Updating admin list: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 112 | 112 | ); |
@@ -114,17 +114,17 @@ discard block |
||
| 114 | 114 | $newContent = $adminsPage->getContent(); |
| 115 | 115 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 116 | 116 | |
| 117 | - $riconfNames = $removeNames = []; |
|
| 117 | + $riconfNames = $removeNames = [ ]; |
|
| 118 | 118 | foreach ( $pages as $page ) { |
| 119 | 119 | $user = $page->getUser(); |
| 120 | 120 | $reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!"; |
| 121 | 121 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 122 | 122 | // Remove the line |
| 123 | 123 | $newContent = preg_replace( $reg, '', $newContent ); |
| 124 | - $removeNames[] = $user; |
|
| 124 | + $removeNames[ ] = $user; |
|
| 125 | 125 | } else { |
| 126 | 126 | $newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent ); |
| 127 | - $riconfNames[] = $user; |
|
| 127 | + $riconfNames[ ] = $user; |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -144,13 +144,13 @@ discard block |
||
| 144 | 144 | /** |
| 145 | 145 | * @param PageRiconferma[] $pages |
| 146 | 146 | */ |
| 147 | - protected function updateCUList( array $pages ) { |
|
| 147 | + protected function updateCUList ( array $pages ) { |
|
| 148 | 148 | $this->getLogger()->info( 'Checking if CU list needs updating.' ); |
| 149 | 149 | $cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) ); |
| 150 | 150 | $admins = $this->getDataProvider()->getUsersList(); |
| 151 | 151 | $newContent = $cuList->getContent(); |
| 152 | 152 | |
| 153 | - $riconfNames = $removeNames = []; |
|
| 153 | + $riconfNames = $removeNames = [ ]; |
|
| 154 | 154 | foreach ( $pages as $page ) { |
| 155 | 155 | $user = $page->getUser(); |
| 156 | 156 | if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) { |
@@ -158,10 +158,10 @@ discard block |
||
| 158 | 158 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 159 | 159 | // Remove the line |
| 160 | 160 | $newContent = preg_replace( $reg, '', $newContent ); |
| 161 | - $removeNames[] = $user; |
|
| 161 | + $removeNames[ ] = $user; |
|
| 162 | 162 | } else { |
| 163 | 163 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 164 | - $riconfNames[] = $user; |
|
| 164 | + $riconfNames[ ] = $user; |
|
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | } |
@@ -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 runInternal() : int { |
|
| 17 | + public function runInternal () : int { |
|
| 18 | 18 | $pages = $this->getDataProvider()->getCreatedPages(); |
| 19 | 19 | |
| 20 | 20 | if ( !$pages ) { |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @param PageRiconferma[] $pages |
| 38 | 38 | */ |
| 39 | - protected function addToMainPage( array $pages ) { |
|
| 39 | + protected function addToMainPage ( array $pages ) { |
|
| 40 | 40 | $this->getLogger()->info( |
| 41 | 41 | 'Adding the following to main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 42 | 42 | ); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @param PageRiconferma[] $pages |
| 65 | 65 | */ |
| 66 | - protected function addVote( array $pages ) { |
|
| 66 | + protected function addVote ( array $pages ) { |
|
| 67 | 67 | $this->getLogger()->info( |
| 68 | 68 | 'Adding the following to votes: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 69 | 69 | ); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 93 | 93 | // Replace semicolon with full stop |
| 94 | 94 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 95 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $content, 1 ); |
|
| 95 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $content, 1 ); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $summary = $this->msg( 'ric-vote-page-summary' ) |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * |
| 112 | 112 | * @param int $amount |
| 113 | 113 | */ |
| 114 | - protected function addNews( int $amount ) { |
|
| 114 | + protected function addNews ( int $amount ) { |
|
| 115 | 115 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 116 | 116 | $newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) ); |
| 117 | 117 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | throw new TaskException( 'Param not found in news page' ); |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | - $newNum = (int)$matches[2] + $amount; |
|
| 127 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 128 | 128 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 129 | 129 | |
| 130 | 130 | $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 | |
@@ -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 | $this->removeFromMainPage( $pages ); |
| 19 | 19 | $this->addToArchive( $pages ); |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | * @param PageRiconferma[] $pages |
| 28 | 28 | * @see UpdatesAround::addToMainPage() |
| 29 | 29 | */ |
| 30 | - protected function removeFromMainPage( array $pages ) { |
|
| 30 | + protected function removeFromMainPage ( array $pages ) { |
|
| 31 | 31 | $this->getLogger()->info( |
| 32 | 32 | 'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 33 | 33 | ); |
| 34 | 34 | |
| 35 | 35 | $mainPage = new Page( $this->getConfig()->get( 'ric-main-page' ) ); |
| 36 | - $remove = []; |
|
| 36 | + $remove = [ ]; |
|
| 37 | 37 | foreach ( $pages as $page ) { |
| 38 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
| 38 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $mainPage->edit( [ |
@@ -49,17 +49,17 @@ discard block |
||
| 49 | 49 | * |
| 50 | 50 | * @param PageRiconferma[] $pages |
| 51 | 51 | */ |
| 52 | - protected function addToArchive( array $pages ) { |
|
| 52 | + protected function addToArchive ( array $pages ) { |
|
| 53 | 53 | $this->getLogger()->info( |
| 54 | 54 | 'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | - $simple = $votes = []; |
|
| 57 | + $simple = $votes = [ ]; |
|
| 58 | 58 | foreach ( $pages as $page ) { |
| 59 | 59 | if ( $page->isVote() ) { |
| 60 | - $votes[] = $page; |
|
| 60 | + $votes[ ] = $page; |
|
| 61 | 61 | } else { |
| 62 | - $simple[] = $page; |
|
| 62 | + $simple[ ] = $page; |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | * @param string $archiveTitle |
| 77 | 77 | * @param array $pages |
| 78 | 78 | */ |
| 79 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 79 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 80 | 80 | $archivePage = new Page( "$archiveTitle/" . date( 'Y' ) ); |
| 81 | 81 | |
| 82 | 82 | $append = ''; |
| 83 | - $archivedList = []; |
|
| 83 | + $archivedList = [ ]; |
|
| 84 | 84 | foreach ( $pages as $page ) { |
| 85 | 85 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 86 | - $archivedList[] = $page->getUserNum(); |
|
| 86 | + $archivedList[ ] = $page->getUserNum(); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | $summary = $this->msg( 'close-archive-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; |
| 4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function runInternal() : int { |
|
| 18 | + public function runInternal () : int { |
|
| 19 | 19 | $orderedList = [ |
| 20 | 20 | 'close-pages', |
| 21 | 21 | 'archive-pages', |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - protected function getSubtasksMap(): array { |
|
| 37 | + protected function getSubtasksMap (): array { |
|
| 38 | 38 | return [ |
| 39 | 39 | 'archive-pages' => ArchivePages::class, |
| 40 | 40 | 'close-pages' => ClosePages::class, |
@@ -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 runInternal() : int { |
|
| 29 | + public function runInternal () : int { |
|
| 30 | 30 | $this->actualList = $this->getActualAdmins(); |
| 31 | 31 | $this->botList = $this->getDataProvider()->getUsersList(); |
| 32 | 32 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @return array |
| 57 | 57 | */ |
| 58 | - protected function getActualAdmins() : array { |
|
| 58 | + protected function getActualAdmins () : array { |
|
| 59 | 59 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 60 | 60 | $params = [ |
| 61 | 61 | 'action' => 'query', |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @param \stdClass $data |
| 74 | 74 | * @return array |
| 75 | 75 | */ |
| 76 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 77 | - $ret = []; |
|
| 76 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 77 | + $ret = [ ]; |
|
| 78 | 78 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 79 | 79 | foreach ( $data->query->allusers as $u ) { |
| 80 | 80 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -91,22 +91,22 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return array[] |
| 93 | 93 | */ |
| 94 | - protected function getMissingGroups() : array { |
|
| 95 | - $missing = []; |
|
| 94 | + protected function getMissingGroups () : array { |
|
| 95 | + $missing = [ ]; |
|
| 96 | 96 | foreach ( $this->actualList as $adm => $groups ) { |
| 97 | - $groupsList = []; |
|
| 97 | + $groupsList = [ ]; |
|
| 98 | 98 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 99 | 99 | $groupsList = $groups; |
| 100 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 100 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 101 | 101 | // Only some groups are missing |
| 102 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 102 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | foreach ( $groupsList as $group ) { |
| 106 | 106 | try { |
| 107 | 107 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 108 | 108 | } catch ( TaskException $e ) { |
| 109 | - $this->errors[] = $e->getMessage(); |
|
| 109 | + $this->errors[ ] = $e->getMessage(); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @return string |
| 122 | 122 | * @throws TaskException |
| 123 | 123 | */ |
| 124 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 124 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 125 | 125 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 126 | 126 | |
| 127 | 127 | $url = DEFAULT_URL; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param string $group |
| 157 | 157 | * @return string|null |
| 158 | 158 | */ |
| 159 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 159 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 160 | 160 | $ts = null; |
| 161 | 161 | foreach ( $data->query->logevents as $entry ) { |
| 162 | 162 | if ( !isset( $entry->params ) ) { |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return array[] |
| 180 | 180 | */ |
| 181 | - protected function getExtraGroups() : array { |
|
| 182 | - $extra = []; |
|
| 181 | + protected function getExtraGroups () : array { |
|
| 182 | + $extra = [ ]; |
|
| 183 | 183 | foreach ( $this->botList as $name => $groups ) { |
| 184 | 184 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 185 | 185 | $extra[ $name ] = $groups; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param array[] $extra |
| 198 | 198 | * @return array[] |
| 199 | 199 | */ |
| 200 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 200 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 201 | 201 | $newContent = $this->botList; |
| 202 | 202 | foreach ( $newContent as $user => $groups ) { |
| 203 | 203 | 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\Subtask; |
| 4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function runInternal() : int { |
|
| 17 | + public function runInternal () : int { |
|
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | |
| 20 | 20 | if ( !$users ) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param string $user |
| 35 | 35 | * @param array $groups |
| 36 | 36 | */ |
| 37 | - protected function processUser( string $user, array $groups ) { |
|
| 37 | + protected function processUser ( string $user, array $groups ) { |
|
| 38 | 38 | try { |
| 39 | 39 | $num = $this->getLastPageNum( $user ) + 1; |
| 40 | 40 | } catch ( TaskException $e ) { |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | * @return int |
| 67 | 67 | * @throws TaskException |
| 68 | 68 | */ |
| 69 | - protected function getLastPageNum( string $user ) : int { |
|
| 69 | + protected function getLastPageNum ( string $user ) : int { |
|
| 70 | 70 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 71 | - $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[1]; |
|
| 71 | + $unprefixedTitle = explode( ':', $this->getConfig()->get( 'ric-main-page' ), 2 )[ 1 ]; |
|
| 72 | 72 | $params = [ |
| 73 | 73 | 'action' => 'query', |
| 74 | 74 | 'list' => 'allpages', |
@@ -103,14 +103,14 @@ discard block |
||
| 103 | 103 | * @param string $user |
| 104 | 104 | * @param array $groups |
| 105 | 105 | */ |
| 106 | - protected function createPage( string $title, string $user, array $groups ) { |
|
| 106 | + protected function createPage ( string $title, string $user, array $groups ) { |
|
| 107 | 107 | $this->getLogger()->info( "Creating page $title" ); |
| 108 | 108 | $text = $this->getConfig()->get( 'ric-page-text' ); |
| 109 | 109 | $textParams = [ |
| 110 | 110 | '$user' => $user, |
| 111 | - '$date' => $groups['sysop'], |
|
| 112 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 113 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 111 | + '$date' => $groups[ 'sysop' ], |
|
| 112 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 113 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 114 | 114 | ]; |
| 115 | 115 | $text = strtr( $text, $textParams ); |
| 116 | 116 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | * @param string $title |
| 130 | 130 | * @param string $newText |
| 131 | 131 | */ |
| 132 | - protected function createBasePage( string $title, string $newText ) { |
|
| 132 | + protected function createBasePage ( string $title, string $newText ) { |
|
| 133 | 133 | $this->getLogger()->info( "Creating base page $title" ); |
| 134 | 134 | |
| 135 | 135 | $params = [ |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param string $title |
| 147 | 147 | * @param string $newText |
| 148 | 148 | */ |
| 149 | - protected function updateBasePage( string $title, string $newText ) { |
|
| 149 | + protected function updateBasePage ( string $title, string $newText ) { |
|
| 150 | 150 | $this->getLogger()->info( "Updating base page $title" ); |
| 151 | 151 | |
| 152 | 152 | $params = [ |