@@ -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\Subtask; |
4 | 4 | |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | /** |
12 | 12 | * @inheritDoc |
13 | 13 | */ |
14 | - public function runInternal() : int { |
|
14 | + public function runInternal () : int { |
|
15 | 15 | $pages = $this->getDataProvider()->getCreatedPages(); |
16 | 16 | $users = $this->getDataProvider()->getUsersToProcess(); |
17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | return TaskResult::STATUS_NOTHING; |
20 | 20 | } |
21 | 21 | |
22 | - $ricNums = []; |
|
22 | + $ricNums = [ ]; |
|
23 | 23 | foreach ( $pages as $page ) { |
24 | 24 | $ricNums[ $page->getUser()->getName() ] = $page->getNum(); |
25 | 25 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @param string $user |
38 | 38 | * @param int $ricNum |
39 | 39 | */ |
40 | - protected function addMsg( string $user, int $ricNum ) { |
|
40 | + protected function addMsg ( string $user, int $ricNum ) { |
|
41 | 41 | $this->getLogger()->info( "Leaving msg to $user" ); |
42 | 42 | $msg = $this->msg( 'user-notice-msg' )->params( [ '$num' => $ricNum ] )->text(); |
43 | 43 |
@@ -1,4 +1,4 @@ |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Exception; |
4 | 4 |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Request; |
4 | 4 | |
@@ -30,14 +30,14 @@ discard block |
||
30 | 30 | /** @var string */ |
31 | 31 | protected $method = 'GET'; |
32 | 32 | /** @var string[] */ |
33 | - protected $newCookies = []; |
|
33 | + protected $newCookies = [ ]; |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Use self::newFromParams, which will provide the right class to use |
37 | 37 | * |
38 | 38 | * @param array $params |
39 | 39 | */ |
40 | - protected function __construct( array $params ) { |
|
40 | + protected function __construct ( array $params ) { |
|
41 | 41 | $this->params = [ 'format' => 'json' ] + $params; |
42 | 42 | $this->url = DEFAULT_URL; |
43 | 43 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param array $params |
49 | 49 | * @return self |
50 | 50 | */ |
51 | - public static function newFromParams( array $params ) : self { |
|
51 | + public static function newFromParams ( array $params ) : self { |
|
52 | 52 | if ( extension_loaded( 'curl' ) ) { |
53 | 53 | $ret = new CurlRequest( $params ); |
54 | 54 | } else { |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return self For chaining |
64 | 64 | */ |
65 | - public function setPost() : self { |
|
65 | + public function setPost () : self { |
|
66 | 66 | $this->method = 'POST'; |
67 | 67 | return $this; |
68 | 68 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param string $url |
74 | 74 | * @return self for chaining |
75 | 75 | */ |
76 | - public function setUrl( string $url ) : self { |
|
76 | + public function setUrl ( string $url ) : self { |
|
77 | 77 | $this->url = $url; |
78 | 78 | return $this; |
79 | 79 | } |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return \stdClass |
85 | 85 | */ |
86 | - public function execute() : \stdClass { |
|
86 | + public function execute () : \stdClass { |
|
87 | 87 | $curParams = $this->params; |
88 | - $sets = []; |
|
88 | + $sets = [ ]; |
|
89 | 89 | do { |
90 | 90 | $res = $this->makeRequestInternal( $curParams ); |
91 | 91 | |
92 | 92 | $this->handleErrorAndWarnings( $res ); |
93 | - $sets[] = $res; |
|
93 | + $sets[ ] = $res; |
|
94 | 94 | |
95 | 95 | $finished = true; |
96 | 96 | if ( isset( $res->continue ) ) { |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | * @param array $params |
109 | 109 | * @return \stdClass |
110 | 110 | */ |
111 | - private function makeRequestInternal( array $params ) : \stdClass { |
|
111 | + private function makeRequestInternal ( array $params ) : \stdClass { |
|
112 | 112 | if ( $this->method === 'POST' ) { |
113 | - $params['maxlag'] = self::MAXLAG; |
|
113 | + $params[ 'maxlag' ] = self::MAXLAG; |
|
114 | 114 | } |
115 | 115 | $params = http_build_query( $params ); |
116 | 116 | |
@@ -126,17 +126,17 @@ discard block |
||
126 | 126 | * @param string $params |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - abstract protected function reallyMakeRequest( string $params ) : string; |
|
129 | + abstract protected function reallyMakeRequest ( string $params ) : string; |
|
130 | 130 | |
131 | 131 | /** |
132 | 132 | * After a request, set cookies for the next ones |
133 | 133 | * |
134 | 134 | * @param array $cookies |
135 | 135 | */ |
136 | - protected function setCookies( array $cookies ) { |
|
136 | + protected function setCookies ( array $cookies ) { |
|
137 | 137 | foreach ( $cookies as $cookie ) { |
138 | 138 | $bits = explode( ';', $cookie ); |
139 | - list( $name, $value ) = explode( '=', $bits[0] ); |
|
139 | + list( $name, $value ) = explode( '=', $bits[ 0 ] ); |
|
140 | 140 | self::$cookiesToSet[ $name ] = $value; |
141 | 141 | } |
142 | 142 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param \stdClass $res |
148 | 148 | * @return APIRequestException |
149 | 149 | */ |
150 | - private function getException( \stdClass $res ) : APIRequestException { |
|
150 | + private function getException ( \stdClass $res ) : APIRequestException { |
|
151 | 151 | switch ( $res->error->code ) { |
152 | 152 | case 'missingtitle': |
153 | 153 | $ex = new MissingPageException; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param \stdClass $res |
171 | 171 | * @throws APIRequestException |
172 | 172 | */ |
173 | - protected function handleErrorAndWarnings( \stdClass $res ) { |
|
173 | + protected function handleErrorAndWarnings ( \stdClass $res ) { |
|
174 | 174 | if ( isset( $res->error ) ) { |
175 | 175 | throw $this->getException( $res ); |
176 | 176 | } elseif ( isset( $res->warnings ) ) { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | * @param \stdClass[] $sets |
187 | 187 | * @return \stdClass |
188 | 188 | */ |
189 | - private function mergeSets( array $sets ) : \stdClass { |
|
189 | + private function mergeSets ( array $sets ) : \stdClass { |
|
190 | 190 | // Use the first set as template |
191 | 191 | $ret = array_shift( $sets ); |
192 | 192 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * @param array|\stdClass $second |
204 | 204 | * @return array|\stdClass array |
205 | 205 | */ |
206 | - private function recursiveMerge( $first, $second ) { |
|
206 | + private function recursiveMerge ( $first, $second ) { |
|
207 | 207 | $ret = $first; |
208 | 208 | if ( is_array( $second ) ) { |
209 | 209 | $ret = is_array( $first ) ? array_merge_recursive( $first, $second ) : $second; |
@@ -221,14 +221,14 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return array |
223 | 223 | */ |
224 | - protected function getHeaders() :array { |
|
224 | + protected function getHeaders () :array { |
|
225 | 225 | $ret = self::HEADERS; |
226 | 226 | if ( self::$cookiesToSet ) { |
227 | - $cookies = []; |
|
227 | + $cookies = [ ]; |
|
228 | 228 | foreach ( self::$cookiesToSet as $cname => $cval ) { |
229 | - $cookies[] = trim( "$cname=$cval" ); |
|
229 | + $cookies[ ] = trim( "$cname=$cval" ); |
|
230 | 230 | } |
231 | - $ret[] = 'Cookie: ' . implode( '; ', $cookies ); |
|
231 | + $ret[ ] = 'Cookie: ' . implode( '; ', $cookies ); |
|
232 | 232 | } |
233 | 233 | return $ret; |
234 | 234 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | * @param array $headers |
240 | 240 | * @return string |
241 | 241 | */ |
242 | - protected function buildHeadersString( array $headers ) : string { |
|
242 | + protected function buildHeadersString ( array $headers ) : string { |
|
243 | 243 | $ret = ''; |
244 | 244 | foreach ( $headers as $header ) { |
245 | 245 | $ret .= "$header\r\n"; |
@@ -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->getOpt( 'main-page-title' ), 2 )[1]; |
|
71 | + $unprefixedTitle = explode( ':', $this->getOpt( '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\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 | * Entry point for the bot, called by CLI |
4 | 4 | */ |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | /* URL (for debugging purpose) */ |
41 | 41 | $urlParam = getopt( '', [ 'force-url:' ] ); |
42 | -$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php'; |
|
42 | +$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php'; |
|
43 | 43 | |
44 | 44 | define( 'DEFAULT_URL', $url ); |
45 | 45 | define( 'META_URL', 'https://meta.wikimedia.org/w/api.php' ); |
@@ -93,9 +93,9 @@ discard block |
||
93 | 93 | |
94 | 94 | if ( count( $taskOpts ) === 2 ) { |
95 | 95 | throw new InvalidArgumentException( 'Cannot specify both task and subtask.' ); |
96 | -} elseif ( isset( $taskOpts['task'] ) ) { |
|
96 | +} elseif ( isset( $taskOpts[ 'task' ] ) ) { |
|
97 | 97 | $bot->runTask( $taskOpts[ 'task' ] ); |
98 | -} elseif ( isset( $taskOpts['subtask'] ) ) { |
|
98 | +} elseif ( isset( $taskOpts[ 'subtask' ] ) ) { |
|
99 | 99 | $bot->runSubtask( $taskOpts[ 'subtask' ] ); |
100 | 100 | } else { |
101 | 101 | $bot->runAll(); |
@@ -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 = $this->getPage( $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,12 +106,12 @@ 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 = $this->getPage( $this->getOpt( 'admins-list-title' ) ); |
112 | 112 | $newContent = $adminsPage->getContent(); |
113 | 113 | |
114 | - $riconfNames = $removeNames = []; |
|
114 | + $riconfNames = $removeNames = [ ]; |
|
115 | 115 | foreach ( $outcomes as $username => $confirmed ) { |
116 | 116 | $user = new User( $username, $this->getController() ); |
117 | 117 | $userReg = $user->getRegex(); |
@@ -123,10 +123,10 @@ discard block |
||
123 | 123 | '${1}' . date( 'Ymd' ) . '|' . $nextDate . '$2', |
124 | 124 | $newContent |
125 | 125 | ); |
126 | - $riconfNames[] = $username; |
|
126 | + $riconfNames[ ] = $username; |
|
127 | 127 | } else { |
128 | 128 | $newContent = preg_replace( $reg, '', $newContent ); |
129 | - $removeNames[] = $username; |
|
129 | + $removeNames[ ] = $username; |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
@@ -149,12 +149,12 @@ discard block |
||
149 | 149 | * @param User $user |
150 | 150 | * @return int |
151 | 151 | */ |
152 | - private function getNextTs( User $user ) : int { |
|
152 | + private function getNextTs ( User $user ) : int { |
|
153 | 153 | $groups = $user->getGroupsWithDates(); |
154 | - if ( isset( $groups['override-perm'] ) ) { |
|
154 | + if ( isset( $groups[ 'override-perm' ] ) ) { |
|
155 | 155 | $date = \DateTime::createFromFormat( |
156 | 156 | 'd/m/Y', |
157 | - $groups['override-perm'] . '/' . date( 'Y' ) |
|
157 | + $groups[ 'override-perm' ] . '/' . date( 'Y' ) |
|
158 | 158 | ); |
159 | 159 | if ( $date < new \DateTime ) { |
160 | 160 | $date->modify( '+1 year' ); |
@@ -163,8 +163,8 @@ discard block |
||
163 | 163 | } else { |
164 | 164 | $ts = PageBotList::getValidFlagTimestamp( $groups ); |
165 | 165 | $res = strtotime( date( 'Y', strtotime( '+1 year' ) ) . date( '-m-d', $ts ) ); |
166 | - if ( isset( $groups['override'] ) ) { |
|
167 | - $date = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] ); |
|
166 | + if ( isset( $groups[ 'override' ] ) ) { |
|
167 | + $date = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] ); |
|
168 | 168 | if ( $date > new \DateTime ) { |
169 | 169 | $res = $date->getTimestamp(); |
170 | 170 | } |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | /** |
177 | 177 | * @param bool[] $outcomes |
178 | 178 | */ |
179 | - protected function updateCUList( array $outcomes ) { |
|
179 | + protected function updateCUList ( array $outcomes ) { |
|
180 | 180 | $this->getLogger()->info( 'Updating CU list.' ); |
181 | 181 | $cuList = $this->getPage( $this->getOpt( 'cu-list-title' ) ); |
182 | 182 | $newContent = $cuList->getContent(); |
183 | 183 | |
184 | - $riconfNames = $removeNames = []; |
|
184 | + $riconfNames = $removeNames = [ ]; |
|
185 | 185 | foreach ( $outcomes as $user => $confirmed ) { |
186 | 186 | $userReg = ( new User( $user, $this->getController() ) )->getRegex(); |
187 | 187 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
188 | 188 | if ( $confirmed ) { |
189 | 189 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
190 | - $riconfNames[] = $user; |
|
190 | + $riconfNames[ ] = $user; |
|
191 | 191 | } else { |
192 | 192 | $newContent = preg_replace( $reg, '', $newContent ); |
193 | - $removeNames[] = $user; |
|
193 | + $removeNames[ ] = $user; |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | * @param PageRiconferma[] $pages |
215 | 215 | * @return bool[] |
216 | 216 | */ |
217 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
218 | - $ret = []; |
|
217 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
218 | + $ret = [ ]; |
|
219 | 219 | foreach ( $pages as $page ) { |
220 | 220 | $user = $page->getUser(); |
221 | 221 | 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\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 | $failed = $this->getFailures(); |
21 | 21 | if ( !$failed ) { |
22 | 22 | return TaskResult::STATUS_NOTHING; |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return PageRiconferma[] |
40 | 40 | */ |
41 | - private function getFailures() : array { |
|
42 | - $ret = []; |
|
41 | + private function getFailures () : array { |
|
42 | + $ret = [ ]; |
|
43 | 43 | $allPages = $this->getDataProvider()->getPagesToClose(); |
44 | 44 | foreach ( $allPages as $page ) { |
45 | 45 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
46 | - $ret[] = $page; |
|
46 | + $ret[ ] = $page; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | return $ret; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @param User[] $users |
54 | 54 | */ |
55 | - protected function updateBurList( array $users ) { |
|
55 | + protected function updateBurList ( array $users ) { |
|
56 | 56 | $this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) ); |
57 | 57 | $remList = Element::regexFromArray( $users ); |
58 | 58 | $burList = $this->getPage( $this->getOpt( 'bur-list-title' ) ); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param PageRiconferma[] $pages |
77 | 77 | */ |
78 | - protected function requestRemoval( array $pages ) { |
|
78 | + protected function requestRemoval ( array $pages ) { |
|
79 | 79 | $this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) ); |
80 | 80 | |
81 | 81 | $metaController = $this->getController()->cloneWithDomain( META_URL ); |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @param PageRiconferma[] $pages |
114 | 114 | */ |
115 | - protected function updateAnnunci( array $pages ) { |
|
115 | + protected function updateAnnunci ( array $pages ) { |
|
116 | 116 | $this->getLogger()->info( 'Updating annunci' ); |
117 | 117 | $section = 1; |
118 | 118 | |
119 | - $names = []; |
|
119 | + $names = [ ]; |
|
120 | 120 | $text = ''; |
121 | 121 | foreach ( $pages as $page ) { |
122 | 122 | $user = $page->getUser()->getName(); |
123 | - $names[] = $user; |
|
123 | + $names[ ] = $user; |
|
124 | 124 | $text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text(); |
125 | 125 | } |
126 | 126 | |
@@ -152,16 +152,16 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param PageRiconferma[] $pages |
154 | 154 | */ |
155 | - protected function updateUltimeNotizie( array $pages ) { |
|
155 | + protected function updateUltimeNotizie ( array $pages ) { |
|
156 | 156 | $this->getLogger()->info( 'Updating ultime notizie' ); |
157 | 157 | $notiziePage = $this->getPage( $this->getOpt( 'ultimenotizie-page-title' ) ); |
158 | 158 | |
159 | - $names = []; |
|
159 | + $names = [ ]; |
|
160 | 160 | $text = ''; |
161 | 161 | $msg = $this->msg( 'ultimenotizie-text' ); |
162 | 162 | foreach ( $pages as $page ) { |
163 | 163 | $user = $page->getUser()->getName(); |
164 | - $names[] = $user; |
|
164 | + $names[ ] = $user; |
|
165 | 165 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
166 | 166 | } |
167 | 167 | |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | * @param PageRiconferma[] $pages |
191 | 191 | * @return User[] |
192 | 192 | */ |
193 | - private function getFailedBureaucrats( array $pages ) : array { |
|
194 | - $ret = []; |
|
193 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
194 | + $ret = [ ]; |
|
195 | 195 | foreach ( $pages as $page ) { |
196 | 196 | $user = $page->getUser(); |
197 | 197 | if ( $user->inGroup( 'bureaucrat' ) ) { |
198 | - $ret[] = $user; |
|
198 | + $ret[ ] = $user; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | return $ret; |