@@ -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 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - protected function getActualAdmins() : array { |
|
| 56 | + protected function getActualAdmins () : array { |
|
| 57 | 57 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 58 | 58 | $params = [ |
| 59 | 59 | 'action' => 'query', |
@@ -71,8 +71,8 @@ discard block |
||
| 71 | 71 | * @param \stdClass $data |
| 72 | 72 | * @return array |
| 73 | 73 | */ |
| 74 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 75 | - $ret = []; |
|
| 74 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 75 | + $ret = [ ]; |
|
| 76 | 76 | $blacklist = $this->getOpt( 'exclude-admins' ); |
| 77 | 77 | foreach ( $data->query->allusers as $u ) { |
| 78 | 78 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -89,16 +89,16 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return array[] |
| 91 | 91 | */ |
| 92 | - protected function getMissingGroups() : array { |
|
| 93 | - $missing = []; |
|
| 92 | + protected function getMissingGroups () : array { |
|
| 93 | + $missing = [ ]; |
|
| 94 | 94 | foreach ( $this->actualList as $adm => $groups ) { |
| 95 | - $curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) ); |
|
| 95 | + $curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) ); |
|
| 96 | 96 | |
| 97 | 97 | foreach ( $curMissing as $group ) { |
| 98 | 98 | try { |
| 99 | 99 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 100 | 100 | } catch ( TaskException $e ) { |
| 101 | - $this->errors[] = $e->getMessage(); |
|
| 101 | + $this->errors[ ] = $e->getMessage(); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return string |
| 114 | 114 | * @throws TaskException |
| 115 | 115 | */ |
| 116 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 116 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 117 | 117 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 118 | 118 | |
| 119 | 119 | $url = DEFAULT_URL; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param string $group |
| 149 | 149 | * @return string|null |
| 150 | 150 | */ |
| 151 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 151 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 152 | 152 | $ts = null; |
| 153 | 153 | foreach ( $data->query->logevents as $entry ) { |
| 154 | 154 | if ( isset( $entry->params ) ) { |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return array[] |
| 169 | 169 | */ |
| 170 | - protected function getExtraGroups() : array { |
|
| 171 | - $extra = []; |
|
| 170 | + protected function getExtraGroups () : array { |
|
| 171 | + $extra = [ ]; |
|
| 172 | 172 | foreach ( $this->botList as $name => $groups ) { |
| 173 | 173 | // These are not groups |
| 174 | 174 | unset( $groups[ 'override' ], $groups[ 'override-perm' ] ); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @param array[] $extra |
| 189 | 189 | * @return array[] |
| 190 | 190 | */ |
| 191 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 191 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 192 | 192 | $newContent = $this->botList; |
| 193 | 193 | foreach ( $newContent as $user => $groups ) { |
| 194 | 194 | if ( isset( $missing[ $user ] ) ) { |
@@ -213,15 +213,15 @@ discard block |
||
| 213 | 213 | * @param array[] $newContent |
| 214 | 214 | * @return array[] |
| 215 | 215 | */ |
| 216 | - protected function removeOverrides( array $newContent ) : array { |
|
| 217 | - $removed = []; |
|
| 216 | + protected function removeOverrides ( array $newContent ) : array { |
|
| 217 | + $removed = [ ]; |
|
| 218 | 218 | foreach ( $newContent as $user => $groups ) { |
| 219 | 219 | $ts = PageBotList::getValidFlagTimestamp( $groups ); |
| 220 | - if ( isset( $groups['override'] ) && ( date( 'd/m', $ts ) === |
|
| 220 | + if ( isset( $groups[ 'override' ] ) && ( date( 'd/m', $ts ) === |
|
| 221 | 221 | date( 'd/m', strtotime( '- 1 days' ) ) ) |
| 222 | 222 | ) { |
| 223 | 223 | unset( $newContent[ $user ][ 'override' ] ); |
| 224 | - $removed[] = $user; |
|
| 224 | + $removed[ ] = $user; |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task\Subtask; |
| 4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @inheritDoc |
| 16 | 16 | */ |
| 17 | - public function runInternal() : int { |
|
| 17 | + public function runInternal () : int { |
|
| 18 | 18 | $users = $this->getDataProvider()->getUsersToProcess(); |
| 19 | 19 | |
| 20 | 20 | if ( !$users ) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param string $user |
| 35 | 35 | * @param array $groups |
| 36 | 36 | */ |
| 37 | - protected function processUser( string $user, array $groups ) { |
|
| 37 | + protected function processUser ( string $user, array $groups ) { |
|
| 38 | 38 | try { |
| 39 | 39 | $num = $this->getLastPageNum( $user ) + 1; |
| 40 | 40 | } catch ( TaskException $e ) { |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | * @return int |
| 67 | 67 | * @throws TaskException |
| 68 | 68 | */ |
| 69 | - protected function getLastPageNum( string $user ) : int { |
|
| 69 | + protected function getLastPageNum ( string $user ) : int { |
|
| 70 | 70 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
| 71 | - $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1]; |
|
| 71 | + $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ]; |
|
| 72 | 72 | $params = [ |
| 73 | 73 | 'action' => 'query', |
| 74 | 74 | 'list' => 'allpages', |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | * @param string $user |
| 104 | 104 | * @param array $groups |
| 105 | 105 | */ |
| 106 | - protected function createPage( string $title, string $user, array $groups ) { |
|
| 106 | + protected function createPage ( string $title, string $user, array $groups ) { |
|
| 107 | 107 | $this->getLogger()->info( "Creating page $title" ); |
| 108 | 108 | $textParams = [ |
| 109 | 109 | '$user' => $user, |
| 110 | - '$date' => $groups['sysop'], |
|
| 111 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
| 112 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
| 110 | + '$date' => $groups[ 'sysop' ], |
|
| 111 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
| 112 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
| 113 | 113 | ]; |
| 114 | 114 | |
| 115 | 115 | $params = [ |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param string $title |
| 128 | 128 | * @param string $newText |
| 129 | 129 | */ |
| 130 | - protected function createBasePage( string $title, string $newText ) { |
|
| 130 | + protected function createBasePage ( string $title, string $newText ) { |
|
| 131 | 131 | $this->getLogger()->info( "Creating base page $title" ); |
| 132 | 132 | |
| 133 | 133 | $params = [ |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $title |
| 145 | 145 | * @param string $newText |
| 146 | 146 | */ |
| 147 | - protected function updateBasePage( string $title, string $newText ) { |
|
| 147 | + protected function updateBasePage ( string $title, string $newText ) { |
|
| 148 | 148 | $this->getLogger()->info( "Updating base page $title" ); |
| 149 | 149 | |
| 150 | 150 | $params = [ |
@@ -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 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @inheritDoc |
| 18 | 18 | */ |
| 19 | - public function runInternal() : int { |
|
| 19 | + public function runInternal () : int { |
|
| 20 | 20 | $failed = $this->getFailures(); |
| 21 | 21 | if ( $failed ) { |
| 22 | 22 | $bureaucrats = $this->getFailedBureaucrats( $failed ); |
@@ -36,12 +36,12 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return PageRiconferma[] |
| 38 | 38 | */ |
| 39 | - private function getFailures() : array { |
|
| 40 | - $ret = []; |
|
| 39 | + private function getFailures () : array { |
|
| 40 | + $ret = [ ]; |
|
| 41 | 41 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 42 | 42 | foreach ( $allPages as $page ) { |
| 43 | 43 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 44 | - $ret[] = $page; |
|
| 44 | + $ret[ ] = $page; |
|
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | return $ret; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | /** |
| 51 | 51 | * @param User[] $users |
| 52 | 52 | */ |
| 53 | - protected function updateBurList( array $users ) { |
|
| 53 | + protected function updateBurList ( array $users ) { |
|
| 54 | 54 | $this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) ); |
| 55 | 55 | $remList = Element::regexFromArray( $users ); |
| 56 | 56 | $burList = new Page( $this->getOpt( 'bur-list-title' ) ); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @param PageRiconferma[] $pages |
| 75 | 75 | */ |
| 76 | - protected function requestRemoval( array $pages ) { |
|
| 76 | + protected function requestRemoval ( array $pages ) { |
|
| 77 | 77 | $this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) ); |
| 78 | 78 | |
| 79 | 79 | $flagRemPage = new Page( |
@@ -109,15 +109,15 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @param PageRiconferma[] $pages |
| 111 | 111 | */ |
| 112 | - protected function updateAnnunci( array $pages ) { |
|
| 112 | + protected function updateAnnunci ( array $pages ) { |
|
| 113 | 113 | $this->getLogger()->info( 'Updating annunci' ); |
| 114 | 114 | $section = 1; |
| 115 | 115 | |
| 116 | - $names = []; |
|
| 116 | + $names = [ ]; |
|
| 117 | 117 | $text = ''; |
| 118 | 118 | foreach ( $pages as $page ) { |
| 119 | 119 | $user = $page->getUser()->getName(); |
| 120 | - $names[] = $user; |
|
| 120 | + $names[ ] = $user; |
|
| 121 | 121 | $text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text(); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | * |
| 150 | 150 | * @param PageRiconferma[] $pages |
| 151 | 151 | */ |
| 152 | - protected function updateUltimeNotizie( array $pages ) { |
|
| 152 | + protected function updateUltimeNotizie ( array $pages ) { |
|
| 153 | 153 | $this->getLogger()->info( 'Updating ultime notizie' ); |
| 154 | 154 | $notiziePage = new Page( $this->getOpt( 'ultimenotizie-page-title' ) ); |
| 155 | 155 | |
| 156 | - $names = []; |
|
| 156 | + $names = [ ]; |
|
| 157 | 157 | $text = ''; |
| 158 | 158 | $msg = $this->msg( 'ultimenotizie-text' ); |
| 159 | 159 | foreach ( $pages as $page ) { |
| 160 | 160 | $user = $page->getUser()->getName(); |
| 161 | - $names[] = $user; |
|
| 161 | + $names[ ] = $user; |
|
| 162 | 162 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | * @param PageRiconferma[] $pages |
| 188 | 188 | * @return User[] |
| 189 | 189 | */ |
| 190 | - private function getFailedBureaucrats( array $pages ) : array { |
|
| 191 | - $ret = []; |
|
| 190 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
| 191 | + $ret = [ ]; |
|
| 192 | 192 | foreach ( $pages as $page ) { |
| 193 | 193 | $user = $page->getUser(); |
| 194 | 194 | if ( $user->inGroup( 'bureaucrat' ) ) { |
| 195 | - $ret[] = $user; |
|
| 195 | + $ret[ ] = $user; |
|
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | 198 | return $ret; |
@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | private $supportSection; |
| 14 | 14 | private $opposeSection; |
| 15 | 15 | /** @var array Counts of votes for each section */ |
| 16 | - private $sectionCounts = []; |
|
| 16 | + private $sectionCounts = [ ]; |
|
| 17 | 17 | |
| 18 | 18 | // Possible outcomes of a vote |
| 19 | 19 | const OUTCOME_OK = 0; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * because they can vary depending on whether the page is a vote, which is relatively |
| 33 | 33 | * expensive to know since it requires parsing the content of the page. |
| 34 | 34 | */ |
| 35 | - private function defineSections() { |
|
| 35 | + private function defineSections () { |
|
| 36 | 36 | $this->supportSection = $this->isVote() ? 3 : 0; |
| 37 | 37 | $this->opposeSection = $this->isVote() ? 4 : 3; |
| 38 | 38 | } |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return User |
| 44 | 44 | */ |
| 45 | - public function getUser() : User { |
|
| 46 | - $name = explode( '/', $this->title )[2]; |
|
| 45 | + public function getUser () : User { |
|
| 46 | + $name = explode( '/', $this->title )[ 2 ]; |
|
| 47 | 47 | return new User( $name ); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return int |
| 54 | 54 | */ |
| 55 | - public function getNum() : int { |
|
| 55 | + public function getNum () : int { |
|
| 56 | 56 | $bits = explode( '/', $this->getTitle() ); |
| 57 | 57 | return intval( end( $bits ) ); |
| 58 | 58 | } |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return string |
| 64 | 64 | */ |
| 65 | - public function getUserNum() : string { |
|
| 66 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 65 | + public function getUserNum () : string { |
|
| 66 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @return string |
| 73 | 73 | */ |
| 74 | - public function getBaseTitle() : string { |
|
| 74 | + public function getBaseTitle () : string { |
|
| 75 | 75 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug |
| 76 | 76 | return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) ); |
| 77 | 77 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * |
| 82 | 82 | * @return int |
| 83 | 83 | */ |
| 84 | - public function getOpposingCount() : int { |
|
| 84 | + public function getOpposingCount () : int { |
|
| 85 | 85 | $this->defineSections(); |
| 86 | 86 | return $this->getCountForSection( $this->opposeSection ); |
| 87 | 87 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @return int |
| 93 | 93 | * @throws \BadMethodCallException |
| 94 | 94 | */ |
| 95 | - public function getSupportCount() : int { |
|
| 95 | + public function getSupportCount () : int { |
|
| 96 | 96 | if ( !$this->isVote() ) { |
| 97 | 97 | throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' ); |
| 98 | 98 | } |
@@ -106,13 +106,13 @@ discard block |
||
| 106 | 106 | * @param int $secNum |
| 107 | 107 | * @return int |
| 108 | 108 | */ |
| 109 | - protected function getCountForSection( int $secNum ) : int { |
|
| 109 | + protected function getCountForSection ( int $secNum ) : int { |
|
| 110 | 110 | if ( !isset( $this->sectionCounts[ $secNum ] ) ) { |
| 111 | 111 | $content = $this->controller->getPageContent( $this->title, $secNum ); |
| 112 | 112 | // Let's hope that this is good enough... |
| 113 | - $this->sectionCounts[$secNum] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content ); |
|
| 113 | + $this->sectionCounts[ $secNum ] = preg_match_all( "/^\# *(?![# *:]|\.\.\.$)/m", $content ); |
|
| 114 | 114 | } |
| 115 | - return $this->sectionCounts[$secNum]; |
|
| 115 | + return $this->sectionCounts[ $secNum ]; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | * |
| 121 | 121 | * @return int |
| 122 | 122 | */ |
| 123 | - protected function getQuorum() : int { |
|
| 123 | + protected function getQuorum () : int { |
|
| 124 | 124 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 125 | - return intval( $this->getMatch( $reg )[1] ); |
|
| 125 | + return intval( $this->getMatch( $reg )[ 1 ] ); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return bool |
| 132 | 132 | */ |
| 133 | - public function hasOpposition() : bool { |
|
| 133 | + public function hasOpposition () : bool { |
|
| 134 | 134 | return $this->getOpposingCount() >= self::REQUIRED_OPPOSE; |
| 135 | 135 | } |
| 136 | 136 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return int One of the OUTCOME_* constants |
| 141 | 141 | */ |
| 142 | - public function getOutcome() : int { |
|
| 142 | + public function getOutcome () : int { |
|
| 143 | 143 | if ( !$this->isVote() ) { |
| 144 | 144 | return self::OUTCOME_OK; |
| 145 | 145 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @throws \BadMethodCallException |
| 163 | 163 | * @throws \LogicException |
| 164 | 164 | */ |
| 165 | - public function getOutcomeText() : string { |
|
| 165 | + public function getOutcomeText () : string { |
|
| 166 | 166 | if ( !$this->isVote() ) { |
| 167 | 167 | throw new \BadMethodCallException( 'No need for an outcome text.' ); |
| 168 | 168 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * |
| 197 | 197 | * @return bool |
| 198 | 198 | */ |
| 199 | - public function isVote() : bool { |
|
| 199 | + public function isVote () : bool { |
|
| 200 | 200 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 201 | 201 | return !$this->matches( $sectionReg ); |
| 202 | 202 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return int |
| 208 | 208 | */ |
| 209 | - public function getCreationTimestamp() : int { |
|
| 209 | + public function getCreationTimestamp () : int { |
|
| 210 | 210 | return $this->controller->getPageCreationTS( $this->title ); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * |
| 216 | 216 | * @return int |
| 217 | 217 | */ |
| 218 | - public function getEndTimestamp() : int { |
|
| 218 | + public function getEndTimestamp () : int { |
|
| 219 | 219 | if ( $this->isVote() ) { |
| 220 | 220 | $reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!"; |
| 221 | 221 | list( , $hours, $day ) = $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\Wiki\Page; |
| 4 | 4 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | * @param string $title |
| 23 | 23 | * @param string $domain The site where the page lives, if different from default |
| 24 | 24 | */ |
| 25 | - public function __construct( string $title, string $domain = DEFAULT_URL ) { |
|
| 25 | + public function __construct ( string $title, string $domain = DEFAULT_URL ) { |
|
| 26 | 26 | $this->title = $title; |
| 27 | 27 | $this->controller = new Controller( $domain ); |
| 28 | 28 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | /** |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getTitle() : string { |
|
| 33 | + public function getTitle () : string { |
|
| 34 | 34 | return $this->title; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param int|null $section A section number to retrieve the content of that section |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | - public function getContent( int $section = null ) : string { |
|
| 43 | + public function getContent ( int $section = null ) : string { |
|
| 44 | 44 | if ( $this->content === null ) { |
| 45 | 45 | $this->content = $this->controller->getPageContent( $this->title, $section ); |
| 46 | 46 | } |
@@ -53,18 +53,18 @@ discard block |
||
| 53 | 53 | * @param array $params |
| 54 | 54 | * @throws \LogicException |
| 55 | 55 | */ |
| 56 | - public function edit( array $params ) { |
|
| 56 | + public function edit ( array $params ) { |
|
| 57 | 57 | $params = [ |
| 58 | 58 | 'title' => $this->getTitle() |
| 59 | 59 | ] + $params; |
| 60 | 60 | |
| 61 | 61 | $this->controller->editPage( $params ); |
| 62 | - if ( isset( $params['text'] ) ) { |
|
| 63 | - $this->content = $params['text']; |
|
| 64 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 65 | - $this->content .= $params['appendtext']; |
|
| 66 | - } elseif ( isset( $params['prependtext'] ) ) { |
|
| 67 | - $this->content = $params['prependtext'] . $this->content; |
|
| 62 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 63 | + $this->content = $params[ 'text' ]; |
|
| 64 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 65 | + $this->content .= $params[ 'appendtext' ]; |
|
| 66 | + } elseif ( isset( $params[ 'prependtext' ] ) ) { |
|
| 67 | + $this->content = $params[ 'prependtext' ] . $this->content; |
|
| 68 | 68 | } else { |
| 69 | 69 | throw new \LogicException( |
| 70 | 70 | 'Unrecognized text param for edit. Params: ' . var_export( $params, true ) |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return bool |
| 79 | 79 | */ |
| 80 | - public function exists() : bool { |
|
| 80 | + public function exists () : bool { |
|
| 81 | 81 | $res = RequestBase::newFromParams( [ |
| 82 | 82 | 'action' => 'query', |
| 83 | 83 | 'titles' => $this->getTitle() |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param string $regex |
| 93 | 93 | * @return bool |
| 94 | 94 | */ |
| 95 | - public function matches( string $regex ) : bool { |
|
| 95 | + public function matches ( string $regex ) : bool { |
|
| 96 | 96 | return (bool)preg_match( $regex, $this->getContent() ); |
| 97 | 97 | } |
| 98 | 98 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @return string[] |
| 105 | 105 | * @throws \Exception |
| 106 | 106 | */ |
| 107 | - public function getMatch( string $regex ) : array { |
|
| 108 | - $ret = []; |
|
| 107 | + public function getMatch ( string $regex ) : array { |
|
| 108 | + $ret = [ ]; |
|
| 109 | 109 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 110 | 110 | throw new \Exception( 'The content does not match the given regex' ); |
| 111 | 111 | } |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | * |
| 118 | 118 | * @inheritDoc |
| 119 | 119 | */ |
| 120 | - public function getRegex() : string { |
|
| 120 | + public function getRegex () : string { |
|
| 121 | 121 | return str_replace( ' ', '[ _]', preg_quote( $this->title ) ); |
| 122 | 122 | } |
| 123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return string |
| 128 | 128 | */ |
| 129 | - public function __toString() { |
|
| 129 | + public function __toString () { |
|
| 130 | 130 | return $this->getTitle(); |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -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 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @param string $domain The URL of the wiki, if different from default |
| 29 | 29 | */ |
| 30 | - public function __construct( string $domain = DEFAULT_URL ) { |
|
| 30 | + public function __construct ( string $domain = DEFAULT_URL ) { |
|
| 31 | 31 | $this->logger = new Logger; |
| 32 | 32 | $this->domain = $domain; |
| 33 | 33 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @throws MissingPageException |
| 42 | 42 | * @throws MissingSectionException |
| 43 | 43 | */ |
| 44 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 44 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 45 | 45 | $msg = "Retrieving content of page $title" . ( $section !== null ? ", section $section" : '' ); |
| 46 | 46 | $this->logger->debug( $msg ); |
| 47 | 47 | $params = [ |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | 55 | if ( $section !== null ) { |
| 56 | - $params['rvsection'] = $section; |
|
| 56 | + $params[ 'rvsection' ] = $section; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | throw new MissingPageException( $title ); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 66 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 67 | 67 | |
| 68 | 68 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
| 69 | 69 | throw new MissingSectionException( $title, $section ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param array $params |
| 78 | 78 | * @throws EditException |
| 79 | 79 | */ |
| 80 | - public function editPage( array $params ) { |
|
| 80 | + public function editPage ( array $params ) { |
|
| 81 | 81 | $this->login(); |
| 82 | 82 | |
| 83 | 83 | $params = [ |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | ] + $params; |
| 87 | 87 | |
| 88 | 88 | if ( Config::getInstance()->get( 'bot-edits' ) ) { |
| 89 | - $params['bot'] = 1; |
|
| 89 | + $params[ 'bot' ] = 1; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | $res = RequestBase::newFromParams( $params ) |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 108 | 108 | * @throws LoginException |
| 109 | 109 | */ |
| 110 | - public function login() { |
|
| 110 | + public function login () { |
|
| 111 | 111 | if ( self::$loggedIn ) { |
| 112 | 112 | return; |
| 113 | 113 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | self::$loggedIn = true; |
| 136 | 136 | // Clear tokens cache |
| 137 | - $this->tokens = []; |
|
| 137 | + $this->tokens = [ ]; |
|
| 138 | 138 | $this->logger->info( 'Login succeeded' ); |
| 139 | 139 | } |
| 140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param string $type |
| 145 | 145 | * @return string |
| 146 | 146 | */ |
| 147 | - public function getToken( string $type ) : string { |
|
| 147 | + public function getToken ( string $type ) : string { |
|
| 148 | 148 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 149 | 149 | $params = [ |
| 150 | 150 | 'action' => 'query', |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @param string $title |
| 168 | 168 | * @return int |
| 169 | 169 | */ |
| 170 | - public function getPageCreationTS( string $title ) : int { |
|
| 170 | + public function getPageCreationTS ( string $title ) : int { |
|
| 171 | 171 | $params = [ |
| 172 | 172 | 'action' => 'query', |
| 173 | 173 | 'prop' => 'revisions', |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
| 182 | 182 | $data = $res->query->pages; |
| 183 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 183 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * @param string $title |
| 190 | 190 | * @param string $reason |
| 191 | 191 | */ |
| 192 | - public function protectPage( string $title, string $reason ) { |
|
| 192 | + public function protectPage ( string $title, string $reason ) { |
|
| 193 | 193 | $this->logger->info( "Protecting page $title" ); |
| 194 | 194 | $this->login(); |
| 195 | 195 | |
@@ -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( ', ', $pages ) |
| 42 | 42 | ); |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @param PageRiconferma[] $pages |
| 71 | 71 | */ |
| 72 | - protected function addToVotazioni( array $pages ) { |
|
| 72 | + protected function addToVotazioni ( array $pages ) { |
|
| 73 | 73 | $this->getLogger()->info( |
| 74 | 74 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
| 75 | 75 | ); |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param int $amount |
| 107 | 107 | * @throws TaskException |
| 108 | 108 | */ |
| 109 | - protected function addToNews( int $amount ) { |
|
| 109 | + protected function addToNews ( int $amount ) { |
|
| 110 | 110 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
| 111 | 111 | $newsPage = new Page( $this->getOpt( 'news-page-title' ) ); |
| 112 | 112 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | throw new TaskException( 'Param not found in news page' ); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $newNum = (int)$matches[2] + $amount; |
|
| 122 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
| 123 | 123 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
| 124 | 124 | |
| 125 | 125 | $summary = $this->msg( '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 | |
@@ -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()->getPagesToClose(); |
| 19 | 19 | |
| 20 | 20 | if ( !$pages ) { |
@@ -33,15 +33,15 @@ discard block |
||
| 33 | 33 | * @param PageRiconferma[] $pages |
| 34 | 34 | * @see OpenUpdates::addToMainPage() |
| 35 | 35 | */ |
| 36 | - protected function removeFromMainPage( array $pages ) { |
|
| 36 | + protected function removeFromMainPage ( array $pages ) { |
|
| 37 | 37 | $this->getLogger()->info( |
| 38 | 38 | 'Removing from main: ' . implode( ', ', $pages ) |
| 39 | 39 | ); |
| 40 | 40 | |
| 41 | 41 | $mainPage = new Page( $this->getOpt( 'main-page-title' ) ); |
| 42 | - $remove = []; |
|
| 42 | + $remove = [ ]; |
|
| 43 | 43 | foreach ( $pages as $page ) { |
| 44 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
| 44 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $newContent = str_replace( $remove, '', $mainPage->getContent() ); |
@@ -70,17 +70,17 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param PageRiconferma[] $pages |
| 72 | 72 | */ |
| 73 | - protected function addToArchive( array $pages ) { |
|
| 73 | + protected function addToArchive ( array $pages ) { |
|
| 74 | 74 | $this->getLogger()->info( |
| 75 | 75 | 'Adding to archive: ' . implode( ', ', $pages ) |
| 76 | 76 | ); |
| 77 | 77 | |
| 78 | - $simple = $votes = []; |
|
| 78 | + $simple = $votes = [ ]; |
|
| 79 | 79 | foreach ( $pages as $page ) { |
| 80 | 80 | if ( $page->isVote() ) { |
| 81 | - $votes[] = $page; |
|
| 81 | + $votes[ ] = $page; |
|
| 82 | 82 | } else { |
| 83 | - $simple[] = $page; |
|
| 83 | + $simple[ ] = $page; |
|
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
@@ -101,15 +101,15 @@ discard block |
||
| 101 | 101 | * @param string $archiveTitle |
| 102 | 102 | * @param array $pages |
| 103 | 103 | */ |
| 104 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
| 104 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
| 105 | 105 | $archivePage = new Page( "$archiveTitle/" . date( 'Y' ) ); |
| 106 | 106 | $exists = $archivePage->exists(); |
| 107 | 107 | |
| 108 | 108 | $append = "\n"; |
| 109 | - $archivedList = []; |
|
| 109 | + $archivedList = [ ]; |
|
| 110 | 110 | foreach ( $pages as $page ) { |
| 111 | 111 | $append .= '{{' . $page->getTitle() . "}}\n"; |
| 112 | - $archivedList[] = $page->getUserNum(); |
|
| 112 | + $archivedList[ ] = $page->getUserNum(); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @param string $archiveTitle |
| 132 | 132 | */ |
| 133 | - private function addArchiveYear( string $archiveTitle ) { |
|
| 133 | + private function addArchiveYear ( string $archiveTitle ) { |
|
| 134 | 134 | $page = new Page( $archiveTitle ); |
| 135 | 135 | $year = date( 'Y' ); |
| 136 | 136 | |
@@ -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 runInternal() : int { |
|
| 17 | + public function runInternal () : int { |
|
| 18 | 18 | $orderedList = [ |
| 19 | 19 | 'create-pages', |
| 20 | 20 | 'open-updates', |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @inheritDoc |
| 34 | 34 | */ |
| 35 | - protected function getSubtasksMap() : array { |
|
| 35 | + protected function getSubtasksMap () : array { |
|
| 36 | 36 | return [ |
| 37 | 37 | 'create-pages' => CreatePages::class, |
| 38 | 38 | 'open-updates' => OpenUpdates::class, |