@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Task; |
4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @inheritDoc |
17 | 17 | */ |
18 | - public function runInternal() : int { |
|
18 | + public function runInternal () : int { |
|
19 | 19 | $orderedList = [ |
20 | 20 | 'close-pages', |
21 | 21 | 'archive-pages', |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @inheritDoc |
36 | 36 | */ |
37 | - protected function getSubtasksMap(): array { |
|
37 | + protected function getSubtasksMap (): array { |
|
38 | 38 | return [ |
39 | 39 | 'archive-pages' => ArchivePages::class, |
40 | 40 | 'close-pages' => ClosePages::class, |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param int $status One of the Task::STATUS_* constants |
22 | 22 | * @param string[] $errors |
23 | 23 | */ |
24 | - public function __construct( int $status, array $errors = [] ) { |
|
24 | + public function __construct ( int $status, array $errors = [ ] ) { |
|
25 | 25 | $this->status = $status; |
26 | 26 | $this->errors = $errors; |
27 | 27 | } |
@@ -29,21 +29,21 @@ discard block |
||
29 | 29 | /** |
30 | 30 | * @return int |
31 | 31 | */ |
32 | - public function getStatus() : int { |
|
32 | + public function getStatus () : int { |
|
33 | 33 | return $this->status; |
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * @return string[] |
38 | 38 | */ |
39 | - public function getErrors() { |
|
39 | + public function getErrors () { |
|
40 | 40 | return $this->errors; |
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param TaskResult $that |
45 | 45 | */ |
46 | - public function merge( TaskResult $that ) { |
|
46 | + public function merge ( TaskResult $that ) { |
|
47 | 47 | $this->status |= $that->status; |
48 | 48 | $this->errors = array_merge( $this->errors, $that->errors ); |
49 | 49 | } |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * @return string |
53 | 53 | */ |
54 | - public function __toString() { |
|
54 | + public function __toString () { |
|
55 | 55 | if ( $this->isOK() ) { |
56 | 56 | $stat = 'OK'; |
57 | 57 | $errs = "\tNo errors."; |
58 | 58 | } else { |
59 | 59 | $stat = 'ERROR'; |
60 | - $formattedErrs = []; |
|
60 | + $formattedErrs = [ ]; |
|
61 | 61 | foreach ( $this->errors as $err ) { |
62 | - $formattedErrs[] = "\t - $err"; |
|
62 | + $formattedErrs[ ] = "\t - $err"; |
|
63 | 63 | } |
64 | 64 | $errs = implode( "\n", $formattedErrs ); |
65 | 65 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return bool |
73 | 73 | */ |
74 | - public function isOK() : bool { |
|
74 | + public function isOK () : bool { |
|
75 | 75 | return ( $this->status | self::STATUS_GOOD ) === self::STATUS_GOOD; |
76 | 76 | } |
77 | 77 | } |
@@ -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 | 'updates-around', |
@@ -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 | 'updates-around' => UpdatesAround::class, |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Exception; |
4 | 4 | |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @param string $title |
11 | 11 | * @param int|string $section Number or title |
12 | 12 | */ |
13 | - public function __construct( string $title = '[unavailable]', $section = '[unavailable]' ) { |
|
13 | + public function __construct ( string $title = '[unavailable]', $section = '[unavailable]' ) { |
|
14 | 14 | parent::__construct( "The section $section in the page $title doesn't exist." ); |
15 | 15 | } |
16 | 16 | } |
@@ -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 | $protectReason = $this->msg( 'close-protect-summary' )->text(); |
20 | 20 | foreach ( $pages as $page ) { |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | /** |
32 | 32 | * @param PageRiconferma $page |
33 | 33 | */ |
34 | - protected function addVoteCloseText( PageRiconferma $page ) { |
|
34 | + protected function addVoteCloseText ( PageRiconferma $page ) { |
|
35 | 35 | $content = $page->getContent(); |
36 | 36 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!'; |
37 | 37 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -46,15 +46,14 @@ discard block |
||
46 | 46 | * @param PageRiconferma $page |
47 | 47 | * @see CreatePages::updateBasePage() |
48 | 48 | */ |
49 | - protected function updateBasePage( PageRiconferma $page ) { |
|
49 | + protected function updateBasePage ( PageRiconferma $page ) { |
|
50 | 50 | $this->getLogger()->info( "Updating base page for $page" ); |
51 | 51 | |
52 | 52 | $basePage = new Page( $page->getBaseTitle() ); |
53 | 53 | $current = $basePage->getContent(); |
54 | 54 | |
55 | 55 | $outcomeText = $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ? |
56 | - 'non riconfermato' : |
|
57 | - 'riconfermato'; |
|
56 | + 'non riconfermato' : 'riconfermato'; |
|
58 | 57 | $text = $page->isVote() ? "votazione: $outcomeText" : 'riconferma tacita'; |
59 | 58 | |
60 | 59 | $newContent = str_replace( 'riconferma in corso', $text, $current ); |
@@ -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->getConfig()->get( 'main-page-title' ), 2 )[1]; |
|
71 | + $unprefixedTitle = explode( ':', $this->getConfig()->get( '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; |
4 | 4 | |
@@ -12,12 +12,12 @@ discard block |
||
12 | 12 | /** @var self */ |
13 | 13 | private static $instance; |
14 | 14 | /** @var array */ |
15 | - private $opts = []; |
|
15 | + private $opts = [ ]; |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Use self::init() and self::getInstance() |
19 | 19 | */ |
20 | - private function __construct() { |
|
20 | + private function __construct () { |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * @param array $defaults |
27 | 27 | * @throws ConfigException |
28 | 28 | */ |
29 | - public static function init( array $defaults ) { |
|
29 | + public static function init ( array $defaults ) { |
|
30 | 30 | if ( self::$instance ) { |
31 | 31 | throw new ConfigException( 'Config was already initialized' ); |
32 | 32 | } |
33 | 33 | |
34 | 34 | $inst = new self; |
35 | - $inst->set( 'list-title', $defaults['list-title'] ); |
|
36 | - $inst->set( 'msg-title', $defaults['msg-title'] ); |
|
37 | - $inst->set( 'username', $defaults['username'] ); |
|
38 | - $inst->set( 'password', $defaults['password'] ); |
|
35 | + $inst->set( 'list-title', $defaults[ 'list-title' ] ); |
|
36 | + $inst->set( 'msg-title', $defaults[ 'msg-title' ] ); |
|
37 | + $inst->set( 'username', $defaults[ 'username' ] ); |
|
38 | + $inst->set( 'password', $defaults[ 'password' ] ); |
|
39 | 39 | self::$instance = $inst; |
40 | 40 | |
41 | 41 | // On-wiki values |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $key |
55 | 55 | * @return string |
56 | 56 | */ |
57 | - public function getWikiMessage( string $key ) : string { |
|
57 | + public function getWikiMessage ( string $key ) : string { |
|
58 | 58 | static $messages = null; |
59 | 59 | if ( $messages === null ) { |
60 | 60 | try { |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | if ( !isset( $messages[ $key ] ) ) { |
68 | 68 | throw new ConfigException( "Message '$key' does not exist." ); |
69 | 69 | } |
70 | - return $messages[$key]; |
|
70 | + return $messages[ $key ]; |
|
71 | 71 | } |
72 | 72 | /** |
73 | 73 | * Set a config value. |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * @param string $key |
76 | 76 | * @param mixed $value |
77 | 77 | */ |
78 | - protected function set( string $key, $value ) { |
|
78 | + protected function set ( string $key, $value ) { |
|
79 | 79 | $this->opts[ $key ] = $value; |
80 | 80 | } |
81 | 81 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return self |
86 | 86 | * @throws ConfigException |
87 | 87 | */ |
88 | - public static function getInstance() : self { |
|
88 | + public static function getInstance () : self { |
|
89 | 89 | if ( !self::$instance ) { |
90 | 90 | throw new ConfigException( 'Config not yet initialized' ); |
91 | 91 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return mixed |
100 | 100 | * @throws ConfigException |
101 | 101 | */ |
102 | - public function get( string $opt ) { |
|
102 | + public function get ( string $opt ) { |
|
103 | 103 | if ( !isset( $this->opts[ $opt ] ) ) { |
104 | 104 | throw new ConfigException( "Config option '$opt' not set." ); |
105 | 105 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * @inheritDoc |
13 | 13 | */ |
14 | - final public function getOperationName(): string { |
|
14 | + final public function getOperationName (): string { |
|
15 | 15 | return 'subtask'; |
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\Task; |
4 | 4 | |
@@ -14,13 +14,13 @@ discard block |
||
14 | 14 | * |
15 | 15 | * @return string[] |
16 | 16 | */ |
17 | - abstract protected function getSubtasksMap() : array; |
|
17 | + abstract protected function getSubtasksMap () : array; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * @param string $subtask Defined in self::SUBTASKS_MAP |
21 | 21 | * @return TaskResult |
22 | 22 | */ |
23 | - protected function runSubtask( string $subtask ) : TaskResult { |
|
23 | + protected function runSubtask ( string $subtask ) : TaskResult { |
|
24 | 24 | $map = $this->getSubtasksMap(); |
25 | 25 | if ( !isset( $map[ $subtask ] ) ) { |
26 | 26 | throw new \InvalidArgumentException( "'$subtask' is not a valid task." ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @inheritDoc |
35 | 35 | */ |
36 | - final public function getOperationName(): string { |
|
36 | + final public function getOperationName (): string { |
|
37 | 37 | return 'task'; |
38 | 38 | } |
39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $class |
44 | 44 | * @return Subtask |
45 | 45 | */ |
46 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
46 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
47 | 47 | return new $class( $this->getDataProvider() ); |
48 | 48 | } |
49 | 49 | } |