@@ -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 | 'update-list', |
20 | 20 | 'create-pages', |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | /** |
34 | 34 | * @inheritDoc |
35 | 35 | */ |
36 | - protected function getSubtasksMap() : array { |
|
36 | + protected function getSubtasksMap () : array { |
|
37 | 37 | return [ |
38 | 38 | 'create-pages' => CreatePages::class, |
39 | 39 | 'update-list' => UpdateList::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 | |
@@ -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 ) { |
@@ -31,18 +31,18 @@ discard block |
||
31 | 31 | |
32 | 32 | $this->processPages( $pages ); |
33 | 33 | |
34 | - return self::STATUS_GOOD ; |
|
34 | + return self::STATUS_GOOD; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @param PageRiconferma[] $pages |
39 | 39 | */ |
40 | - protected function processPages( array $pages ) { |
|
41 | - $actualPages = []; |
|
40 | + protected function processPages ( array $pages ) { |
|
41 | + $actualPages = [ ]; |
|
42 | 42 | foreach ( $pages as $page ) { |
43 | 43 | if ( $page->hasOpposition() && !$page->isVote() ) { |
44 | 44 | $this->openVote( $page ); |
45 | - $actualPages[] = $page; |
|
45 | + $actualPages[ ] = $page; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @param PageRiconferma $page |
61 | 61 | */ |
62 | - protected function openVote( PageRiconferma $page ) { |
|
62 | + protected function openVote ( PageRiconferma $page ) { |
|
63 | 63 | $this->getLogger()->info( "Starting vote on $page" ); |
64 | 64 | |
65 | 65 | $content = $page->getContent(); |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | * @see SimpleUpdates::updateVote() |
99 | 99 | * @see UpdatesAround::addVote() |
100 | 100 | */ |
101 | - protected function updateVotePage( array $pages ) { |
|
101 | + protected function updateVotePage ( array $pages ) { |
|
102 | 102 | $votePage = new Page( $this->getConfig()->get( 'ric-vote-page' ) ); |
103 | 103 | $content = $votePage->getContent(); |
104 | 104 | |
105 | - $titles = []; |
|
105 | + $titles = [ ]; |
|
106 | 106 | foreach ( $pages as $page ) { |
107 | - $titles[] = preg_quote( $page->getTitle() ); |
|
107 | + $titles[ ] = preg_quote( $page->getTitle() ); |
|
108 | 108 | } |
109 | 109 | $titleReg = implode( '|', $titles ); |
110 | 110 | $search = "!^\*.+ La \[\[($titleReg)\|procedura]] termina.+\n!gm"; |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | $newContent = preg_replace( $introReg, '$0' . "\n$newLines", $newContent, 1 ); |
128 | 128 | } else { |
129 | 129 | // Start section |
130 | - $matches = []; |
|
130 | + $matches = [ ]; |
|
131 | 131 | if ( preg_match( $introReg, $newContent, $matches ) === false ) { |
132 | 132 | throw new TaskException( 'Intro not found in vote page' ); |
133 | 133 | } |
134 | 134 | $beforeReg = '!INSERIRE LA NOTIZIA PIÙ NUOVA IN CIMA.+!m'; |
135 | 135 | // Replace semicolon with full stop |
136 | 136 | $newLines = substr( $newLines, 0, -2 ) . ".\n"; |
137 | - $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[0]}\n$newLines", $newContent, 1 ); |
|
137 | + $newContent = preg_replace( $beforeReg, '$0' . "\n{$matches[ 0 ]}\n$newLines", $newContent, 1 ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $summary = $this->msg( 'vote-start-vote-page-summary' ) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @see UpdatesAround::addNews() |
157 | 157 | * @see SimpleUpdates::updateNews() |
158 | 158 | */ |
159 | - protected function updateNews( int $amount ) { |
|
159 | + protected function updateNews ( int $amount ) { |
|
160 | 160 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
161 | 161 | $newsPage = new Page( $this->getConfig()->get( 'ric-news-page' ) ); |
162 | 162 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | throw new TaskException( 'Param "voto" not found in news page' ); |
172 | 172 | } |
173 | 173 | |
174 | - $newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: ''; |
|
175 | - $newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: ''; |
|
174 | + $newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: ''; |
|
175 | + $newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: ''; |
|
176 | 176 | |
177 | 177 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
178 | 178 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |