@@ -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 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @inheritDoc |
15 | 15 | */ |
16 | - public function runInternal(): int { |
|
16 | + public function runInternal (): int { |
|
17 | 17 | $pages = $this->getDataProvider()->getPagesToClose(); |
18 | 18 | |
19 | 19 | if ( !$pages ) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @param PageRiconferma $page |
37 | 37 | */ |
38 | - protected function addVoteCloseText( PageRiconferma $page ): void { |
|
38 | + protected function addVoteCloseText ( PageRiconferma $page ): void { |
|
39 | 39 | $content = $page->getContent(); |
40 | 40 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!u'; |
41 | 41 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param PageRiconferma $page |
51 | 51 | * @see CreatePages::updateBasePage() |
52 | 52 | */ |
53 | - protected function updateBasePage( PageRiconferma $page ): void { |
|
53 | + protected function updateBasePage ( PageRiconferma $page ): void { |
|
54 | 54 | $this->getLogger()->info( "Updating base page for $page" ); |
55 | 55 | |
56 | 56 | if ( $page->getNum() === 1 ) { |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $current = $basePage->getContent(); |
63 | 63 | |
64 | 64 | $outcomeText = ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) ? |
65 | - 'non riconfermato' : |
|
66 | - 'riconfermato'; |
|
65 | + 'non riconfermato' : 'riconfermato'; |
|
67 | 66 | $text = $page->isVote() ? "votazione di riconferma: $outcomeText" : 'riconferma tacita'; |
68 | 67 | |
69 | 68 | $newContent = preg_replace( '/^(#: *)(votazione di )?riconferma in corso/m', '$1' . $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 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @inheritDoc |
15 | 15 | */ |
16 | - public function runInternal(): int { |
|
16 | + public function runInternal (): int { |
|
17 | 17 | $pages = $this->getDataProvider()->getCreatedPages(); |
18 | 18 | |
19 | 19 | if ( !$pages ) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param PageRiconferma[] $pages |
37 | 37 | */ |
38 | - protected function addToMainPage( array $pages ): void { |
|
38 | + protected function addToMainPage ( array $pages ): void { |
|
39 | 39 | $this->getLogger()->info( |
40 | 40 | 'Adding the following to main: ' . implode( ', ', $pages ) |
41 | 41 | ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param PageRiconferma[] $pages |
70 | 70 | */ |
71 | - protected function addToVotazioni( array $pages ): void { |
|
71 | + protected function addToVotazioni ( array $pages ): void { |
|
72 | 72 | $this->getLogger()->info( |
73 | 73 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
74 | 74 | ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param int $amount |
106 | 106 | * @throws TaskException |
107 | 107 | */ |
108 | - protected function addToNews( int $amount ): void { |
|
108 | + protected function addToNews ( int $amount ): void { |
|
109 | 109 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
110 | 110 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
111 | 111 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $matches = $newsPage->getMatch( $reg ); |
120 | 120 | |
121 | - $newNum = (int)$matches[2] + $amount; |
|
121 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
122 | 122 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
123 | 123 | |
124 | 124 | $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 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * @inheritDoc |
14 | 14 | */ |
15 | - public function runInternal(): int { |
|
15 | + public function runInternal (): int { |
|
16 | 16 | $pages = $this->getDataProvider()->getCreatedPages(); |
17 | 17 | $users = $this->getDataProvider()->getUsersToProcess(); |
18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | return TaskResult::STATUS_NOTHING; |
21 | 21 | } |
22 | 22 | |
23 | - $ricNums = []; |
|
23 | + $ricNums = [ ]; |
|
24 | 24 | foreach ( $pages as $page ) { |
25 | 25 | $ricNums[ $page->getUserName() ] = $page->getNum(); |
26 | 26 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param User $user |
39 | 39 | * @param int $ricNum |
40 | 40 | */ |
41 | - protected function addMsg( User $user, int $ricNum ): void { |
|
41 | + protected function addMsg ( User $user, int $ricNum ): void { |
|
42 | 42 | $this->getLogger()->info( "Leaving msg to $user" ); |
43 | 43 | $msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text(); |
44 | 44 |
@@ -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\Task; |
4 | 4 | |
@@ -15,13 +15,13 @@ discard block |
||
15 | 15 | * |
16 | 16 | * @return string[] |
17 | 17 | */ |
18 | - abstract protected function getSubtasksMap(): array; |
|
18 | + abstract protected function getSubtasksMap (): array; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param string $subtask Defined in self::SUBTASKS_MAP |
22 | 22 | * @return TaskResult |
23 | 23 | */ |
24 | - protected function runSubtask( string $subtask ): TaskResult { |
|
24 | + protected function runSubtask ( string $subtask ): TaskResult { |
|
25 | 25 | $map = $this->getSubtasksMap(); |
26 | 26 | if ( !isset( $map[ $subtask ] ) ) { |
27 | 27 | throw new InvalidArgumentException( "'$subtask' is not a valid task." ); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @inheritDoc |
36 | 36 | */ |
37 | - final public function getOperationName(): string { |
|
37 | + final public function getOperationName (): string { |
|
38 | 38 | return 'task'; |
39 | 39 | } |
40 | 40 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param string $class |
45 | 45 | * @return Subtask |
46 | 46 | */ |
47 | - private function getSubtaskInstance( string $class ): Subtask { |
|
47 | + private function getSubtaskInstance ( string $class ): Subtask { |
|
48 | 48 | return new $class( |
49 | 49 | $this->getLogger(), |
50 | 50 | $this->getWikiGroup(), |
@@ -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 | |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | abstract class TaskBase extends ContextSource { |
19 | 19 | /** @var string[] */ |
20 | - protected $errors = []; |
|
20 | + protected $errors = [ ]; |
|
21 | 21 | /** @var TaskDataProvider */ |
22 | 22 | protected $dataProvider; |
23 | 23 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param MessageProvider $mp |
31 | 31 | * @param PageBotList $pbl |
32 | 32 | */ |
33 | - final public function __construct( |
|
33 | + final public function __construct ( |
|
34 | 34 | LoggerInterface $logger, |
35 | 35 | WikiGroup $wikiGroup, |
36 | 36 | TaskDataProvider $dataProvider, |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return TaskResult |
48 | 48 | */ |
49 | - final public function run(): TaskResult { |
|
49 | + final public function run (): TaskResult { |
|
50 | 50 | $class = ( new ReflectionClass( $this ) )->getShortName(); |
51 | 51 | $opName = $this->getOperationName(); |
52 | 52 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -77,19 +77,19 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return int One of the STATUS_* constants |
79 | 79 | */ |
80 | - abstract protected function runInternal(): int; |
|
80 | + abstract protected function runInternal (): int; |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * How this operation should be called in logs |
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - abstract public function getOperationName(): string; |
|
87 | + abstract public function getOperationName (): string; |
|
88 | 88 | |
89 | 89 | /** |
90 | 90 | * @return TaskDataProvider |
91 | 91 | */ |
92 | - protected function getDataProvider(): TaskDataProvider { |
|
92 | + protected function getDataProvider (): TaskDataProvider { |
|
93 | 93 | return $this->dataProvider; |
94 | 94 | } |
95 | 95 | } |
@@ -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,15 +14,15 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @inheritDoc |
16 | 16 | */ |
17 | - protected function getSubtasksMap(): array { |
|
17 | + protected function getSubtasksMap (): array { |
|
18 | 18 | // Everything is done here. |
19 | - return []; |
|
19 | + return [ ]; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @inheritDoc |
24 | 24 | */ |
25 | - public function runInternal(): int { |
|
25 | + public function runInternal (): int { |
|
26 | 26 | $pages = $this->getDataProvider()->getOpenPages(); |
27 | 27 | |
28 | 28 | if ( !$pages ) { |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | * @param PageRiconferma[] $pages |
37 | 37 | * @return int a STATUS_* constant |
38 | 38 | */ |
39 | - protected function processPages( array $pages ): int { |
|
40 | - $donePages = []; |
|
39 | + protected function processPages ( array $pages ): int { |
|
40 | + $donePages = [ ]; |
|
41 | 41 | foreach ( $pages as $page ) { |
42 | 42 | if ( $page->hasOpposition() && !$page->isVote() ) { |
43 | 43 | $this->openVote( $page ); |
44 | 44 | $this->updateBasePage( $page ); |
45 | - $donePages[] = $page; |
|
45 | + $donePages[ ] = $page; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param PageRiconferma $page |
62 | 62 | */ |
63 | - protected function openVote( PageRiconferma $page ): void { |
|
63 | + protected function openVote ( PageRiconferma $page ): void { |
|
64 | 64 | $this->getLogger()->info( "Starting vote on $page" ); |
65 | 65 | |
66 | 66 | $content = $page->getContent(); |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | * @see SimpleUpdates::updateVotazioni() |
100 | 100 | * @see OpenUpdates::addToVotazioni() |
101 | 101 | */ |
102 | - protected function updateVotazioni( array $pages ): void { |
|
102 | + protected function updateVotazioni ( array $pages ): void { |
|
103 | 103 | $votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) ); |
104 | 104 | |
105 | - $users = []; |
|
105 | + $users = [ ]; |
|
106 | 106 | foreach ( $pages as $page ) { |
107 | - $users[] = $this->getUser( $page->getUserName() ); |
|
107 | + $users[ ] = $this->getUser( $page->getUserName() ); |
|
108 | 108 | } |
109 | 109 | $usersReg = RegexUtils::regexFromArray( '!', ...$users ); |
110 | 110 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param PageRiconferma $page |
139 | 139 | * @see \BotRiconferme\Task\Subtask\ClosePages::updateBasePage() |
140 | 140 | */ |
141 | - protected function updateBasePage( PageRiconferma $page ): void { |
|
141 | + protected function updateBasePage ( PageRiconferma $page ): void { |
|
142 | 142 | $this->getLogger()->info( "Updating base page for $page" ); |
143 | 143 | |
144 | 144 | if ( $page->getNum() === 1 ) { |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * @see SimpleUpdates::updateNews() |
166 | 166 | * @see OpenUpdates::addToNews() |
167 | 167 | */ |
168 | - protected function updateNews( int $amount ): void { |
|
168 | + protected function updateNews ( int $amount ): void { |
|
169 | 169 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
170 | 170 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
171 | 171 | |
@@ -180,8 +180,8 @@ discard block |
||
180 | 180 | throw new TaskException( 'Param "voto" not found in news page' ); |
181 | 181 | } |
182 | 182 | |
183 | - $newTac = ( (int)$newsPage->getMatch( $regTac )[2] - $amount ) ?: ''; |
|
184 | - $newVot = ( (int)$newsPage->getMatch( $regVot )[2] + $amount ) ?: ''; |
|
183 | + $newTac = ( (int)$newsPage->getMatch( $regTac )[ 2 ] - $amount ) ?: ''; |
|
184 | + $newVot = ( (int)$newsPage->getMatch( $regVot )[ 2 ] + $amount ) ?: ''; |
|
185 | 185 | |
186 | 186 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
187 | 187 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |
@@ -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, |
@@ -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 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param MessageProvider $mp |
73 | 73 | * @param PageBotList $pbl |
74 | 74 | */ |
75 | - public function __construct( |
|
75 | + public function __construct ( |
|
76 | 76 | LoggerInterface $logger, |
77 | 77 | WikiGroup $wikiGroup, |
78 | 78 | MessageProvider $mp, |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string[] $tasks Only used in MODE_TASK and MODE_SUBTASK |
98 | 98 | * @return TaskResult |
99 | 99 | */ |
100 | - public function run( string $mode, array $tasks = [] ): TaskResult { |
|
100 | + public function run ( string $mode, array $tasks = [ ] ): TaskResult { |
|
101 | 101 | if ( $mode === self::MODE_COMPLETE ) { |
102 | 102 | return $this->runTasks( self::FULL_RUN_ORDERED ); |
103 | 103 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param string[] $tasks |
114 | 114 | * @return TaskResult |
115 | 115 | */ |
116 | - private function runTasks( array $tasks ): TaskResult { |
|
116 | + private function runTasks ( array $tasks ): TaskResult { |
|
117 | 117 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
118 | 118 | do { |
119 | 119 | $res->merge( $this->runTask( current( $tasks ) ) ); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @param string $name |
129 | 129 | * @return TaskResult |
130 | 130 | */ |
131 | - protected function runTask( string $name ): TaskResult { |
|
131 | + protected function runTask ( string $name ): TaskResult { |
|
132 | 132 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
133 | 133 | throw new InvalidArgumentException( "'$name' is not a valid task." ); |
134 | 134 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @param string[] $subtasks |
143 | 143 | * @return TaskResult |
144 | 144 | */ |
145 | - private function runSubtasks( array $subtasks ): TaskResult { |
|
145 | + private function runSubtasks ( array $subtasks ): TaskResult { |
|
146 | 146 | $res = new TaskResult( TaskResult::STATUS_GOOD ); |
147 | 147 | do { |
148 | 148 | $res->merge( $this->runSubtask( current( $subtasks ) ) ); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param string $name |
158 | 158 | * @return TaskResult |
159 | 159 | */ |
160 | - protected function runSubtask( string $name ): TaskResult { |
|
160 | + protected function runSubtask ( string $name ): TaskResult { |
|
161 | 161 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
162 | 162 | throw new InvalidArgumentException( "'$name' is not a valid subtask." ); |
163 | 163 | } |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param string $name |
173 | 173 | * @return Task |
174 | 174 | */ |
175 | - private function getTaskInstance( string $name ): Task { |
|
175 | + private function getTaskInstance ( string $name ): Task { |
|
176 | 176 | $class = self::TASKS_MAP[ $name ]; |
177 | 177 | return new $class( |
178 | 178 | $this->logger, |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | * @param string $class |
190 | 190 | * @return Subtask |
191 | 191 | */ |
192 | - private function getSubtaskInstance( string $class ): Subtask { |
|
192 | + private function getSubtaskInstance ( string $class ): Subtask { |
|
193 | 193 | return new $class( |
194 | 194 | $this->logger, |
195 | 195 | $this->wikiGroup, |