@@ -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 | |
@@ -16,15 +16,15 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @inheritDoc |
| 18 | 18 | */ |
| 19 | - protected function getSubtasksMap(): array { |
|
| 19 | + protected function getSubtasksMap (): array { |
|
| 20 | 20 | // Everything is done here. |
| 21 | - return []; |
|
| 21 | + return [ ]; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @inheritDoc |
| 26 | 26 | */ |
| 27 | - public function runInternal() : int { |
|
| 27 | + public function runInternal () : int { |
|
| 28 | 28 | $pages = $this->getDataProvider()->getOpenPages(); |
| 29 | 29 | |
| 30 | 30 | if ( !$pages ) { |
@@ -38,12 +38,12 @@ discard block |
||
| 38 | 38 | * @param PageRiconferma[] $pages |
| 39 | 39 | * @return int a STATUS_* constant |
| 40 | 40 | */ |
| 41 | - protected function processPages( array $pages ) : int { |
|
| 42 | - $actualPages = []; |
|
| 41 | + protected function processPages ( array $pages ) : int { |
|
| 42 | + $actualPages = [ ]; |
|
| 43 | 43 | foreach ( $pages as $page ) { |
| 44 | 44 | if ( $page->hasOpposition() && !$page->isVote() ) { |
| 45 | 45 | $this->openVote( $page ); |
| 46 | - $actualPages[] = $page; |
|
| 46 | + $actualPages[ ] = $page; |
|
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @param PageRiconferma $page |
| 63 | 63 | */ |
| 64 | - protected function openVote( PageRiconferma $page ) { |
|
| 64 | + protected function openVote ( PageRiconferma $page ) { |
|
| 65 | 65 | $this->getLogger()->info( "Starting vote on $page" ); |
| 66 | 66 | |
| 67 | 67 | $content = $page->getContent(); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @see SimpleUpdates::updateVotazioni() |
| 101 | 101 | * @see UpdatesAround::addToVotazioni() |
| 102 | 102 | */ |
| 103 | - protected function updateVotePage( array $pages ) { |
|
| 103 | + protected function updateVotePage ( array $pages ) { |
|
| 104 | 104 | $votePage = new Page( $this->getConfig()->get( 'vote-page-title' ) ); |
| 105 | 105 | $content = $votePage->getContent(); |
| 106 | 106 | |
@@ -127,14 +127,14 @@ discard block |
||
| 127 | 127 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 ); |
| 128 | 128 | } else { |
| 129 | 129 | // Start section |
| 130 | - $matches = []; |
|
| 130 | + $matches = [ ]; |
|
| 131 | 131 | if ( preg_match( $introReg, $newContent, $matches ) === 0 ) { |
| 132 | 132 | throw new TaskException( 'Intro not found in vote page' ); |
| 133 | 133 | } |
| 134 | 134 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
| 135 | 135 | // Replace semicolon with full stop |
| 136 | 136 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
| 137 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 ); |
|
| 137 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 ); |
|
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | $summary = $this->msg( 'vote-start-vote-page-summary' ) |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @see UpdatesAround::addToNews() |
| 157 | 157 | * @see SimpleUpdates::updateNews() |
| 158 | 158 | */ |
| 159 | - protected function updateNews( int $amount ) { |
|
| 159 | + protected function updateNews ( int $amount ) { |
|
| 160 | 160 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
| 161 | 161 | $newsPage = new Page( $this->getConfig()->get( 'news-page-title' ) ); |
| 162 | 162 | |
@@ -171,8 +171,8 @@ discard block |
||
| 171 | 171 | throw new TaskException( 'Param "voto" not found in news page' ); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - $newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: ''; |
|
| 175 | - $newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: ''; |
|
| 174 | + $newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: ''; |
|
| 175 | + $newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: ''; |
|
| 176 | 176 | |
| 177 | 177 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
| 178 | 178 | $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\Wiki; |
| 4 | 4 | |
@@ -16,21 +16,21 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @param string $name |
| 18 | 18 | */ |
| 19 | - public function __construct( string $name ) { |
|
| 19 | + public function __construct ( string $name ) { |
|
| 20 | 20 | $this->name = $name; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public function getName() : string { |
|
| 26 | + public function getName () : string { |
|
| 27 | 27 | return $this->name; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * @return string[] |
| 32 | 32 | */ |
| 33 | - public function getGroups() : array { |
|
| 33 | + public function getGroups () : array { |
|
| 34 | 34 | if ( $this->groups === null ) { |
| 35 | 35 | $usersList = PageBotList::get()->getAdminsList(); |
| 36 | 36 | $this->groups = array_keys( $usersList[ $this->name ] ); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | * @param string $groupName |
| 45 | 45 | * @return bool |
| 46 | 46 | */ |
| 47 | - public function inGroup( string $groupName ) : bool { |
|
| 47 | + public function inGroup ( string $groupName ) : bool { |
|
| 48 | 48 | return in_array( $groupName, $this->getGroups() ); |
| 49 | 49 | } |
| 50 | 50 | |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @inheritDoc |
| 55 | 55 | */ |
| 56 | - public function getRegex() : string { |
|
| 56 | + public function getRegex () : string { |
|
| 57 | 57 | return str_replace( ' ', '[ _]', preg_quote( $this->name ) ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public function __toString() { |
|
| 63 | + public function __toString () { |
|
| 64 | 64 | return $this->name; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Wiki\Page; |
| 4 | 4 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $title |
| 22 | 22 | * @param string $domain The site where the page lives, if different from default |
| 23 | 23 | */ |
| 24 | - public function __construct( string $title, string $domain = DEFAULT_URL ) { |
|
| 24 | + public function __construct ( string $title, string $domain = DEFAULT_URL ) { |
|
| 25 | 25 | $this->title = $title; |
| 26 | 26 | $this->controller = new Controller( $domain ); |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - public function getTitle() : string { |
|
| 32 | + public function getTitle () : string { |
|
| 33 | 33 | return $this->title; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param int|null $section A section number to retrieve the content of that section |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - public function getContent( int $section = null ) : string { |
|
| 42 | + public function getContent ( int $section = null ) : string { |
|
| 43 | 43 | if ( $this->content === null ) { |
| 44 | 44 | $this->content = $this->controller->getPageContent( $this->title, $section ); |
| 45 | 45 | } |
@@ -51,16 +51,16 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @param array $params |
| 53 | 53 | */ |
| 54 | - public function edit( array $params ) { |
|
| 54 | + public function edit ( array $params ) { |
|
| 55 | 55 | $params = [ |
| 56 | 56 | 'title' => $this->getTitle() |
| 57 | 57 | ] + $params; |
| 58 | 58 | |
| 59 | 59 | $this->controller->editPage( $params ); |
| 60 | - if ( isset( $params['text'] ) ) { |
|
| 61 | - $this->content = $params['text']; |
|
| 62 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 63 | - $this->content .= $params['appendtext']; |
|
| 60 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 61 | + $this->content = $params[ 'text' ]; |
|
| 62 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 63 | + $this->content .= $params[ 'appendtext' ]; |
|
| 64 | 64 | } else { |
| 65 | 65 | // Clear the cache anyway |
| 66 | 66 | ( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param string $regex |
| 75 | 75 | * @return bool |
| 76 | 76 | */ |
| 77 | - public function matches( string $regex ) : bool { |
|
| 77 | + public function matches ( string $regex ) : bool { |
|
| 78 | 78 | return (bool)preg_match( $regex, $this->getContent() ); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * @return string[] |
| 87 | 87 | * @throws \Exception |
| 88 | 88 | */ |
| 89 | - public function getMatch( string $regex ) : array { |
|
| 90 | - $ret = []; |
|
| 89 | + public function getMatch ( string $regex ) : array { |
|
| 90 | + $ret = [ ]; |
|
| 91 | 91 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 92 | 92 | throw new \Exception( 'The content does not match the given regex' ); |
| 93 | 93 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @inheritDoc |
| 101 | 101 | */ |
| 102 | - public function getRegex() : string { |
|
| 102 | + public function getRegex () : string { |
|
| 103 | 103 | return str_replace( ' ', '[ _]', preg_quote( $this->title ) ); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @return string |
| 110 | 110 | */ |
| 111 | - public function __toString() { |
|
| 111 | + public function __toString () { |
|
| 112 | 112 | return $this->getTitle(); |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Wiki; |
| 4 | 4 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @return string |
| 13 | 13 | */ |
| 14 | - abstract public function getRegex() : string; |
|
| 14 | + abstract public function getRegex () : string; |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Get a regex matching any element in the given array |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | * @return string |
| 21 | 21 | * @fixme Is this the right place? |
| 22 | 22 | */ |
| 23 | - public static function regexFromArray( array $elements ) : string { |
|
| 24 | - $bits = []; |
|
| 23 | + public static function regexFromArray ( array $elements ) : string { |
|
| 24 | + $bits = [ ]; |
|
| 25 | 25 | foreach ( $elements as $el ) { |
| 26 | - $bits[] = $el->getRegex(); |
|
| 26 | + $bits[ ] = $el->getRegex(); |
|
| 27 | 27 | } |
| 28 | 28 | return '(?:' . implode( '|', $bits ) . ')'; |
| 29 | 29 | } |
@@ -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,7 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Replace {{$plur|<amount>|sing|plur}} |
| 41 | 41 | */ |
| 42 | - protected function parsePlurals() { |
|
| 42 | + protected function parsePlurals () { |
|
| 43 | 43 | $reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!'; |
| 44 | 44 | |
| 45 | 45 | if ( preg_match( $reg, $this->value ) === 0 ) { |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | $this->value = preg_replace_callback( |
| 49 | 49 | $reg, |
| 50 | 50 | function ( $matches ) { |
| 51 | - return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
| 51 | + return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
| 52 | 52 | }, |
| 53 | 53 | $this->value |
| 54 | 54 | ); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param int $timestamp |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public static function getTimeWithArticle( int $timestamp ) : string { |
|
| 63 | + public static function getTimeWithArticle ( int $timestamp ) : string { |
|
| 64 | 64 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 65 | 65 | $timeString = strftime( '%e %B alle %R', $timestamp ); |
| 66 | 66 | // Remove the left space if day has a single digit |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param string $timeString |
| 78 | 78 | * @return int |
| 79 | 79 | */ |
| 80 | - public static function getTimestampFromLocalTime( string $timeString ) : int { |
|
| 80 | + public static function getTimestampFromLocalTime ( string $timeString ) : int { |
|
| 81 | 81 | $months = [ |
| 82 | 82 | 'gennaio' => 'January', |
| 83 | 83 | 'febbraio' => 'February', |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | * @param string $emptyText |
| 108 | 108 | * @return string |
| 109 | 109 | */ |
| 110 | - public static function commaList( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 110 | + public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 111 | 111 | if ( count( $data ) > 1 ) { |
| 112 | 112 | $last = array_pop( $data ); |
| 113 | 113 | $ret = implode( ', ', $data ) . " e $last"; |
| 114 | 114 | } elseif ( $data ) { |
| 115 | - $ret = (string)$data[0]; |
|
| 115 | + $ret = (string)$data[ 0 ]; |
|
| 116 | 116 | } else { |
| 117 | 117 | $ret = $emptyText; |
| 118 | 118 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | return $ret; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - public function __toString() { |
|
| 123 | + public function __toString () { |
|
| 124 | 124 | return $this->text(); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -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 runInternal() : int { |
|
| 18 | + public function runInternal () : int { |
|
| 19 | 19 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 20 | 20 | |
| 21 | 21 | if ( !$pages ) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param PageRiconferma[] $pages |
| 35 | 35 | * @see UpdatesAround::addToVotazioni() |
| 36 | 36 | */ |
| 37 | - protected function updateVotazioni( array $pages ) { |
|
| 37 | + protected function updateVotazioni ( array $pages ) { |
|
| 38 | 38 | $this->getLogger()->info( |
| 39 | 39 | 'Updating votazioni: ' . implode( ', ', $pages ) |
| 40 | 40 | ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param array $pages |
| 67 | 67 | * @see UpdatesAround::addToNews() |
| 68 | 68 | */ |
| 69 | - protected function updateNews( array $pages ) { |
|
| 69 | + protected function updateNews ( array $pages ) { |
|
| 70 | 70 | $simpleAmount = $voteAmount = 0; |
| 71 | 71 | foreach ( $pages as $page ) { |
| 72 | 72 | if ( $page->isVote() ) { |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 90 | 90 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 91 | 91 | |
| 92 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 93 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 92 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 93 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 94 | 94 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content ); |
| 95 | 95 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 96 | 96 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param PageRiconferma[] $pages |
| 110 | 110 | */ |
| 111 | - protected function updateAdminList( array $pages ) { |
|
| 111 | + protected function updateAdminList ( array $pages ) { |
|
| 112 | 112 | $this->getLogger()->info( |
| 113 | 113 | 'Updating admin list: ' . implode( ', ', $pages ) |
| 114 | 114 | ); |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | $newContent = $adminsPage->getContent(); |
| 117 | 117 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 118 | 118 | |
| 119 | - $riconfNames = $removeNames = []; |
|
| 119 | + $riconfNames = $removeNames = [ ]; |
|
| 120 | 120 | foreach ( $pages as $page ) { |
| 121 | 121 | $user = $page->getUser(); |
| 122 | 122 | $reg = '!(\{\{Amministratore\/riga\|' . $user->getRegex() . ".+\| *)\d+( *\|[ \w]*\}\}\n)!"; |
| 123 | 123 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 124 | 124 | // Remove the line |
| 125 | 125 | $newContent = preg_replace( $reg, '', $newContent ); |
| 126 | - $removeNames[] = $user->getName(); |
|
| 126 | + $removeNames[ ] = $user->getName(); |
|
| 127 | 127 | } else { |
| 128 | 128 | $newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent ); |
| 129 | - $riconfNames[] = $user->getName(); |
|
| 129 | + $riconfNames[ ] = $user->getName(); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @param PageRiconferma[] $pages |
| 148 | 148 | */ |
| 149 | - protected function updateCUList( array $pages ) { |
|
| 149 | + protected function updateCUList ( array $pages ) { |
|
| 150 | 150 | $this->getLogger()->info( 'Checking if CU list needs updating.' ); |
| 151 | 151 | $cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) ); |
| 152 | 152 | $newContent = $cuList->getContent(); |
| 153 | 153 | |
| 154 | - $riconfNames = $removeNames = []; |
|
| 154 | + $riconfNames = $removeNames = [ ]; |
|
| 155 | 155 | foreach ( $pages as $page ) { |
| 156 | 156 | $user = $page->getUser(); |
| 157 | 157 | if ( $user->inGroup( 'checkuser' ) ) { |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 160 | 160 | // Remove the line |
| 161 | 161 | $newContent = preg_replace( $reg, '', $newContent ); |
| 162 | - $removeNames[] = $user->getName(); |
|
| 162 | + $removeNames[ ] = $user->getName(); |
|
| 163 | 163 | } else { |
| 164 | 164 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 165 | - $riconfNames[] = $user->getName(); |
|
| 165 | + $riconfNames[ ] = $user->getName(); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -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 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK |
| 53 | 53 | * @return TaskResult |
| 54 | 54 | */ |
| 55 | - public function run( string $mode, string $name = null ) : TaskResult { |
|
| 55 | + public function run ( string $mode, string $name = null ) : TaskResult { |
|
| 56 | 56 | $this->provider = new TaskDataProvider; |
| 57 | 57 | |
| 58 | 58 | if ( $mode === self::MODE_COMPLETE ) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return TaskResult |
| 71 | 71 | */ |
| 72 | - protected function runAllTasks() : TaskResult { |
|
| 72 | + protected function runAllTasks () : TaskResult { |
|
| 73 | 73 | $orderedList = [ |
| 74 | 74 | 'update-list', |
| 75 | 75 | 'start-new', |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $name |
| 92 | 92 | * @return TaskResult |
| 93 | 93 | */ |
| 94 | - protected function runTask( string $name ) : TaskResult { |
|
| 94 | + protected function runTask ( string $name ) : TaskResult { |
|
| 95 | 95 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 96 | 96 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
| 97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param string $name |
| 107 | 107 | * @return TaskResult |
| 108 | 108 | */ |
| 109 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 109 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 110 | 110 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 111 | 111 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 112 | 112 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param string $class |
| 122 | 122 | * @return Task |
| 123 | 123 | */ |
| 124 | - private function getTaskInstance( string $class ) : Task { |
|
| 124 | + private function getTaskInstance ( string $class ) : Task { |
|
| 125 | 125 | return new $class( $this->provider ); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $class |
| 132 | 132 | * @return Subtask |
| 133 | 133 | */ |
| 134 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 134 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 135 | 135 | return new $class( $this->provider ); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -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,16 +14,16 @@ discard block |
||
| 14 | 14 | /** @var array[] */ |
| 15 | 15 | private $processUsers; |
| 16 | 16 | /** @var PageRiconferma[] */ |
| 17 | - private $createdPages = []; |
|
| 17 | + private $createdPages = [ ]; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Get a list of users to execute tasks on. |
| 21 | 21 | * |
| 22 | 22 | * @return array[] |
| 23 | 23 | */ |
| 24 | - public function getUsersToProcess() : array { |
|
| 24 | + public function getUsersToProcess () : array { |
|
| 25 | 25 | if ( $this->processUsers === null ) { |
| 26 | - $this->processUsers = []; |
|
| 26 | + $this->processUsers = [ ]; |
|
| 27 | 27 | foreach ( PageBotList::get()->getAdminsList() as $user => $groups ) { |
| 28 | 28 | if ( array_intersect_key( $groups, [ 'override-perm', 'override' ] ) ) { |
| 29 | 29 | // A one-time override takes precedence |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return PageRiconferma[] |
| 53 | 53 | */ |
| 54 | - public function getOpenPages() : array { |
|
| 54 | + public function getOpenPages () : array { |
|
| 55 | 55 | static $list = null; |
| 56 | 56 | if ( $list === null ) { |
| 57 | 57 | $mainTitle = $this->getConfig()->get( 'main-page-title' ); |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $pages = RequestBase::newFromParams( $params )->execute()->query->pages; |
| 67 | 67 | $reg = ( new Page( $mainTitle ) )->getRegex(); |
| 68 | - $list = []; |
|
| 68 | + $list = [ ]; |
|
| 69 | 69 | foreach ( reset( $pages )->templates as $page ) { |
| 70 | 70 | if ( preg_match( "!$reg\/[^\/]+\/\d!", $page->title ) ) { |
| 71 | - $list[] = new PageRiconferma( $page->title ); |
|
| 71 | + $list[ ] = new PageRiconferma( $page->title ); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -81,14 +81,14 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @return PageRiconferma[] |
| 83 | 83 | */ |
| 84 | - public function getPagesToClose() : array { |
|
| 84 | + public function getPagesToClose () : array { |
|
| 85 | 85 | static $list = null; |
| 86 | 86 | if ( $list === null ) { |
| 87 | 87 | $allPages = $this->getOpenPages(); |
| 88 | - $list = []; |
|
| 88 | + $list = [ ]; |
|
| 89 | 89 | foreach ( $allPages as $page ) { |
| 90 | 90 | if ( time() > $page->getEndTimestamp() ) { |
| 91 | - $list[] = $page; |
|
| 91 | + $list[ ] = $page; |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -100,21 +100,21 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @param string $name |
| 102 | 102 | */ |
| 103 | - public function removeUser( string $name ) { |
|
| 103 | + public function removeUser ( string $name ) { |
|
| 104 | 104 | unset( $this->processUsers[ $name ] ); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @return PageRiconferma[] |
| 109 | 109 | */ |
| 110 | - public function getCreatedPages() : array { |
|
| 110 | + public function getCreatedPages () : array { |
|
| 111 | 111 | return $this->createdPages; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * @param PageRiconferma $page |
| 116 | 116 | */ |
| 117 | - public function addCreatedPages( PageRiconferma $page ) { |
|
| 118 | - $this->createdPages[] = $page; |
|
| 117 | + public function addCreatedPages ( PageRiconferma $page ) { |
|
| 118 | + $this->createdPages[ ] = $page; |
|
| 119 | 119 | } |
| 120 | 120 | } |
@@ -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 | $this->botList = PageBotList::get()->getAdminsList(); |
| 33 | 33 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * @return array |
| 58 | 58 | */ |
| 59 | - protected function getActualAdmins() : array { |
|
| 59 | + protected function getActualAdmins () : array { |
|
| 60 | 60 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 61 | 61 | $params = [ |
| 62 | 62 | 'action' => 'query', |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @param \stdClass $data |
| 75 | 75 | * @return array |
| 76 | 76 | */ |
| 77 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 78 | - $ret = []; |
|
| 77 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 78 | + $ret = [ ]; |
|
| 79 | 79 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 80 | 80 | foreach ( $data->query->allusers as $u ) { |
| 81 | 81 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -92,22 +92,22 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @return array[] |
| 94 | 94 | */ |
| 95 | - protected function getMissingGroups() : array { |
|
| 96 | - $missing = []; |
|
| 95 | + protected function getMissingGroups () : array { |
|
| 96 | + $missing = [ ]; |
|
| 97 | 97 | foreach ( $this->actualList as $adm => $groups ) { |
| 98 | - $groupsList = []; |
|
| 98 | + $groupsList = [ ]; |
|
| 99 | 99 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 100 | 100 | $groupsList = $groups; |
| 101 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 101 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 102 | 102 | // Only some groups are missing |
| 103 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 103 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | foreach ( $groupsList as $group ) { |
| 107 | 107 | try { |
| 108 | 108 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 109 | 109 | } catch ( TaskException $e ) { |
| 110 | - $this->errors[] = $e->getMessage(); |
|
| 110 | + $this->errors[ ] = $e->getMessage(); |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @return string |
| 123 | 123 | * @throws TaskException |
| 124 | 124 | */ |
| 125 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 125 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 126 | 126 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 127 | 127 | |
| 128 | 128 | $url = DEFAULT_URL; |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $group |
| 158 | 158 | * @return string|null |
| 159 | 159 | */ |
| 160 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 160 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 161 | 161 | $ts = null; |
| 162 | 162 | foreach ( $data->query->logevents as $entry ) { |
| 163 | 163 | if ( !isset( $entry->params ) ) { |
@@ -179,8 +179,8 @@ discard block |
||
| 179 | 179 | * |
| 180 | 180 | * @return array[] |
| 181 | 181 | */ |
| 182 | - protected function getExtraGroups() : array { |
|
| 183 | - $extra = []; |
|
| 182 | + protected function getExtraGroups () : array { |
|
| 183 | + $extra = [ ]; |
|
| 184 | 184 | foreach ( $this->botList as $name => $groups ) { |
| 185 | 185 | // These are not groups |
| 186 | 186 | unset( $groups[ 'override' ], $groups[ 'override-perm' ] ); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param array[] $extra |
| 201 | 201 | * @return array[] |
| 202 | 202 | */ |
| 203 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 203 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 204 | 204 | $newContent = $this->botList; |
| 205 | 205 | foreach ( $newContent as $user => $groups ) { |
| 206 | 206 | if ( isset( $missing[ $user ] ) ) { |
@@ -225,15 +225,15 @@ discard block |
||
| 225 | 225 | * @param array[] $newContent |
| 226 | 226 | * @return array[] |
| 227 | 227 | */ |
| 228 | - protected function removeOverrides( array $newContent ) : array { |
|
| 229 | - $removed = []; |
|
| 228 | + protected function removeOverrides ( array $newContent ) : array { |
|
| 229 | + $removed = [ ]; |
|
| 230 | 230 | foreach ( $newContent as $user => $groups ) { |
| 231 | 231 | $ts = PageBotList::getValidTimestamp( $groups ); |
| 232 | 232 | if ( date( 'd/m', $ts ) === date( 'd/m', strtotime( '- 1 days' ) ) && |
| 233 | - isset( $newContent[ $user ]['override'] ) |
|
| 233 | + isset( $newContent[ $user ][ 'override' ] ) |
|
| 234 | 234 | ) { |
| 235 | 235 | unset( $newContent[ $user ][ 'override' ] ); |
| 236 | - $removed[] = $user; |
|
| 236 | + $removed[ ] = $user; |
|
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |