@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK |
| 53 | 53 | * @return TaskResult |
| 54 | 54 | */ |
| 55 | - public function run( string $mode, string $name = null ) : TaskResult { |
|
| 55 | + public function run ( string $mode, string $name = null ) : TaskResult { |
|
| 56 | 56 | $this->provider = new TaskDataProvider; |
| 57 | 57 | |
| 58 | 58 | if ( $mode === self::MODE_COMPLETE ) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return TaskResult |
| 71 | 71 | */ |
| 72 | - protected function runAllTasks() : TaskResult { |
|
| 72 | + protected function runAllTasks () : TaskResult { |
|
| 73 | 73 | $orderedList = [ |
| 74 | 74 | 'update-list', |
| 75 | 75 | 'start-new', |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $name |
| 92 | 92 | * @return TaskResult |
| 93 | 93 | */ |
| 94 | - protected function runTask( string $name ) : TaskResult { |
|
| 94 | + protected function runTask ( string $name ) : TaskResult { |
|
| 95 | 95 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 96 | 96 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
| 97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param string $name |
| 107 | 107 | * @return TaskResult |
| 108 | 108 | */ |
| 109 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 109 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 110 | 110 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 111 | 111 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 112 | 112 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param string $class |
| 122 | 122 | * @return Task |
| 123 | 123 | */ |
| 124 | - private function getTaskInstance( string $class ) : Task { |
|
| 124 | + private function getTaskInstance ( string $class ) : Task { |
|
| 125 | 125 | return new $class( $this->provider ); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $class |
| 132 | 132 | * @return Subtask |
| 133 | 133 | */ |
| 134 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 134 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 135 | 135 | return new $class( $this->provider ); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme\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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function log( $level, $message, array $context = [] ) { |
|
| 14 | + public function log ( $level, $message, array $context = [ ] ) { |
|
| 15 | 15 | printf( "%s [%s] - %s\n", date( 'd M H:i:s' ), $level, $message ); |
| 16 | 16 | } |
| 17 | 17 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | const VERSION = 1.0; |
| 13 | 13 | |
| 14 | - public function __construct() { |
|
| 14 | + public function __construct () { |
|
| 15 | 15 | $this->logger = new Logger; |
| 16 | 16 | } |
| 17 | 17 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $mode |
| 22 | 22 | * @param string|null $name |
| 23 | 23 | */ |
| 24 | - private function run( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) { |
|
| 24 | + private function run ( string $mode = TaskManager::MODE_COMPLETE, string $name = null ) { |
|
| 25 | 25 | $activity = $mode === TaskManager::MODE_COMPLETE ? TaskManager::MODE_COMPLETE : "$mode $name"; |
| 26 | 26 | $this->logger->info( "Running $activity" ); |
| 27 | 27 | $manager = new TaskManager; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | /** |
| 38 | 38 | * Entry point for the whole process |
| 39 | 39 | */ |
| 40 | - public function runAll() { |
|
| 40 | + public function runAll () { |
|
| 41 | 41 | $this->run(); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * |
| 47 | 47 | * @param string $task |
| 48 | 48 | */ |
| 49 | - public function runTask( string $task ) { |
|
| 49 | + public function runTask ( string $task ) { |
|
| 50 | 50 | $this->run( TaskManager::MODE_TASK, $task ); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | * |
| 56 | 56 | * @param string $subtask |
| 57 | 57 | */ |
| 58 | - public function runSubtask( string $subtask ) { |
|
| 58 | + public function runSubtask ( string $subtask ) { |
|
| 59 | 59 | $this->run( TaskManager::MODE_SUBTASK, $subtask ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -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 | $failed = $this->getFailures(); |
| 20 | 20 | if ( $failed ) { |
| 21 | 21 | $this->updateBurList( $failed ); |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return PageRiconferma[] |
| 34 | 34 | */ |
| 35 | - private function getFailures() : array { |
|
| 36 | - $ret = []; |
|
| 35 | + private function getFailures () : array { |
|
| 36 | + $ret = [ ]; |
|
| 37 | 37 | $allPages = $this->getDataProvider()->getPagesToClose(); |
| 38 | 38 | foreach ( $allPages as $page ) { |
| 39 | 39 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 40 | - $ret[] = $page; |
|
| 40 | + $ret[ ] = $page; |
|
| 41 | 41 | } |
| 42 | 42 | } |
| 43 | 43 | return $ret; |
@@ -46,16 +46,16 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * @param PageRiconferma[] $pages |
| 48 | 48 | */ |
| 49 | - protected function updateBurList( array $pages ) { |
|
| 49 | + protected function updateBurList ( array $pages ) { |
|
| 50 | 50 | $this->getLogger()->info( 'Checking if bur list needs updating.' ); |
| 51 | 51 | |
| 52 | - $remove = []; |
|
| 52 | + $remove = [ ]; |
|
| 53 | 53 | foreach ( $pages as $page ) { |
| 54 | 54 | $user = $page->getUser(); |
| 55 | 55 | if ( $user->inGroup( 'bureaucrat' ) && |
| 56 | 56 | ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) |
| 57 | 57 | ) { |
| 58 | - $remove[] = $user; |
|
| 58 | + $remove[ ] = $user; |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * |
| 86 | 86 | * @param PageRiconferma[] $pages |
| 87 | 87 | */ |
| 88 | - protected function requestRemoval( array $pages ) { |
|
| 88 | + protected function requestRemoval ( array $pages ) { |
|
| 89 | 89 | $this->getLogger()->info( |
| 90 | 90 | 'Requesting removal on meta for: ' . implode( ', ', $pages ) |
| 91 | 91 | ); |
@@ -124,16 +124,16 @@ discard block |
||
| 124 | 124 | * |
| 125 | 125 | * @param PageRiconferma[] $pages |
| 126 | 126 | */ |
| 127 | - protected function updateAnnunci( array $pages ) { |
|
| 127 | + protected function updateAnnunci ( array $pages ) { |
|
| 128 | 128 | $this->getLogger()->info( 'Updating annunci' ); |
| 129 | 129 | $section = 1; |
| 130 | 130 | |
| 131 | - $names = []; |
|
| 131 | + $names = [ ]; |
|
| 132 | 132 | $text = ''; |
| 133 | 133 | $msg = $this->msg( 'annunci-text' ); |
| 134 | 134 | foreach ( $pages as $page ) { |
| 135 | 135 | $user = $page->getUser()->getName(); |
| 136 | - $names[] = $user; |
|
| 136 | + $names[ ] = $user; |
|
| 137 | 137 | $text .= $msg->params( [ '$user' => $user ] )->text(); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -167,17 +167,17 @@ 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-page-title' ) ); |
| 173 | 173 | |
| 174 | - $names = []; |
|
| 174 | + $names = [ ]; |
|
| 175 | 175 | $text = ''; |
| 176 | 176 | $msg = $this->msg( 'ultimenotizie-text' ); |
| 177 | 177 | foreach ( $pages as $page ) { |
| 178 | 178 | $user = $page->getUser()->getName(); |
| 179 | 179 | $title = $page->getTitle(); |
| 180 | - $names[] = $user; |
|
| 180 | + $names[ ] = $user; |
|
| 181 | 181 | $text .= $msg->params( [ '$user' => $user, '$title' => $title ] )->text(); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | |
| 3 | 3 | namespace BotRiconferme; |
| 4 | 4 | |
@@ -14,16 +14,16 @@ discard block |
||
| 14 | 14 | /** @var array[] */ |
| 15 | 15 | private $processUsers; |
| 16 | 16 | /** @var PageRiconferma[] */ |
| 17 | - private $createdPages = []; |
|
| 17 | + private $createdPages = [ ]; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * Get a list of users to execute tasks on. |
| 21 | 21 | * |
| 22 | 22 | * @return array[] |
| 23 | 23 | */ |
| 24 | - public function getUsersToProcess() : array { |
|
| 24 | + public function getUsersToProcess () : array { |
|
| 25 | 25 | if ( $this->processUsers === null ) { |
| 26 | - $this->processUsers = []; |
|
| 26 | + $this->processUsers = [ ]; |
|
| 27 | 27 | foreach ( PageBotList::get()->getAdminsList() as $user => $groups ) { |
| 28 | 28 | if ( $this->shouldAddUser( $groups ) ) { |
| 29 | 29 | $this->processUsers[ $user ] = $groups; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param array[] $groups |
| 41 | 41 | * @return bool |
| 42 | 42 | */ |
| 43 | - private function shouldAddUser( array $groups ) : bool { |
|
| 43 | + private function shouldAddUser ( array $groups ) : bool { |
|
| 44 | 44 | $override = true; |
| 45 | 45 | $timestamp = PageBotList::getOverrideTimestamp( $groups ); |
| 46 | 46 | |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return PageRiconferma[] |
| 61 | 61 | */ |
| 62 | - public function getOpenPages() : array { |
|
| 62 | + public function getOpenPages () : array { |
|
| 63 | 63 | static $list = null; |
| 64 | 64 | if ( $list === null ) { |
| 65 | - $list = []; |
|
| 65 | + $list = [ ]; |
|
| 66 | 66 | $mainTitle = $this->getConfig()->get( 'main-page-title' ); |
| 67 | 67 | $params = [ |
| 68 | 68 | 'action' => 'query', |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $pages = RequestBase::newFromParams( $params )->execute()->query->pages; |
| 77 | 77 | foreach ( reset( $pages )->templates as $page ) { |
| 78 | 78 | if ( preg_match( "!$titleReg\/[^\/]+\/\d!", $page->title ) ) { |
| 79 | - $list[] = new PageRiconferma( $page->title ); |
|
| 79 | + $list[ ] = new PageRiconferma( $page->title ); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | * |
| 90 | 90 | * @return PageRiconferma[] |
| 91 | 91 | */ |
| 92 | - public function getPagesToClose() : array { |
|
| 92 | + public function getPagesToClose () : array { |
|
| 93 | 93 | static $list = null; |
| 94 | 94 | if ( $list === null ) { |
| 95 | - $list = []; |
|
| 95 | + $list = [ ]; |
|
| 96 | 96 | foreach ( $this->getOpenPages() as $page ) { |
| 97 | 97 | if ( time() > $page->getEndTimestamp() ) { |
| 98 | - $list[] = $page; |
|
| 98 | + $list[ ] = $page; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -107,21 +107,21 @@ discard block |
||
| 107 | 107 | * |
| 108 | 108 | * @param string $name |
| 109 | 109 | */ |
| 110 | - public function removeUser( string $name ) { |
|
| 110 | + public function removeUser ( string $name ) { |
|
| 111 | 111 | unset( $this->processUsers[ $name ] ); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
| 115 | 115 | * @return PageRiconferma[] |
| 116 | 116 | */ |
| 117 | - public function getCreatedPages() : array { |
|
| 117 | + public function getCreatedPages () : array { |
|
| 118 | 118 | return $this->createdPages; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
| 122 | 122 | * @param PageRiconferma $page |
| 123 | 123 | */ |
| 124 | - public function addCreatedPages( PageRiconferma $page ) { |
|
| 125 | - $this->createdPages[] = $page; |
|
| 124 | + public function addCreatedPages ( PageRiconferma $page ) { |
|
| 125 | + $this->createdPages[ ] = $page; |
|
| 126 | 126 | } |
| 127 | 127 | } |
@@ -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 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @param string $key |
| 30 | 30 | */ |
| 31 | - public function __construct( string $key ) { |
|
| 31 | + public function __construct ( string $key ) { |
|
| 32 | 32 | $this->key = $key; |
| 33 | 33 | $this->value = Config::getInstance()->getWikiMessage( $key ); |
| 34 | 34 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param array $args |
| 38 | 38 | * @return self |
| 39 | 39 | */ |
| 40 | - public function params( array $args ) : self { |
|
| 40 | + public function params ( array $args ) : self { |
|
| 41 | 41 | $this->value = strtr( $this->value, $args ); |
| 42 | 42 | return $this; |
| 43 | 43 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * @return string |
| 47 | 47 | */ |
| 48 | - public function text() : string { |
|
| 48 | + public function text () : string { |
|
| 49 | 49 | $this->parsePlurals(); |
| 50 | 50 | return $this->value; |
| 51 | 51 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * Replace {{$plur|<amount>|sing|plur}} |
| 55 | 55 | */ |
| 56 | - protected function parsePlurals() { |
|
| 56 | + protected function parsePlurals () { |
|
| 57 | 57 | $reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!'; |
| 58 | 58 | |
| 59 | 59 | if ( preg_match( $reg, $this->value ) === 0 ) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $this->value = preg_replace_callback( |
| 63 | 63 | $reg, |
| 64 | 64 | function ( $matches ) { |
| 65 | - return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
| 65 | + return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
| 66 | 66 | }, |
| 67 | 67 | $this->value |
| 68 | 68 | ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param int $timestamp |
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | - public static function getTimeWithArticle( int $timestamp ) : string { |
|
| 77 | + public static function getTimeWithArticle ( int $timestamp ) : string { |
|
| 78 | 78 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 79 | 79 | $timeString = strftime( '%e %B alle %R', $timestamp ); |
| 80 | 80 | // Remove the left space if day has a single digit |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $timeString |
| 92 | 92 | * @return int |
| 93 | 93 | */ |
| 94 | - public static function getTimestampFromLocalTime( string $timeString ) : int { |
|
| 94 | + public static function getTimestampFromLocalTime ( string $timeString ) : int { |
|
| 95 | 95 | $englishTime = str_ireplace( |
| 96 | 96 | array_values( self::MONTHS ), |
| 97 | 97 | array_keys( self::MONTHS ), |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | * @param string $emptyText |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public static function commaList( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 113 | + public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 114 | 114 | if ( count( $data ) > 1 ) { |
| 115 | 115 | $last = array_pop( $data ); |
| 116 | 116 | $ret = implode( ', ', $data ) . " e $last"; |
| 117 | 117 | } elseif ( $data ) { |
| 118 | - $ret = (string)$data[0]; |
|
| 118 | + $ret = (string)$data[ 0 ]; |
|
| 119 | 119 | } else { |
| 120 | 120 | $ret = $emptyText; |
| 121 | 121 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | return $ret; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function __toString() { |
|
| 126 | + public function __toString () { |
|
| 127 | 127 | return $this->text(); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -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,23 +108,23 @@ 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 | ); |
| 115 | 115 | $adminsPage = new Page( $this->getConfig()->get( 'admins-list-title' ) ); |
| 116 | 116 | $newContent = $adminsPage->getContent(); |
| 117 | 117 | |
| 118 | - $riconfNames = $removeNames = []; |
|
| 118 | + $riconfNames = $removeNames = [ ]; |
|
| 119 | 119 | foreach ( $pages as $page ) { |
| 120 | 120 | $user = $page->getUser(); |
| 121 | 121 | $reg = '!(\{\{Amministratore\/riga\|' . $user->getRegex() . ".+\| *)\d+( *\|[ \w]*\}\}.*\n)!"; |
| 122 | 122 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 123 | 123 | $newContent = preg_replace( $reg, '', $newContent ); |
| 124 | - $removeNames[] = $user->getName(); |
|
| 124 | + $removeNames[ ] = $user->getName(); |
|
| 125 | 125 | } else { |
| 126 | 126 | $newContent = preg_replace( $reg, '${1}{{subst:#time:Ymd|+1 year}}$2', $newContent ); |
| 127 | - $riconfNames[] = $user->getName(); |
|
| 127 | + $riconfNames[ ] = $user->getName(); |
|
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
@@ -144,22 +144,22 @@ 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 | $newContent = $cuList->getContent(); |
| 151 | 151 | |
| 152 | - $riconfNames = $removeNames = []; |
|
| 152 | + $riconfNames = $removeNames = [ ]; |
|
| 153 | 153 | foreach ( $pages as $page ) { |
| 154 | 154 | $user = $page->getUser(); |
| 155 | 155 | if ( $user->inGroup( 'checkuser' ) ) { |
| 156 | 156 | $reg = '!(\{\{ *Checkuser *\| *' . $user->getRegex() . " *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
| 157 | 157 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
| 158 | 158 | $newContent = preg_replace( $reg, '', $newContent ); |
| 159 | - $removeNames[] = $user->getName(); |
|
| 159 | + $removeNames[ ] = $user->getName(); |
|
| 160 | 160 | } else { |
| 161 | 161 | $newContent = preg_replace( $reg, '$1{{subst:#time:j F Y}}$2', $newContent ); |
| 162 | - $riconfNames[] = $user->getName(); |
|
| 162 | + $riconfNames[ ] = $user->getName(); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | } |