@@ -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\Page; |
| 4 | 4 | |
@@ -23,8 +23,8 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | - public function getUser() : string { |
|
| 27 | - return explode( '/', $this->title )[2]; |
|
| 26 | + public function getUser () : string { |
|
| 27 | + return explode( '/', $this->title )[ 2 ]; |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return int |
| 34 | 34 | */ |
| 35 | - public function getNum() : int { |
|
| 35 | + public function getNum () : int { |
|
| 36 | 36 | $bits = explode( '/', $this->getTitle() ); |
| 37 | 37 | return intval( end( $bits ) ); |
| 38 | 38 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return string |
| 44 | 44 | */ |
| 45 | - public function getUserNum() : string { |
|
| 46 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 45 | + public function getUserNum () : string { |
|
| 46 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | - public function getBaseTitle() : string { |
|
| 54 | + public function getBaseTitle () : string { |
|
| 55 | 55 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug |
| 56 | 56 | return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) ); |
| 57 | 57 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return int |
| 63 | 63 | */ |
| 64 | - public function getOpposingCount() : int { |
|
| 64 | + public function getOpposingCount () : int { |
|
| 65 | 65 | return $this->getCountForSection( self::SECTION_OPPOSE ); |
| 66 | 66 | } |
| 67 | 67 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @return int |
| 72 | 72 | */ |
| 73 | - public function getSupportCount() : int { |
|
| 73 | + public function getSupportCount () : int { |
|
| 74 | 74 | return $this->getCountForSection( self::SECTION_SUPPORT ); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param int $secNum |
| 81 | 81 | * @return int |
| 82 | 82 | */ |
| 83 | - protected function getCountForSection( int $secNum ) : int { |
|
| 83 | + protected function getCountForSection ( int $secNum ) : int { |
|
| 84 | 84 | $content = $this->controller->getPageContent( $this->title, $secNum ); |
| 85 | 85 | // Let's hope that this is good enough... |
| 86 | 86 | return substr_count( $content, "\n\# *(?![#*])" ); |
@@ -91,9 +91,9 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return int |
| 93 | 93 | */ |
| 94 | - protected function getQuorum() : int { |
|
| 94 | + protected function getQuorum () : int { |
|
| 95 | 95 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 96 | - return intval( $this->getMatch( $reg )[1] ); |
|
| 96 | + return intval( $this->getMatch( $reg )[ 1 ] ); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return bool |
| 103 | 103 | */ |
| 104 | - public function hasOpposition() : bool { |
|
| 104 | + public function hasOpposition () : bool { |
|
| 105 | 105 | return $this->getOpposingCount() >= 15; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return int One of the OUTCOME_* constants |
| 112 | 112 | * @throws \BadMethodCallException |
| 113 | 113 | */ |
| 114 | - public function getOutcome() : int { |
|
| 114 | + public function getOutcome () : int { |
|
| 115 | 115 | if ( !$this->isVote() ) { |
| 116 | 116 | throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' ); |
| 117 | 117 | } |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @throws \BadMethodCallException |
| 132 | 132 | * @throws \LogicException |
| 133 | 133 | */ |
| 134 | - public function getOutcomeText() : string { |
|
| 134 | + public function getOutcomeText () : string { |
|
| 135 | 135 | if ( !$this->isVote() ) { |
| 136 | 136 | throw new \BadMethodCallException( 'No need for an outcome text.' ); |
| 137 | 137 | } |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * |
| 166 | 166 | * @return bool |
| 167 | 167 | */ |
| 168 | - public function isVote() : bool { |
|
| 168 | + public function isVote () : bool { |
|
| 169 | 169 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 170 | 170 | return $this->matches( $sectionReg ); |
| 171 | 171 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * |
| 176 | 176 | * @return int |
| 177 | 177 | */ |
| 178 | - public function getEndTimestamp() : int { |
|
| 178 | + public function getEndTimestamp () : int { |
|
| 179 | 179 | if ( $this->isVote() ) { |
| 180 | 180 | $reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!"; |
| 181 | 181 | list( , $day, $hours ) = $this->getMatch( $reg ); |
@@ -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 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @param string $domain The URL of the wiki, if different from default |
| 26 | 26 | */ |
| 27 | - public function __construct( string $domain = DEFAULT_URL ) { |
|
| 27 | + public function __construct ( string $domain = DEFAULT_URL ) { |
|
| 28 | 28 | $this->logger = new Logger; |
| 29 | 29 | $this->domain = $domain; |
| 30 | 30 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @return string |
| 38 | 38 | * @throws MissingPageException |
| 39 | 39 | */ |
| 40 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 40 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 41 | 41 | $this->logger->debug( "Retrieving page $title" ); |
| 42 | 42 | $params = [ |
| 43 | 43 | 'action' => 'query', |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | ]; |
| 49 | 49 | |
| 50 | 50 | if ( $section !== null ) { |
| 51 | - $params['rvsection'] = $section; |
|
| 51 | + $params[ 'rvsection' ] = $section; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | throw new MissingPageException( $title ); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - return $page->revisions[0]->slots->main->{ '*' }; |
|
| 61 | + return $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | * @param array $params |
| 68 | 68 | * @throws EditException |
| 69 | 69 | */ |
| 70 | - public function editPage( array $params ) { |
|
| 70 | + public function editPage ( array $params ) { |
|
| 71 | 71 | $this->login(); |
| 72 | 72 | |
| 73 | 73 | $params = [ |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 90 | 90 | * @throws LoginException |
| 91 | 91 | */ |
| 92 | - public function login() { |
|
| 92 | + public function login () { |
|
| 93 | 93 | if ( self::$loggedIn ) { |
| 94 | 94 | $this->logger->debug( 'Already logged in' ); |
| 95 | 95 | return; |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | self::$loggedIn = true; |
| 118 | 118 | // Clear tokens cache |
| 119 | - $this->tokens = []; |
|
| 119 | + $this->tokens = [ ]; |
|
| 120 | 120 | $this->logger->info( 'Login succeeded' ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * @param string $type |
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | - public function getToken( string $type ) : string { |
|
| 129 | + public function getToken ( string $type ) : string { |
|
| 130 | 130 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 131 | 131 | $params = [ |
| 132 | 132 | 'action' => 'query', |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @param string $title |
| 150 | 150 | * @return int |
| 151 | 151 | */ |
| 152 | - public function getPageCreationTS( string $title ) : int { |
|
| 152 | + public function getPageCreationTS ( string $title ) : int { |
|
| 153 | 153 | $params = [ |
| 154 | 154 | 'action' => 'query', |
| 155 | 155 | 'prop' => 'revisions', |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
| 164 | 164 | $data = $res->query->pages; |
| 165 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 165 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param string $title |
| 172 | 172 | * @param string $reason |
| 173 | 173 | */ |
| 174 | - public function protectPage( string $title, string $reason ) { |
|
| 174 | + public function protectPage ( string $title, string $reason ) { |
|
| 175 | 175 | $this->logger->info( "Protecting page $title" ); |
| 176 | 176 | $this->login(); |
| 177 | 177 | |
@@ -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, |