@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\Task\Subtask; |
| 4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | /** |
| 16 | 16 | * @inheritDoc |
| 17 | 17 | */ |
| 18 | - public function runInternal() : int { |
|
| 18 | + public function runInternal () : int { |
|
| 19 | 19 | $pages = $this->getDataProvider()->getPagesToClose(); |
| 20 | 20 | |
| 21 | 21 | if ( !$pages ) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param PageRiconferma[] $pages |
| 35 | 35 | * @see UpdatesAround::addToVotazioni() |
| 36 | 36 | */ |
| 37 | - protected function updateVotazioni( array $pages ) { |
|
| 37 | + protected function updateVotazioni ( array $pages ) { |
|
| 38 | 38 | $this->getLogger()->info( |
| 39 | 39 | 'Updating votazioni: ' . implode( ', ', $pages ) |
| 40 | 40 | ); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * @param array $pages |
| 67 | 67 | * @see UpdatesAround::addToNews() |
| 68 | 68 | */ |
| 69 | - protected function updateNews( array $pages ) { |
|
| 69 | + protected function updateNews ( array $pages ) { |
|
| 70 | 70 | $simpleAmount = $voteAmount = 0; |
| 71 | 71 | foreach ( $pages as $page ) { |
| 72 | 72 | if ( $page->isVote() ) { |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
| 90 | 90 | $voteMatches = $newsPage->getMatch( $voteReg ); |
| 91 | 91 | |
| 92 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
| 93 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
| 92 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
| 93 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
| 94 | 94 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $content ); |
| 95 | 95 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
| 96 | 96 | |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * |
| 109 | 109 | * @param PageRiconferma[] $pages |
| 110 | 110 | */ |
| 111 | - protected function updateAdminList( array $pages ) { |
|
| 111 | + protected function updateAdminList ( array $pages ) { |
|
| 112 | 112 | $this->getLogger()->info( |
| 113 | 113 | 'Updating admin list: ' . implode( ', ', $pages ) |
| 114 | 114 | ); |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | $newContent = $adminsPage->getContent(); |
| 117 | 117 | $newDate = date( 'Ymd', strtotime( '+1 year' ) ); |
| 118 | 118 | |
| 119 | - $riconfNames = $removeNames = []; |
|
| 119 | + $riconfNames = $removeNames = [ ]; |
|
| 120 | 120 | foreach ( $pages as $page ) { |
| 121 | 121 | $user = $page->getUser(); |
| 122 | 122 | $reg = '!(\{\{Amministratore\/riga\|' . $user->getRegex() . ".+\| *)\d+( *\|[ \w]*\}\}.*\n)!"; |
| 123 | 123 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 124 | 124 | // Remove the line |
| 125 | 125 | $newContent = preg_replace( $reg, '', $newContent ); |
| 126 | - $removeNames[] = $user->getName(); |
|
| 126 | + $removeNames[ ] = $user->getName(); |
|
| 127 | 127 | } else { |
| 128 | 128 | $newContent = preg_replace( $reg, '$1' . $newDate . '$2', $newContent ); |
| 129 | - $riconfNames[] = $user->getName(); |
|
| 129 | + $riconfNames[ ] = $user->getName(); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
@@ -146,12 +146,12 @@ discard block |
||
| 146 | 146 | /** |
| 147 | 147 | * @param PageRiconferma[] $pages |
| 148 | 148 | */ |
| 149 | - protected function updateCUList( array $pages ) { |
|
| 149 | + protected function updateCUList ( array $pages ) { |
|
| 150 | 150 | $this->getLogger()->info( 'Checking if CU list needs updating.' ); |
| 151 | 151 | $cuList = new Page( $this->getConfig()->get( 'cu-list-title' ) ); |
| 152 | 152 | $newContent = $cuList->getContent(); |
| 153 | 153 | |
| 154 | - $riconfNames = $removeNames = []; |
|
| 154 | + $riconfNames = $removeNames = [ ]; |
|
| 155 | 155 | foreach ( $pages as $page ) { |
| 156 | 156 | $user = $page->getUser(); |
| 157 | 157 | if ( $user->inGroup( 'checkuser' ) ) { |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 160 | 160 | // Remove the line |
| 161 | 161 | $newContent = preg_replace( $reg, '', $newContent ); |
| 162 | - $removeNames[] = $user->getName(); |
|
| 162 | + $removeNames[ ] = $user->getName(); |
|
| 163 | 163 | } else { |
| 164 | 164 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 165 | - $riconfNames[] = $user->getName(); |
|
| 165 | + $riconfNames[ ] = $user->getName(); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\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->getConfig()->get( 'exclude-admins' ); |
| 77 | 77 | foreach ( $data->query->allusers as $u ) { |
| 78 | 78 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -89,22 +89,22 @@ 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 | - $groupsList = []; |
|
| 95 | + $groupsList = [ ]; |
|
| 96 | 96 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 97 | 97 | $groupsList = $groups; |
| 98 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 98 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 99 | 99 | // Only some groups are missing |
| 100 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 100 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | foreach ( $groupsList as $group ) { |
| 104 | 104 | try { |
| 105 | 105 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 106 | 106 | } catch ( TaskException $e ) { |
| 107 | - $this->errors[] = $e->getMessage(); |
|
| 107 | + $this->errors[ ] = $e->getMessage(); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * @return string |
| 120 | 120 | * @throws TaskException |
| 121 | 121 | */ |
| 122 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 122 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 123 | 123 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 124 | 124 | |
| 125 | 125 | $url = DEFAULT_URL; |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @param string $group |
| 155 | 155 | * @return string|null |
| 156 | 156 | */ |
| 157 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 157 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 158 | 158 | $ts = null; |
| 159 | 159 | foreach ( $data->query->logevents as $entry ) { |
| 160 | 160 | if ( !isset( $entry->params ) ) { |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return array[] |
| 178 | 178 | */ |
| 179 | - protected function getExtraGroups() : array { |
|
| 180 | - $extra = []; |
|
| 179 | + protected function getExtraGroups () : array { |
|
| 180 | + $extra = [ ]; |
|
| 181 | 181 | foreach ( $this->botList as $name => $groups ) { |
| 182 | 182 | // These are not groups |
| 183 | 183 | unset( $groups[ 'override' ], $groups[ 'override-perm' ] ); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param array[] $extra |
| 198 | 198 | * @return array[] |
| 199 | 199 | */ |
| 200 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 200 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 201 | 201 | $newContent = $this->botList; |
| 202 | 202 | foreach ( $newContent as $user => $groups ) { |
| 203 | 203 | if ( isset( $missing[ $user ] ) ) { |
@@ -222,15 +222,15 @@ discard block |
||
| 222 | 222 | * @param array[] $newContent |
| 223 | 223 | * @return array[] |
| 224 | 224 | */ |
| 225 | - protected function removeOverrides( array $newContent ) : array { |
|
| 226 | - $removed = []; |
|
| 225 | + protected function removeOverrides ( array $newContent ) : array { |
|
| 226 | + $removed = [ ]; |
|
| 227 | 227 | foreach ( $newContent as $user => $groups ) { |
| 228 | 228 | $ts = PageBotList::getValidFlagTimestamp( $groups ); |
| 229 | 229 | if ( date( 'd/m', $ts ) === date( 'd/m', strtotime( '- 1 days' ) ) && |
| 230 | - isset( $newContent[ $user ]['override'] ) |
|
| 230 | + isset( $newContent[ $user ][ 'override' ] ) |
|
| 231 | 231 | ) { |
| 232 | 232 | unset( $newContent[ $user ][ 'override' ] ); |
| 233 | - $removed[] = $user; |
|
| 233 | + $removed[ ] = $user; |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @private Use self::get() |
| 13 | 13 | */ |
| 14 | - public function __construct() { |
|
| 14 | + public function __construct () { |
|
| 15 | 15 | parent::__construct( Config::getInstance()->get( 'list-title' ) ); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return self |
| 22 | 22 | */ |
| 23 | - public static function get() : self { |
|
| 23 | + public static function get () : self { |
|
| 24 | 24 | static $instance = null; |
| 25 | 25 | if ( $instance === null ) { |
| 26 | 26 | $instance = new self; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param string[] $groups |
| 33 | 33 | * @return int|null |
| 34 | 34 | */ |
| 35 | - public static function getOverrideTimestamp( array $groups ) : ?int { |
|
| 35 | + public static function getOverrideTimestamp ( array $groups ) : ?int { |
|
| 36 | 36 | if ( array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) { |
| 37 | 37 | // A one-time override takes precedence |
| 38 | 38 | $date = $groups[ 'override' ] ?? $groups[ 'override-perm' ]; |
@@ -47,17 +47,15 @@ discard block |
||
| 47 | 47 | * @param array $groups |
| 48 | 48 | * @return int |
| 49 | 49 | */ |
| 50 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
| 51 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
| 52 | - \DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
| 53 | - 0; |
|
| 54 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
| 55 | - \DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
| 56 | - 0; |
|
| 50 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
| 51 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
| 52 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 53 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
| 54 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 57 | 55 | |
| 58 | 56 | $timestamp = max( $bureaucrat, $checkuser ); |
| 59 | 57 | if ( $timestamp === 0 ) { |
| 60 | - $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
| 58 | + $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
| 61 | 59 | } |
| 62 | 60 | return $timestamp; |
| 63 | 61 | } |
@@ -67,7 +65,7 @@ discard block |
||
| 67 | 65 | * |
| 68 | 66 | * @return array[] |
| 69 | 67 | */ |
| 70 | - public function getAdminsList() : array { |
|
| 68 | + public function getAdminsList () : array { |
|
| 71 | 69 | return json_decode( $this->getContent(), true ); |
| 72 | 70 | } |
| 73 | 71 | } |
@@ -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 = 3; |
| 14 | 14 | private $opposeSection = 4; |
| 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; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @param string $title |
| 31 | 31 | */ |
| 32 | - public function __construct( string $title ) { |
|
| 32 | + public function __construct ( string $title ) { |
|
| 33 | 33 | parent::__construct( $title ); |
| 34 | 34 | $this->supportSection = $this->isVote() ? 3 : 0; |
| 35 | 35 | $this->opposeSection = $this->isVote() ? 4 : 3; |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return User |
| 42 | 42 | */ |
| 43 | - public function getUser() : User { |
|
| 44 | - $name = explode( '/', $this->title )[2]; |
|
| 43 | + public function getUser () : User { |
|
| 44 | + $name = explode( '/', $this->title )[ 2 ]; |
|
| 45 | 45 | return new User( $name ); |
| 46 | 46 | } |
| 47 | 47 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return int |
| 52 | 52 | */ |
| 53 | - public function getNum() : int { |
|
| 53 | + public function getNum () : int { |
|
| 54 | 54 | $bits = explode( '/', $this->getTitle() ); |
| 55 | 55 | return intval( end( $bits ) ); |
| 56 | 56 | } |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public function getUserNum() : string { |
|
| 64 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 63 | + public function getUserNum () : string { |
|
| 64 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string |
| 71 | 71 | */ |
| 72 | - public function getBaseTitle() : string { |
|
| 72 | + public function getBaseTitle () : string { |
|
| 73 | 73 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug |
| 74 | 74 | return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) ); |
| 75 | 75 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * |
| 80 | 80 | * @return int |
| 81 | 81 | */ |
| 82 | - public function getOpposingCount() : int { |
|
| 82 | + public function getOpposingCount () : int { |
|
| 83 | 83 | return $this->getCountForSection( $this->opposeSection ); |
| 84 | 84 | } |
| 85 | 85 | |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | * @return int |
| 90 | 90 | * @throws \BadMethodCallException |
| 91 | 91 | */ |
| 92 | - public function getSupportCount() : int { |
|
| 92 | + public function getSupportCount () : int { |
|
| 93 | 93 | if ( !$this->isVote() ) { |
| 94 | 94 | throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' ); |
| 95 | 95 | } |
@@ -102,13 +102,13 @@ discard block |
||
| 102 | 102 | * @param int $secNum |
| 103 | 103 | * @return int |
| 104 | 104 | */ |
| 105 | - protected function getCountForSection( int $secNum ) : int { |
|
| 105 | + protected function getCountForSection ( int $secNum ) : int { |
|
| 106 | 106 | if ( !isset( $this->sectionCounts[ $secNum ] ) ) { |
| 107 | 107 | $content = $this->controller->getPageContent( $this->title, $secNum ); |
| 108 | 108 | // Let's hope that this is good enough... |
| 109 | - $this->sectionCounts[$secNum] = preg_match_all( "/^\# *(?![# *]|\.\.\.$)/m", $content ); |
|
| 109 | + $this->sectionCounts[ $secNum ] = preg_match_all( "/^\# *(?![# *]|\.\.\.$)/m", $content ); |
|
| 110 | 110 | } |
| 111 | - return $this->sectionCounts[$secNum]; |
|
| 111 | + return $this->sectionCounts[ $secNum ]; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @return int |
| 118 | 118 | */ |
| 119 | - protected function getQuorum() : int { |
|
| 119 | + protected function getQuorum () : int { |
|
| 120 | 120 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 121 | - return intval( $this->getMatch( $reg )[1] ); |
|
| 121 | + return intval( $this->getMatch( $reg )[ 1 ] ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @return bool |
| 128 | 128 | */ |
| 129 | - public function hasOpposition() : bool { |
|
| 129 | + public function hasOpposition () : bool { |
|
| 130 | 130 | return $this->getOpposingCount() >= self::REQUIRED_OPPOSE; |
| 131 | 131 | } |
| 132 | 132 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @return int One of the OUTCOME_* constants |
| 137 | 137 | * @throws \BadMethodCallException |
| 138 | 138 | */ |
| 139 | - public function getOutcome() : int { |
|
| 139 | + public function getOutcome () : int { |
|
| 140 | 140 | if ( !$this->isVote() ) { |
| 141 | 141 | throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' ); |
| 142 | 142 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @throws \BadMethodCallException |
| 157 | 157 | * @throws \LogicException |
| 158 | 158 | */ |
| 159 | - public function getOutcomeText() : string { |
|
| 159 | + public function getOutcomeText () : string { |
|
| 160 | 160 | if ( !$this->isVote() ) { |
| 161 | 161 | throw new \BadMethodCallException( 'No need for an outcome text.' ); |
| 162 | 162 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return bool |
| 192 | 192 | */ |
| 193 | - public function isVote() : bool { |
|
| 193 | + public function isVote () : bool { |
|
| 194 | 194 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 195 | 195 | return !$this->matches( $sectionReg ); |
| 196 | 196 | } |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * |
| 201 | 201 | * @return int |
| 202 | 202 | */ |
| 203 | - public function getCreationTimestamp() : int { |
|
| 203 | + public function getCreationTimestamp () : int { |
|
| 204 | 204 | return $this->controller->getPageCreationTS( $this->title ); |
| 205 | 205 | } |
| 206 | 206 | /** |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | * |
| 209 | 209 | * @return int |
| 210 | 210 | */ |
| 211 | - public function getEndTimestamp() : int { |
|
| 211 | + public function getEndTimestamp () : int { |
|
| 212 | 212 | if ( $this->isVote() ) { |
| 213 | 213 | $reg = "!La votazione ha inizio il.+ alle ore ([\d:]+) e ha termine il (.+) alla stessa ora!"; |
| 214 | 214 | 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; |
| 4 | 4 | |
@@ -14,16 +14,16 @@ discard block |
||
| 14 | 14 | /** @var array[] */ |
| 15 | 15 | private $processUsers; |
| 16 | 16 | /** @var PageRiconferma[] */ |
| 17 | - private $createdPages = []; |
|
| 17 | + private $createdPages = [ ]; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Get a list of users to execute tasks on. |
| 21 | 21 | * |
| 22 | 22 | * @return array[] |
| 23 | 23 | */ |
| 24 | - public function getUsersToProcess() : array { |
|
| 24 | + public function getUsersToProcess () : array { |
|
| 25 | 25 | if ( $this->processUsers === null ) { |
| 26 | - $this->processUsers = []; |
|
| 26 | + $this->processUsers = [ ]; |
|
| 27 | 27 | foreach ( PageBotList::get()->getAdminsList() as $user => $groups ) { |
| 28 | 28 | $override = true; |
| 29 | 29 | $timestamp = PageBotList::getOverrideTimestamp( $groups ); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @return PageRiconferma[] |
| 52 | 52 | */ |
| 53 | - public function getOpenPages() : array { |
|
| 53 | + public function getOpenPages () : array { |
|
| 54 | 54 | static $list = null; |
| 55 | 55 | if ( $list === null ) { |
| 56 | 56 | $mainTitle = $this->getConfig()->get( 'main-page-title' ); |
@@ -64,10 +64,10 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | $pages = RequestBase::newFromParams( $params )->execute()->query->pages; |
| 66 | 66 | $reg = ( new Page( $mainTitle ) )->getRegex(); |
| 67 | - $list = []; |
|
| 67 | + $list = [ ]; |
|
| 68 | 68 | foreach ( reset( $pages )->templates as $page ) { |
| 69 | 69 | if ( preg_match( "!$reg\/[^\/]+\/\d!", $page->title ) ) { |
| 70 | - $list[] = new PageRiconferma( $page->title ); |
|
| 70 | + $list[ ] = new PageRiconferma( $page->title ); |
|
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -80,14 +80,14 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return PageRiconferma[] |
| 82 | 82 | */ |
| 83 | - public function getPagesToClose() : array { |
|
| 83 | + public function getPagesToClose () : array { |
|
| 84 | 84 | static $list = null; |
| 85 | 85 | if ( $list === null ) { |
| 86 | 86 | $allPages = $this->getOpenPages(); |
| 87 | - $list = []; |
|
| 87 | + $list = [ ]; |
|
| 88 | 88 | foreach ( $allPages as $page ) { |
| 89 | 89 | if ( time() > $page->getEndTimestamp() ) { |
| 90 | - $list[] = $page; |
|
| 90 | + $list[ ] = $page; |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -99,21 +99,21 @@ discard block |
||
| 99 | 99 | * |
| 100 | 100 | * @param string $name |
| 101 | 101 | */ |
| 102 | - public function removeUser( string $name ) { |
|
| 102 | + public function removeUser ( string $name ) { |
|
| 103 | 103 | unset( $this->processUsers[ $name ] ); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @return PageRiconferma[] |
| 108 | 108 | */ |
| 109 | - public function getCreatedPages() : array { |
|
| 109 | + public function getCreatedPages () : array { |
|
| 110 | 110 | return $this->createdPages; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * @param PageRiconferma $page |
| 115 | 115 | */ |
| 116 | - public function addCreatedPages( PageRiconferma $page ) { |
|
| 117 | - $this->createdPages[] = $page; |
|
| 116 | + public function addCreatedPages ( PageRiconferma $page ) { |
|
| 117 | + $this->createdPages[ ] = $page; |
|
| 118 | 118 | } |
| 119 | 119 | } |