@@ -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 | |
20 | 20 | if ( !$pages ) { |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | * @param PageRiconferma[] $pages |
34 | 34 | * @see OpenUpdates::addToMainPage() |
35 | 35 | */ |
36 | - protected function removeFromMainPage( array $pages ) { |
|
36 | + protected function removeFromMainPage ( array $pages ) { |
|
37 | 37 | $this->getLogger()->info( |
38 | 38 | 'Removing from main: ' . implode( ', ', $pages ) |
39 | 39 | ); |
40 | 40 | |
41 | 41 | $mainPage = new Page( $this->getOpt( 'main-page-title' ) ); |
42 | - $remove = []; |
|
42 | + $remove = [ ]; |
|
43 | 43 | foreach ( $pages as $page ) { |
44 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
44 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $newContent = str_replace( $remove, '', $mainPage->getContent() ); |
@@ -70,17 +70,17 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param PageRiconferma[] $pages |
72 | 72 | */ |
73 | - protected function addToArchive( array $pages ) { |
|
73 | + protected function addToArchive ( array $pages ) { |
|
74 | 74 | $this->getLogger()->info( |
75 | 75 | 'Adding to archive: ' . implode( ', ', $pages ) |
76 | 76 | ); |
77 | 77 | |
78 | - $simple = $votes = []; |
|
78 | + $simple = $votes = [ ]; |
|
79 | 79 | foreach ( $pages as $page ) { |
80 | 80 | if ( $page->isVote() ) { |
81 | - $votes[] = $page; |
|
81 | + $votes[ ] = $page; |
|
82 | 82 | } else { |
83 | - $simple[] = $page; |
|
83 | + $simple[ ] = $page; |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | * @param string $archiveTitle |
102 | 102 | * @param array $pages |
103 | 103 | */ |
104 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) { |
|
104 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) { |
|
105 | 105 | $archivePage = new Page( "$archiveTitle/" . date( 'Y' ) ); |
106 | 106 | $exists = $archivePage->exists(); |
107 | 107 | |
108 | 108 | $append = "\n"; |
109 | - $archivedList = []; |
|
109 | + $archivedList = [ ]; |
|
110 | 110 | foreach ( $pages as $page ) { |
111 | 111 | $append .= '{{' . $page->getTitle() . "}}\n"; |
112 | - $archivedList[] = $page->getUserNum(); |
|
112 | + $archivedList[ ] = $page->getUserNum(); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * |
131 | 131 | * @param string $archiveTitle |
132 | 132 | */ |
133 | - private function addArchiveYear( string $archiveTitle ) { |
|
133 | + private function addArchiveYear ( string $archiveTitle ) { |
|
134 | 134 | $page = new Page( $archiveTitle ); |
135 | 135 | $year = date( 'Y' ); |
136 | 136 |
@@ -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 | |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @inheritDoc |
18 | 18 | */ |
19 | - public function runInternal() : int { |
|
19 | + public function runInternal () : int { |
|
20 | 20 | $pages = $this->getDataProvider()->getPagesToClose(); |
21 | 21 | |
22 | 22 | if ( !$pages ) { |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | * @param PageRiconferma[] $pages |
39 | 39 | * @see OpenUpdates::addToVotazioni() |
40 | 40 | */ |
41 | - protected function updateVotazioni( array $pages ) { |
|
41 | + protected function updateVotazioni ( array $pages ) { |
|
42 | 42 | $this->getLogger()->info( |
43 | 43 | 'Updating votazioni: ' . implode( ', ', $pages ) |
44 | 44 | ); |
45 | 45 | $votePage = new Page( $this->getOpt( 'vote-page-title' ) ); |
46 | 46 | |
47 | - $users = []; |
|
47 | + $users = [ ]; |
|
48 | 48 | foreach ( $pages as $page ) { |
49 | - $users[] = $page->getUser(); |
|
49 | + $users[ ] = $page->getUser(); |
|
50 | 50 | } |
51 | 51 | $usersReg = Element::regexFromArray( $users ); |
52 | 52 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param array $pages |
68 | 68 | * @see OpenUpdates::addToNews() |
69 | 69 | */ |
70 | - protected function updateNews( array $pages ) { |
|
70 | + protected function updateNews ( array $pages ) { |
|
71 | 71 | $simpleAmount = $voteAmount = 0; |
72 | 72 | foreach ( $pages as $page ) { |
73 | 73 | if ( $page->isVote() ) { |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
88 | 88 | $voteMatches = $newsPage->getMatch( $voteReg ); |
89 | 89 | |
90 | - $newSimp = (int)$simpleMatches[2] - $simpleAmount ?: ''; |
|
91 | - $newVote = (int)$voteMatches[2] - $voteAmount ?: ''; |
|
90 | + $newSimp = (int)$simpleMatches[ 2 ] - $simpleAmount ?: ''; |
|
91 | + $newVote = (int)$voteMatches[ 2 ] - $voteAmount ?: ''; |
|
92 | 92 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() ); |
93 | 93 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
94 | 94 | |
@@ -106,21 +106,21 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param bool[] $outcomes |
108 | 108 | */ |
109 | - protected function updateAdminList( array $outcomes ) { |
|
109 | + protected function updateAdminList ( array $outcomes ) { |
|
110 | 110 | $this->getLogger()->info( 'Updating admin list' ); |
111 | 111 | $adminsPage = new Page( $this->getOpt( 'admins-list-title' ) ); |
112 | 112 | $newContent = $adminsPage->getContent(); |
113 | 113 | |
114 | - $riconfNames = $removeNames = []; |
|
114 | + $riconfNames = $removeNames = [ ]; |
|
115 | 115 | foreach ( $outcomes as $user => $confirmed ) { |
116 | 116 | $userReg = ( new User( $user ) )->getRegex(); |
117 | 117 | $reg = "!(\{\{Amministratore\/riga\|$userReg.+\| *)\d+( *\|[ \w]*\}\}.*\n)!"; |
118 | 118 | if ( $confirmed ) { |
119 | 119 | $newContent = preg_replace( $reg, '${1}{{subst:#time:Ymd}}$2', $newContent ); |
120 | - $riconfNames[] = $user; |
|
120 | + $riconfNames[ ] = $user; |
|
121 | 121 | } else { |
122 | 122 | $newContent = preg_replace( $reg, '', $newContent ); |
123 | - $removeNames[] = $user; |
|
123 | + $removeNames[ ] = $user; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
@@ -140,21 +140,21 @@ discard block |
||
140 | 140 | /** |
141 | 141 | * @param bool[] $outcomes |
142 | 142 | */ |
143 | - protected function updateCUList( array $outcomes ) { |
|
143 | + protected function updateCUList ( array $outcomes ) { |
|
144 | 144 | $this->getLogger()->info( 'Updating CU list.' ); |
145 | 145 | $cuList = new Page( $this->getOpt( 'cu-list-title' ) ); |
146 | 146 | $newContent = $cuList->getContent(); |
147 | 147 | |
148 | - $riconfNames = $removeNames = []; |
|
148 | + $riconfNames = $removeNames = [ ]; |
|
149 | 149 | foreach ( $outcomes as $user => $confirmed ) { |
150 | 150 | $userReg = ( new User( $user ) )->getRegex(); |
151 | 151 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
152 | 152 | if ( $confirmed ) { |
153 | 153 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
154 | - $riconfNames[] = $user; |
|
154 | + $riconfNames[ ] = $user; |
|
155 | 155 | } else { |
156 | 156 | $newContent = preg_replace( $reg, '', $newContent ); |
157 | - $removeNames[] = $user; |
|
157 | + $removeNames[ ] = $user; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * @param PageRiconferma[] $pages |
179 | 179 | * @return bool[] |
180 | 180 | */ |
181 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
182 | - $ret = []; |
|
181 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
182 | + $ret = [ ]; |
|
183 | 183 | foreach ( $pages as $page ) { |
184 | 184 | $user = $page->getUser(); |
185 | 185 | if ( $user->inGroup( $group ) ) { |
@@ -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\Task; |
4 | 4 | |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @inheritDoc |
17 | 17 | */ |
18 | - protected function getSubtasksMap(): array { |
|
18 | + protected function getSubtasksMap (): array { |
|
19 | 19 | // Everything is done here. |
20 | - return []; |
|
20 | + return [ ]; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
24 | 24 | * @inheritDoc |
25 | 25 | */ |
26 | - public function runInternal() : int { |
|
26 | + public function runInternal () : int { |
|
27 | 27 | $pages = $this->getDataProvider()->getOpenPages(); |
28 | 28 | |
29 | 29 | if ( !$pages ) { |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * @param PageRiconferma[] $pages |
38 | 38 | * @return int a STATUS_* constant |
39 | 39 | */ |
40 | - protected function processPages( array $pages ) : int { |
|
41 | - $donePages = []; |
|
40 | + protected function processPages ( array $pages ) : int { |
|
41 | + $donePages = [ ]; |
|
42 | 42 | foreach ( $pages as $page ) { |
43 | 43 | if ( $page->hasOpposition() && !$page->isVote() ) { |
44 | 44 | $this->openVote( $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 ) { |
|
63 | + protected function openVote ( PageRiconferma $page ) { |
|
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 ) { |
|
102 | + protected function updateVotazioni ( array $pages ) { |
|
103 | 103 | $votePage = new Page( $this->getOpt( 'vote-page-title' ) ); |
104 | 104 | |
105 | - $users = []; |
|
105 | + $users = [ ]; |
|
106 | 106 | foreach ( $pages as $page ) { |
107 | - $users[] = $page->getUser(); |
|
107 | + $users[ ] = $page->getUser(); |
|
108 | 108 | } |
109 | 109 | $usersReg = Element::regexFromArray( $users ); |
110 | 110 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | *@see SimpleUpdates::updateNews() |
143 | 143 | * @see OpenUpdates::addToNews() |
144 | 144 | */ |
145 | - protected function updateNews( int $amount ) { |
|
145 | + protected function updateNews ( int $amount ) { |
|
146 | 146 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
147 | 147 | $newsPage = new Page( $this->getOpt( 'news-page-title' ) ); |
148 | 148 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | throw new TaskException( 'Param "voto" not found in news page' ); |
158 | 158 | } |
159 | 159 | |
160 | - $newTac = intval( $newsPage->getMatch( $regTac )[2] ) - $amount ?: ''; |
|
161 | - $newVot = intval( $newsPage->getMatch( $regVot )[2] ) + $amount ?: ''; |
|
160 | + $newTac = intval( $newsPage->getMatch( $regTac )[ 2 ] ) - $amount ?: ''; |
|
161 | + $newVot = intval( $newsPage->getMatch( $regVot )[ 2 ] ) + $amount ?: ''; |
|
162 | 162 | |
163 | 163 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
164 | 164 | $newContent = preg_replace( $regVot, '${1}' . $newVot, $newContent ); |