@@ -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 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $title |
| 30 | 30 | * @param WikiController $controller |
| 31 | 31 | */ |
| 32 | - public function __construct( string $title, WikiController $controller ) { |
|
| 32 | + public function __construct ( string $title, WikiController $controller ) { |
|
| 33 | 33 | $this->title = $title; |
| 34 | 34 | $this->controller = $controller; |
| 35 | 35 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * @return string |
| 39 | 39 | */ |
| 40 | - public function getTitle() : string { |
|
| 40 | + public function getTitle () : string { |
|
| 41 | 41 | return $this->title; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @return string |
| 48 | 48 | */ |
| 49 | - public function getUser() : string { |
|
| 50 | - return explode( '/', $this->title )[2]; |
|
| 49 | + public function getUser () : string { |
|
| 50 | + return explode( '/', $this->title )[ 2 ]; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @return int |
| 57 | 57 | */ |
| 58 | - public function getNum() : int { |
|
| 58 | + public function getNum () : int { |
|
| 59 | 59 | $bits = explode( '/', $this->getTitle() ); |
| 60 | 60 | return intval( end( $bits ) ); |
| 61 | 61 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function getUserNum() : string { |
|
| 69 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 68 | + public function getUserNum () : string { |
|
| 69 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | - public function getBaseTitle() : string { |
|
| 77 | + public function getBaseTitle () : string { |
|
| 78 | 78 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug |
| 79 | 79 | return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) ); |
| 80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * |
| 85 | 85 | * @return string |
| 86 | 86 | */ |
| 87 | - public function getContent() : string { |
|
| 87 | + public function getContent () : string { |
|
| 88 | 88 | if ( $this->content === null ) { |
| 89 | 89 | $this->content = $this->controller->getPageContent( $this->title ); |
| 90 | 90 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * |
| 97 | 97 | * @return int |
| 98 | 98 | */ |
| 99 | - public function getOpposingCount() : int { |
|
| 99 | + public function getOpposingCount () : int { |
|
| 100 | 100 | return $this->getCountForSection( self::SECTION_OPPOSE ); |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @return int |
| 107 | 107 | */ |
| 108 | - public function getSupportCount() : int { |
|
| 108 | + public function getSupportCount () : int { |
|
| 109 | 109 | return $this->getCountForSection( self::SECTION_SUPPORT ); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param int $secNum |
| 116 | 116 | * @return int |
| 117 | 117 | */ |
| 118 | - protected function getCountForSection( int $secNum ) : int { |
|
| 118 | + protected function getCountForSection ( int $secNum ) : int { |
|
| 119 | 119 | $content = $this->controller->getPageContent( $this->title, $secNum ); |
| 120 | 120 | // Let's hope that this is good enough... |
| 121 | 121 | return substr_count( $content, "\n\# *(?![#*])" ); |
@@ -126,11 +126,11 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return int |
| 128 | 128 | */ |
| 129 | - protected function getQuorum() : int { |
|
| 129 | + protected function getQuorum () : int { |
|
| 130 | 130 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 131 | - $matches = []; |
|
| 131 | + $matches = [ ]; |
|
| 132 | 132 | preg_match( $reg, $this->getContent(), $matches ); |
| 133 | - return intval( $matches[1] ); |
|
| 133 | + return intval( $matches[ 1 ] ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return bool |
| 140 | 140 | */ |
| 141 | - public function hasOpposition() : bool { |
|
| 141 | + public function hasOpposition () : bool { |
|
| 142 | 142 | return $this->getOpposingCount() >= 15; |
| 143 | 143 | } |
| 144 | 144 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @return int One of the OUTCOME_* constants |
| 149 | 149 | * @throws \BadMethodCallException |
| 150 | 150 | */ |
| 151 | - public function getOutcome() : int { |
|
| 151 | + public function getOutcome () : int { |
|
| 152 | 152 | if ( !$this->isVote() ) { |
| 153 | 153 | throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' ); |
| 154 | 154 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @return string |
| 168 | 168 | * @throws \BadMethodCallException |
| 169 | 169 | */ |
| 170 | - public function getOutcomeText() : string { |
|
| 170 | + public function getOutcomeText () : string { |
|
| 171 | 171 | if ( !$this->isVote() ) { |
| 172 | 172 | throw new \BadMethodCallException( 'No need for an outcome text.' ); |
| 173 | 173 | } |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @return bool |
| 201 | 201 | */ |
| 202 | - public function isVote() : bool { |
|
| 202 | + public function isVote () : bool { |
|
| 203 | 203 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 204 | 204 | return preg_match( $sectionReg, $this->getContent() ) === false; |
| 205 | 205 | } |
@@ -209,9 +209,9 @@ discard block |
||
| 209 | 209 | * |
| 210 | 210 | * @return int |
| 211 | 211 | */ |
| 212 | - public function getEndTimestamp() : int { |
|
| 212 | + public function getEndTimestamp () : int { |
|
| 213 | 213 | if ( $this->isVote() ) { |
| 214 | - $matches = []; |
|
| 214 | + $matches = [ ]; |
|
| 215 | 215 | $reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!"; |
| 216 | 216 | preg_match( $reg, $this->getContent(), $matches ); |
| 217 | 217 | list( , $day, $hours ) = $matches; |
@@ -228,19 +228,19 @@ discard block |
||
| 228 | 228 | * |
| 229 | 229 | * @param array $params |
| 230 | 230 | */ |
| 231 | - public function edit( array $params ) { |
|
| 231 | + public function edit ( array $params ) { |
|
| 232 | 232 | $params = [ |
| 233 | 233 | 'title' => $this->getTitle() |
| 234 | 234 | ] + $params; |
| 235 | 235 | |
| 236 | 236 | $this->controller->editPage( $params ); |
| 237 | - if ( isset( $params['text'] ) ) { |
|
| 238 | - $this->content = $params['text']; |
|
| 239 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 240 | - $this->content .= $params['appendtext']; |
|
| 237 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 238 | + $this->content = $params[ 'text' ]; |
|
| 239 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 240 | + $this->content .= $params[ 'appendtext' ]; |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | - public function __toString() { |
|
| 243 | + public function __toString () { |
|
| 244 | 244 | return $this->getTitle(); |
| 245 | 245 | } |
| 246 | 246 | } |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** @var string[] */ |
| 20 | 20 | private $tokens; |
| 21 | 21 | |
| 22 | - public function __construct() { |
|
| 22 | + public function __construct () { |
|
| 23 | 23 | $this->logger = new Logger; |
| 24 | 24 | } |
| 25 | 25 | |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @return string |
| 32 | 32 | * @throws MissingPageException |
| 33 | 33 | */ |
| 34 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 34 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 35 | 35 | $this->logger->debug( "Retrieving page $title" ); |
| 36 | 36 | $params = [ |
| 37 | 37 | 'action' => 'query', |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | ]; |
| 43 | 43 | |
| 44 | 44 | if ( $section !== null ) { |
| 45 | - $params['rvsection'] = $section; |
|
| 45 | + $params[ 'rvsection' ] = $section; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $req = RequestBase::newFromParams( $params ); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | throw new MissingPageException( $title ); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - return $page->revisions[0]->slots->main->{ '*' }; |
|
| 55 | + return $page->revisions[ 0 ]->slots->main->{ '*' }; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * @param array $params |
| 62 | 62 | * @throws EditException |
| 63 | 63 | */ |
| 64 | - public function editPage( array $params ) { |
|
| 64 | + public function editPage ( array $params ) { |
|
| 65 | 65 | $this->login(); |
| 66 | 66 | |
| 67 | 67 | $params = [ |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | * @fixme Not the right place for this |
| 85 | 85 | */ |
| 86 | - public static function getTimeWithArticle( int $timestamp ) : string { |
|
| 86 | + public static function getTimeWithArticle ( int $timestamp ) : string { |
|
| 87 | 87 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 88 | 88 | $timeString = strftime( '%e %B alle %R', $timestamp ); |
| 89 | 89 | // Remove the left space if day has a single digit |
@@ -102,16 +102,16 @@ discard block |
||
| 102 | 102 | * @fixme Not the right place for this |
| 103 | 103 | * @todo Is there a better way? |
| 104 | 104 | */ |
| 105 | - public static function getTimestampFromLocalTime( string $timeString ) : int { |
|
| 105 | + public static function getTimestampFromLocalTime ( string $timeString ) : int { |
|
| 106 | 106 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 107 | 107 | $bits = strptime( $timeString, '%e %m %Y alle %H:%M' ); |
| 108 | 108 | $timestamp = mktime( |
| 109 | - $bits['tm_hour'], |
|
| 110 | - $bits['tm_min'], |
|
| 109 | + $bits[ 'tm_hour' ], |
|
| 110 | + $bits[ 'tm_min' ], |
|
| 111 | 111 | 0, |
| 112 | - $bits['tm_mon'] + 1, |
|
| 113 | - $bits['tm_mday'], |
|
| 114 | - $bits['tm_year'] + 1900 |
|
| 112 | + $bits[ 'tm_mon' ] + 1, |
|
| 113 | + $bits[ 'tm_mday' ], |
|
| 114 | + $bits[ 'tm_year' ] + 1900 |
|
| 115 | 115 | ); |
| 116 | 116 | setlocale( LC_TIME, $oldLoc ); |
| 117 | 117 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 122 | 122 | * @throws LoginException |
| 123 | 123 | */ |
| 124 | - public function login() { |
|
| 124 | + public function login () { |
|
| 125 | 125 | if ( self::$loggedIn ) { |
| 126 | 126 | $this->logger->debug( 'Already logged in' ); |
| 127 | 127 | return; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | self::$loggedIn = true; |
| 150 | 150 | // Clear tokens cache |
| 151 | - $this->tokens = []; |
|
| 151 | + $this->tokens = [ ]; |
|
| 152 | 152 | $this->logger->info( 'Login succeeded' ); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @param string $type |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - public function getToken( string $type ) : string { |
|
| 161 | + public function getToken ( string $type ) : string { |
|
| 162 | 162 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 163 | 163 | $params = [ |
| 164 | 164 | 'action' => 'query', |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param string $title |
| 182 | 182 | * @return int |
| 183 | 183 | */ |
| 184 | - public function getPageCreationTS( string $title ) : int { |
|
| 184 | + public function getPageCreationTS ( string $title ) : int { |
|
| 185 | 185 | $params = [ |
| 186 | 186 | 'action' => 'query', |
| 187 | 187 | 'prop' => 'revisions', |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | $res = ( RequestBase::newFromParams( $params ) )->execute(); |
| 196 | 196 | $data = $res->query->pages; |
| 197 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 197 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | /** |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param string $title |
| 204 | 204 | * @param string $reason |
| 205 | 205 | */ |
| 206 | - public function protectPage( string $title, string $reason ) { |
|
| 206 | + public function protectPage ( string $title, string $reason ) { |
|
| 207 | 207 | $this->logger->info( "Protecting page $title" ); |
| 208 | 208 | $this->login(); |
| 209 | 209 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task; |
| 4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function run() : TaskResult { |
|
| 17 | + public function run () : TaskResult { |
|
| 18 | 18 | $this->getLogger()->info( 'Starting task ClosePages' ); |
| 19 | 19 | |
| 20 | 20 | $pages = $this->getPagesList(); |
@@ -51,12 +51,12 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return PageRiconferma[] |
| 53 | 53 | */ |
| 54 | - protected function getPagesList() : array { |
|
| 54 | + protected function getPagesList () : array { |
|
| 55 | 55 | $allPages = $this->getDataProvider()->getOpenPages(); |
| 56 | - $ret = []; |
|
| 56 | + $ret = [ ]; |
|
| 57 | 57 | foreach ( $allPages as $page ) { |
| 58 | 58 | if ( time() > $page->getEndTimestamp() ) { |
| 59 | - $ret[] = $page; |
|
| 59 | + $ret[ ] = $page; |
|
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | return $ret; |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | * @param PageRiconferma[] $pages |
| 69 | 69 | * @return PageRiconferma[] |
| 70 | 70 | */ |
| 71 | - private function getFailures( array $pages ) : array { |
|
| 72 | - $ret = []; |
|
| 71 | + private function getFailures ( array $pages ) : array { |
|
| 72 | + $ret = [ ]; |
|
| 73 | 73 | foreach ( $pages as $page ) { |
| 74 | 74 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 75 | - $ret[] = $page; |
|
| 75 | + $ret[ ] = $page; |
|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | return $ret; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | /** |
| 82 | 82 | * @param PageRiconferma $page |
| 83 | 83 | */ |
| 84 | - protected function addVoteCloseText( PageRiconferma $page ) { |
|
| 84 | + protected function addVoteCloseText ( PageRiconferma $page ) { |
|
| 85 | 85 | $content = $page->getContent(); |
| 86 | 86 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!'; |
| 87 | 87 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -99,14 +99,14 @@ discard block |
||
| 99 | 99 | * @param PageRiconferma[] $pages |
| 100 | 100 | * @see UpdatesAround::addToMainPage() |
| 101 | 101 | */ |
| 102 | - protected function removeFromMainPage( array $pages ) { |
|
| 102 | + protected function removeFromMainPage ( array $pages ) { |
|
| 103 | 103 | $this->getLogger()->info( |
| 104 | 104 | 'Removing from main: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 105 | 105 | ); |
| 106 | 106 | |
| 107 | 107 | $mainPage = $this->getConfig()->get( 'ric-main-page' ); |
| 108 | 108 | $content = $this->getController()->getPageContent( $mainPage ); |
| 109 | - $translations = []; |
|
| 109 | + $translations = [ ]; |
|
| 110 | 110 | foreach ( $pages as $page ) { |
| 111 | 111 | $translations[ '{{' . $page->getTitle() . '}}' ] = ''; |
| 112 | 112 | } |
@@ -124,17 +124,17 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param PageRiconferma[] $pages |
| 126 | 126 | */ |
| 127 | - protected function addToArchive( array $pages ) { |
|
| 127 | + protected function addToArchive ( array $pages ) { |
|
| 128 | 128 | $this->getLogger()->info( |
| 129 | 129 | 'Adding to archive: ' . implode( ', ', array_map( 'strval', $pages ) ) |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | - $simple = $votes = []; |
|
| 132 | + $simple = $votes = [ ]; |
|
| 133 | 133 | foreach ( $pages as $page ) { |
| 134 | 134 | if ( $page->isVote() ) { |
| 135 | - $votes[] = $page; |
|
| 135 | + $votes[ ] = $page; |
|
| 136 | 136 | } else { |
| 137 | - $simple[] = $page; |
|
| 137 | + $simple[ ] = $page; |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -151,21 +151,21 @@ discard block |
||
| 151 | 151 | * @param string $archiveTitle |
| 152 | 152 | * @param array $pages |
| 153 | 153 | */ |
| 154 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 154 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 155 | 155 | $curTitle = "$archiveTitle/" . date( 'Y' ); |
| 156 | 156 | |
| 157 | 157 | $append = ''; |
| 158 | - $archivedList = []; |
|
| 158 | + $archivedList = [ ]; |
|
| 159 | 159 | foreach ( $pages as $page ) { |
| 160 | 160 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 161 | - $archivedList[] = $page->getUserNum(); |
|
| 161 | + $archivedList[ ] = $page->getUserNum(); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | if ( count( $archivedList ) > 1 ) { |
| 165 | 165 | $last = array_pop( $archivedList ); |
| 166 | 166 | $userNums = implode( ', ', $archivedList ) . " e $last"; |
| 167 | 167 | } else { |
| 168 | - $userNums = $archivedList[0]; |
|
| 168 | + $userNums = $archivedList[ 0 ]; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | $summary = strtr( |
@@ -186,14 +186,13 @@ discard block |
||
| 186 | 186 | * @param PageRiconferma $page |
| 187 | 187 | * @see CreatePages::updateBasePage() |
| 188 | 188 | */ |
| 189 | - protected function updateBasePage( PageRiconferma $page ) { |
|
| 189 | + protected function updateBasePage ( PageRiconferma $page ) { |
|
| 190 | 190 | $this->getLogger()->info( "Updating base page for $page" ); |
| 191 | 191 | |
| 192 | 192 | $current = $this->getController()->getPageContent( $page->getBaseTitle() ); |
| 193 | 193 | |
| 194 | 194 | $outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ? |
| 195 | - 'non riconfermato' : |
|
| 196 | - 'riconfermato'; |
|
| 195 | + 'non riconfermato' : 'riconfermato'; |
|
| 197 | 196 | $text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita'; |
| 198 | 197 | |
| 199 | 198 | $newContent = str_replace( 'riconferma in corso', $text, $current ); |
@@ -210,13 +209,13 @@ discard block |
||
| 210 | 209 | * @param PageRiconferma[] $pages |
| 211 | 210 | * @see UpdatesAround::addVote() |
| 212 | 211 | */ |
| 213 | - protected function updateVote( array $pages ) { |
|
| 212 | + protected function updateVote ( array $pages ) { |
|
| 214 | 213 | $votePage = $this->getConfig()->get( 'ric-vote-page' ); |
| 215 | 214 | $content = $this->getController()->getPageContent( $votePage ); |
| 216 | 215 | |
| 217 | - $titles = []; |
|
| 216 | + $titles = [ ]; |
|
| 218 | 217 | foreach ( $pages as $page ) { |
| 219 | - $titles[] = preg_quote( $page->getTitle() ); |
|
| 218 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
| 220 | 219 | } |
| 221 | 220 | |
| 222 | 221 | $titleReg = implode( '|', array_map( 'preg_quote', $titles ) ); |
@@ -239,7 +238,7 @@ discard block |
||
| 239 | 238 | $summary = preg_replace_callback( |
| 240 | 239 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 241 | 240 | function ( $matches ) { |
| 242 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 241 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 243 | 242 | }, |
| 244 | 243 | $summary |
| 245 | 244 | ); |
@@ -257,7 +256,7 @@ discard block |
||
| 257 | 256 | * @param array $pages |
| 258 | 257 | * @see UpdatesAround::addNews() |
| 259 | 258 | */ |
| 260 | - protected function updateNews( array $pages ) { |
|
| 259 | + protected function updateNews ( array $pages ) { |
|
| 261 | 260 | $simpleAmount = $voteAmount = 0; |
| 262 | 261 | foreach ( $pages as $page ) { |
| 263 | 262 | if ( $page->isVote() ) { |
@@ -277,12 +276,12 @@ discard block |
||
| 277 | 276 | $simpleReg = '!(\| *riconferme[ _]tacite[ _]amministratori *= *)(\d+)!'; |
| 278 | 277 | $voteReg = '!(\| *riconferme[ _]voto[ _]amministratori *= *)(\d+)!'; |
| 279 | 278 | |
| 280 | - $simpleMatches = $voteMatches = []; |
|
| 279 | + $simpleMatches = $voteMatches = [ ]; |
|
| 281 | 280 | preg_match( $simpleReg, $content, $simpleMatches ); |
| 282 | 281 | preg_match( $voteReg, $content, $voteMatches ); |
| 283 | 282 | |
| 284 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 285 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 283 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 284 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 286 | 285 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content ); |
| 287 | 286 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 288 | 287 | |
@@ -293,7 +292,7 @@ discard block |
||
| 293 | 292 | $summary = preg_replace_callback( |
| 294 | 293 | '!\{\{$plur|(\d+)|([^|]+)|([^|]+)}}!', |
| 295 | 294 | function ( $matches ) { |
| 296 | - return intval( $matches[1] ) > 1 ? trim( $matches[3] ) : trim( $matches[2] ); |
|
| 295 | + return intval( $matches[ 1 ] ) > 1 ? trim( $matches[ 3 ] ) : trim( $matches[ 2 ] ); |
|
| 297 | 296 | }, |
| 298 | 297 | $summary |
| 299 | 298 | ); |
@@ -312,22 +311,22 @@ discard block |
||
| 312 | 311 | * |
| 313 | 312 | * @param PageRiconferma[] $pages |
| 314 | 313 | */ |
| 315 | - protected function updateAdminList( array $pages ) { |
|
| 314 | + protected function updateAdminList ( array $pages ) { |
|
| 316 | 315 | $listTitle = $this->getConfig()->get( 'admins-list' ); |
| 317 | 316 | $newContent = $this->getController()->getPageContent( $listTitle ); |
| 318 | 317 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 319 | 318 | |
| 320 | - $riconfNames = $removeNames = []; |
|
| 319 | + $riconfNames = $removeNames = [ ]; |
|
| 321 | 320 | foreach ( $pages as $page ) { |
| 322 | 321 | $user = $page->getUser(); |
| 323 | 322 | $reg = "!(\{\{Amministratore\/riga\|$user.+\| *)\d+( *\|(?: *pausa)? *\}\}\n)!"; |
| 324 | 323 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 325 | 324 | // Remove the line |
| 326 | 325 | $newContent = preg_replace( $reg, '', $newContent ); |
| 327 | - $removeNames[] = $user; |
|
| 326 | + $removeNames[ ] = $user; |
|
| 328 | 327 | } else { |
| 329 | 328 | $newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent ); |
| 330 | - $riconfNames[] = $user; |
|
| 329 | + $riconfNames[ ] = $user; |
|
| 331 | 330 | } |
| 332 | 331 | } |
| 333 | 332 | |
@@ -335,7 +334,7 @@ discard block |
||
| 335 | 334 | $lastUser = array_pop( $riconfNames ); |
| 336 | 335 | $riconfList = implode( ', ', $riconfNames ) . " e $lastUser"; |
| 337 | 336 | } elseif ( $riconfNames ) { |
| 338 | - $riconfList = $riconfNames[0]; |
|
| 337 | + $riconfList = $riconfNames[ 0 ]; |
|
| 339 | 338 | } else { |
| 340 | 339 | $riconfList = 'nessuno'; |
| 341 | 340 | } |
@@ -344,7 +343,7 @@ discard block |
||
| 344 | 343 | $lastUser = array_pop( $removeNames ); |
| 345 | 344 | $removeList = implode( ', ', $removeNames ) . " e $lastUser"; |
| 346 | 345 | } elseif ( $removeNames ) { |
| 347 | - $removeList = $removeNames[0]; |
|
| 346 | + $removeList = $removeNames[ 0 ]; |
|
| 348 | 347 | } else { |
| 349 | 348 | $removeList = 'nessuno'; |
| 350 | 349 | } |
@@ -369,13 +368,13 @@ discard block |
||
| 369 | 368 | /** |
| 370 | 369 | * @param PageRiconferma[] $pages |
| 371 | 370 | */ |
| 372 | - protected function updateCUList( array $pages ) { |
|
| 371 | + protected function updateCUList ( array $pages ) { |
|
| 373 | 372 | $cuListTitle = $this->getConfig()->get( 'cu-list-title' ); |
| 374 | 373 | $listTitle = $this->getConfig()->get( 'list-title' ); |
| 375 | 374 | $admins = json_decode( $this->getController()->getPageContent( $listTitle ), true ); |
| 376 | 375 | $newContent = $this->getController()->getPageContent( $cuListTitle ); |
| 377 | 376 | |
| 378 | - $riconfNames = $removeNames = []; |
|
| 377 | + $riconfNames = $removeNames = [ ]; |
|
| 379 | 378 | foreach ( $pages as $page ) { |
| 380 | 379 | $user = $page->getUser(); |
| 381 | 380 | if ( array_key_exists( 'checkuser', $admins[ $user ] ) ) { |
@@ -383,10 +382,10 @@ discard block |
||
| 383 | 382 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 384 | 383 | // Remove the line |
| 385 | 384 | $newContent = preg_replace( $reg, '', $newContent ); |
| 386 | - $removeNames[] = $user; |
|
| 385 | + $removeNames[ ] = $user; |
|
| 387 | 386 | } else { |
| 388 | 387 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 389 | - $riconfNames[] = $user; |
|
| 388 | + $riconfNames[ ] = $user; |
|
| 390 | 389 | } |
| 391 | 390 | } |
| 392 | 391 | } |
@@ -399,7 +398,7 @@ discard block |
||
| 399 | 398 | $lastUser = array_pop( $riconfNames ); |
| 400 | 399 | $riconfList = implode( ', ', $riconfNames ) . " e $lastUser"; |
| 401 | 400 | } elseif ( $riconfNames ) { |
| 402 | - $riconfList = $riconfNames[0]; |
|
| 401 | + $riconfList = $riconfNames[ 0 ]; |
|
| 403 | 402 | } else { |
| 404 | 403 | $riconfList = 'nessuno'; |
| 405 | 404 | } |
@@ -408,7 +407,7 @@ discard block |
||
| 408 | 407 | $lastUser = array_pop( $removeNames ); |
| 409 | 408 | $removeList = implode( ', ', $removeNames ) . " e $lastUser"; |
| 410 | 409 | } elseif ( $removeNames ) { |
| 411 | - $removeList = $removeNames[0]; |
|
| 410 | + $removeList = $removeNames[ 0 ]; |
|
| 412 | 411 | } else { |
| 413 | 412 | $removeList = 'nessuno'; |
| 414 | 413 | } |
@@ -432,17 +431,17 @@ discard block |
||
| 432 | 431 | /** |
| 433 | 432 | * @param PageRiconferma[] $pages |
| 434 | 433 | */ |
| 435 | - protected function updateBurList( array $pages ) { |
|
| 434 | + protected function updateBurList ( array $pages ) { |
|
| 436 | 435 | $listTitle = $this->getConfig()->get( 'list-title' ); |
| 437 | 436 | $admins = json_decode( $this->getController()->getPageContent( $listTitle ), true ); |
| 438 | 437 | |
| 439 | - $remove = []; |
|
| 438 | + $remove = [ ]; |
|
| 440 | 439 | foreach ( $pages as $page ) { |
| 441 | 440 | $user = $page->getUser(); |
| 442 | 441 | if ( array_key_exists( 'bureaucrat', $admins[ $user ] ) && |
| 443 | 442 | $page->getOutcome() & PageRiconferma::OUTCOME_FAIL |
| 444 | 443 | ) { |
| 445 | - $remove[] = $user; |
|
| 444 | + $remove[ ] = $user; |
|
| 446 | 445 | } |
| 447 | 446 | } |
| 448 | 447 | |
@@ -460,7 +459,7 @@ discard block |
||
| 460 | 459 | $lastUser = array_pop( $remove ); |
| 461 | 460 | $removeList = implode( ', ', $remove ) . " e $lastUser"; |
| 462 | 461 | } else { |
| 463 | - $removeList = $remove[0]; |
|
| 462 | + $removeList = $remove[ 0 ]; |
|
| 464 | 463 | } |
| 465 | 464 | |
| 466 | 465 | $summary = strtr( |
@@ -483,7 +482,7 @@ discard block |
||
| 483 | 482 | * |
| 484 | 483 | * @param PageRiconferma[] $pages |
| 485 | 484 | */ |
| 486 | - protected function requestRemoval( array $pages ) { |
|
| 485 | + protected function requestRemoval ( array $pages ) { |
|
| 487 | 486 | $listTitle = $this->getConfig()->get( 'list-title' ); |
| 488 | 487 | $admins = json_decode( $this->getController()->getPageContent( $listTitle ), true ); |
| 489 | 488 | |
@@ -528,14 +527,14 @@ discard block |
||
| 528 | 527 | * |
| 529 | 528 | * @param PageRiconferma[] $pages |
| 530 | 529 | */ |
| 531 | - protected function updateAnnunci( array $pages ) { |
|
| 530 | + protected function updateAnnunci ( array $pages ) { |
|
| 532 | 531 | $title = $this->getConfig()->get( 'annunci-title' ); |
| 533 | 532 | |
| 534 | - $names = []; |
|
| 533 | + $names = [ ]; |
|
| 535 | 534 | $text = ''; |
| 536 | 535 | foreach ( $pages as $page ) { |
| 537 | 536 | $user = $page->getUser(); |
| 538 | - $names[] = $user; |
|
| 537 | + $names[ ] = $user; |
|
| 539 | 538 | $text .= "{{Breve|admin|{{subst:#time:j}}|[[Utente:$user|]] non è stato riconfermato [[WP:A|amministratore]].}}\n"; |
| 540 | 539 | } |
| 541 | 540 | |
@@ -556,7 +555,7 @@ discard block |
||
| 556 | 555 | $lastUser = array_pop( $names ); |
| 557 | 556 | $namesList = implode( ', ', $names ) . " e $lastUser"; |
| 558 | 557 | } else { |
| 559 | - $namesList = $names[0]; |
|
| 558 | + $namesList = $names[ 0 ]; |
|
| 560 | 559 | } |
| 561 | 560 | |
| 562 | 561 | $summary = strtr( |
@@ -577,15 +576,15 @@ discard block |
||
| 577 | 576 | * |
| 578 | 577 | * @param PageRiconferma[] $pages |
| 579 | 578 | */ |
| 580 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 579 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 581 | 580 | $title = $this->getConfig()->get( 'ultimenotizie-title' ); |
| 582 | 581 | |
| 583 | - $names = []; |
|
| 582 | + $names = [ ]; |
|
| 584 | 583 | $text = ''; |
| 585 | 584 | foreach ( $pages as $page ) { |
| 586 | 585 | $user = $page->getUser(); |
| 587 | 586 | $title = $page->getTitle(); |
| 588 | - $names[] = $user; |
|
| 587 | + $names[ ] = $user; |
|
| 589 | 588 | $text .= "'''{{subst:#time:j F}}''': [[Utente:$user|]] non è stato [[$title|riconfermato]] [[WP:A|amministratore]]; ora gli admin sono {{subst:#expr: {{NUMBEROFADMINS}} - 1}}."; |
| 590 | 589 | } |
| 591 | 590 | |
@@ -603,7 +602,7 @@ discard block |
||
| 603 | 602 | $lastUser = array_pop( $names ); |
| 604 | 603 | $namesList = implode( ', ', $names ) . " e $lastUser"; |
| 605 | 604 | } else { |
| 606 | - $namesList = $names[0]; |
|
| 605 | + $namesList = $names[ 0 ]; |
|
| 607 | 606 | } |
| 608 | 607 | |
| 609 | 608 | $summary = strtr( |