@@ -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 | |
@@ -11,12 +11,12 @@ discard block |
||
11 | 11 | /** @var self */ |
12 | 12 | private static $instance; |
13 | 13 | /** @var array */ |
14 | - private $opts = []; |
|
14 | + private $opts = [ ]; |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Use self::init() and self::getInstance() |
18 | 18 | */ |
19 | - private function __construct() { |
|
19 | + private function __construct () { |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param array $confValues |
26 | 26 | * @throws ConfigException |
27 | 27 | */ |
28 | - public static function init( array $confValues ) : void { |
|
28 | + public static function init ( array $confValues ) : void { |
|
29 | 29 | if ( self::$instance ) { |
30 | 30 | throw new ConfigException( 'Config was already initialized' ); |
31 | 31 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param string $key |
45 | 45 | * @param mixed $value |
46 | 46 | */ |
47 | - protected function set( string $key, $value ) : void { |
|
47 | + protected function set ( string $key, $value ) : void { |
|
48 | 48 | $this->opts[ $key ] = $value; |
49 | 49 | } |
50 | 50 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @return self |
55 | 55 | * @throws ConfigException |
56 | 56 | */ |
57 | - public static function getInstance() : self { |
|
57 | + public static function getInstance () : self { |
|
58 | 58 | if ( !self::$instance ) { |
59 | 59 | throw new ConfigException( 'Config not yet initialized' ); |
60 | 60 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return mixed |
69 | 69 | * @throws ConfigException |
70 | 70 | */ |
71 | - public function get( string $opt ) { |
|
71 | + public function get ( string $opt ) { |
|
72 | 72 | if ( !isset( $this->opts[ $opt ] ) ) { |
73 | 73 | throw new ConfigException( "Config option '$opt' not set." ); |
74 | 74 | } |
@@ -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 ) : void { |
|
55 | + protected function updateBurList ( array $users ) : void { |
|
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 ) : void { |
|
78 | + protected function requestRemoval ( array $pages ) : void { |
|
79 | 79 | $this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) ); |
80 | 80 | |
81 | 81 | $metaWiki = $this->getWikiGroup()->getCentralWiki(); |
@@ -115,15 +115,15 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @param PageRiconferma[] $pages |
117 | 117 | */ |
118 | - protected function updateAnnunci( array $pages ) : void { |
|
118 | + protected function updateAnnunci ( array $pages ) : void { |
|
119 | 119 | $this->getLogger()->info( 'Updating annunci' ); |
120 | 120 | $section = 1; |
121 | 121 | |
122 | - $names = []; |
|
122 | + $names = [ ]; |
|
123 | 123 | $text = ''; |
124 | 124 | foreach ( $pages as $page ) { |
125 | 125 | $user = $page->getUserName(); |
126 | - $names[] = $user; |
|
126 | + $names[ ] = $user; |
|
127 | 127 | $text .= $this->msg( 'annunci-text' )->params( [ '$user' => $user ] )->text(); |
128 | 128 | } |
129 | 129 | |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @param PageRiconferma[] $pages |
157 | 157 | */ |
158 | - protected function updateUltimeNotizie( array $pages ) : void { |
|
158 | + protected function updateUltimeNotizie ( array $pages ) : void { |
|
159 | 159 | $this->getLogger()->info( 'Updating ultime notizie' ); |
160 | 160 | $notiziePage = $this->getPage( $this->getOpt( 'ultimenotizie-page-title' ) ); |
161 | 161 | |
162 | - $names = []; |
|
162 | + $names = [ ]; |
|
163 | 163 | $text = ''; |
164 | 164 | $msg = $this->msg( 'ultimenotizie-text' ); |
165 | 165 | foreach ( $pages as $page ) { |
166 | 166 | $user = $page->getUserName(); |
167 | - $names[] = $user; |
|
167 | + $names[ ] = $user; |
|
168 | 168 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
169 | 169 | } |
170 | 170 | |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | * @param PageRiconferma[] $pages |
194 | 194 | * @return User[] |
195 | 195 | */ |
196 | - private function getFailedBureaucrats( array $pages ) : array { |
|
197 | - $ret = []; |
|
196 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
197 | + $ret = [ ]; |
|
198 | 198 | foreach ( $pages as $page ) { |
199 | 199 | $user = $this->getUser( $page->getUserName() ); |
200 | 200 | if ( $user->inGroup( 'bureaucrat' ) ) { |
201 | - $ret[] = $user; |
|
201 | + $ret[ ] = $user; |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | return $ret; |
@@ -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\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 ) { |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | * @param PageRiconferma[] $pages |
37 | 37 | * @see OpenUpdates::addToVotazioni() |
38 | 38 | */ |
39 | - protected function updateVotazioni( array $pages ) : void { |
|
39 | + protected function updateVotazioni ( array $pages ) : void { |
|
40 | 40 | $this->getLogger()->info( |
41 | 41 | 'Updating votazioni: ' . implode( ', ', $pages ) |
42 | 42 | ); |
43 | 43 | $votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) ); |
44 | 44 | |
45 | - $users = []; |
|
45 | + $users = [ ]; |
|
46 | 46 | foreach ( $pages as $page ) { |
47 | - $users[] = $this->getUser( $page->getUserName() ); |
|
47 | + $users[ ] = $this->getUser( $page->getUserName() ); |
|
48 | 48 | } |
49 | 49 | $usersReg = Element::regexFromArray( $users, '!' ); |
50 | 50 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array $pages |
66 | 66 | * @see OpenUpdates::addToNews() |
67 | 67 | */ |
68 | - protected function updateNews( array $pages ) : void { |
|
68 | + protected function updateNews ( array $pages ) : void { |
|
69 | 69 | $simpleAmount = $voteAmount = 0; |
70 | 70 | foreach ( $pages as $page ) { |
71 | 71 | if ( $page->isVote() ) { |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | $simpleMatches = $newsPage->getMatch( $simpleReg ); |
86 | 86 | $voteMatches = $newsPage->getMatch( $voteReg ); |
87 | 87 | |
88 | - $newSimp = ( (int)$simpleMatches[2] - $simpleAmount ) ?: ''; |
|
89 | - $newVote = ( (int)$voteMatches[2] - $voteAmount ) ?: ''; |
|
88 | + $newSimp = ( (int)$simpleMatches[ 2 ] - $simpleAmount ) ?: ''; |
|
89 | + $newVote = ( (int)$voteMatches[ 2 ] - $voteAmount ) ?: ''; |
|
90 | 90 | $newContent = preg_replace( $simpleReg, '${1}' . $newSimp, $newsPage->getContent() ); |
91 | 91 | $newContent = preg_replace( $voteReg, '${1}' . $newVote, $newContent ); |
92 | 92 | |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @param bool[] $outcomes |
106 | 106 | */ |
107 | - protected function updateAdminList( array $outcomes ) : void { |
|
107 | + protected function updateAdminList ( array $outcomes ) : void { |
|
108 | 108 | $this->getLogger()->info( 'Updating admin list' ); |
109 | 109 | $adminsPage = $this->getPage( $this->getOpt( 'admins-list-title' ) ); |
110 | 110 | $newContent = $adminsPage->getContent(); |
111 | 111 | |
112 | - $riconfNames = $removeNames = []; |
|
112 | + $riconfNames = $removeNames = [ ]; |
|
113 | 113 | foreach ( $outcomes as $username => $confirmed ) { |
114 | 114 | $user = $this->getUser( $username ); |
115 | 115 | $userReg = $user->getRegex( '!' ); |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | '${1}{{subst:#timel:Ymd}}|' . $nextDate . '$2', |
125 | 125 | $newContent |
126 | 126 | ); |
127 | - $riconfNames[] = $username; |
|
127 | + $riconfNames[ ] = $username; |
|
128 | 128 | } else { |
129 | 129 | $newContent = preg_replace( $reg, '', $newContent ); |
130 | - $removeNames[] = $username; |
|
130 | + $removeNames[ ] = $username; |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -147,21 +147,21 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * @param bool[] $outcomes |
149 | 149 | */ |
150 | - protected function updateCUList( array $outcomes ) : void { |
|
150 | + protected function updateCUList ( array $outcomes ) : void { |
|
151 | 151 | $this->getLogger()->info( 'Updating CU list.' ); |
152 | 152 | $cuList = $this->getPage( $this->getOpt( 'cu-list-title' ) ); |
153 | 153 | $newContent = $cuList->getContent(); |
154 | 154 | |
155 | - $riconfNames = $removeNames = []; |
|
155 | + $riconfNames = $removeNames = [ ]; |
|
156 | 156 | foreach ( $outcomes as $user => $confirmed ) { |
157 | 157 | $userReg = $this->getUser( $user )->getRegex( '!' ); |
158 | 158 | $reg = "!(\{\{ *Checkuser *\| *$userReg *\|[^}]+\| *)[\w \d]+(}}.*\n)!"; |
159 | 159 | if ( $confirmed ) { |
160 | 160 | $newContent = preg_replace( $reg, '${1}{{subst:#time:j F Y}}$2', $newContent ); |
161 | - $riconfNames[] = $user; |
|
161 | + $riconfNames[ ] = $user; |
|
162 | 162 | } else { |
163 | 163 | $newContent = preg_replace( $reg, '', $newContent ); |
164 | - $removeNames[] = $user; |
|
164 | + $removeNames[ ] = $user; |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param PageRiconferma[] $pages |
186 | 186 | * @return bool[] |
187 | 187 | */ |
188 | - private function getGroupOutcomes( string $group, array $pages ) : array { |
|
189 | - $ret = []; |
|
188 | + private function getGroupOutcomes ( string $group, array $pages ) : array { |
|
189 | + $ret = [ ]; |
|
190 | 190 | foreach ( $pages as $page ) { |
191 | 191 | $user = $this->getUser( $page->getUserName() ); |
192 | 192 | 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,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,12 +36,12 @@ 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 | - $donePages[] = $page; |
|
44 | + $donePages[ ] = $page; |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @param PageRiconferma $page |
61 | 61 | */ |
62 | - protected function openVote( PageRiconferma $page ) : void { |
|
62 | + protected function openVote ( PageRiconferma $page ) : void { |
|
63 | 63 | $this->getLogger()->info( "Starting vote on $page" ); |
64 | 64 | |
65 | 65 | $content = $page->getContent(); |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | * @see SimpleUpdates::updateVotazioni() |
99 | 99 | * @see OpenUpdates::addToVotazioni() |
100 | 100 | */ |
101 | - protected function updateVotazioni( array $pages ) : void { |
|
101 | + protected function updateVotazioni ( array $pages ) : void { |
|
102 | 102 | $votePage = $this->getPage( $this->getOpt( 'vote-page-title' ) ); |
103 | 103 | |
104 | - $users = []; |
|
104 | + $users = [ ]; |
|
105 | 105 | foreach ( $pages as $page ) { |
106 | - $users[] = $this->getUser( $page->getUserName() ); |
|
106 | + $users[ ] = $this->getUser( $page->getUserName() ); |
|
107 | 107 | } |
108 | 108 | $usersReg = Element::regexFromArray( $users, '!' ); |
109 | 109 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @see SimpleUpdates::updateNews() |
142 | 142 | * @see OpenUpdates::addToNews() |
143 | 143 | */ |
144 | - protected function updateNews( int $amount ) : void { |
|
144 | + protected function updateNews ( int $amount ) : void { |
|
145 | 145 | $this->getLogger()->info( "Turning $amount pages into votes" ); |
146 | 146 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
147 | 147 | |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | throw new TaskException( 'Param "voto" not found in news page' ); |
157 | 157 | } |
158 | 158 | |
159 | - $newTac = ( (int)$newsPage->getMatch( $regTac )[2] - $amount ) ?: ''; |
|
160 | - $newVot = ( (int)$newsPage->getMatch( $regVot )[2] + $amount ) ?: ''; |
|
159 | + $newTac = ( (int)$newsPage->getMatch( $regTac )[ 2 ] - $amount ) ?: ''; |
|
160 | + $newVot = ( (int)$newsPage->getMatch( $regVot )[ 2 ] + $amount ) ?: ''; |
|
161 | 161 | |
162 | 162 | $newContent = preg_replace( $regTac, '${1}' . $newTac, $content ); |
163 | 163 | $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 | |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @inheritDoc |
20 | 20 | */ |
21 | - protected function getSubtasksMap(): array { |
|
21 | + protected function getSubtasksMap (): array { |
|
22 | 22 | // Everything is done here. |
23 | - return []; |
|
23 | + return [ ]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @inheritDoc |
28 | 28 | */ |
29 | - public function runInternal() : int { |
|
29 | + public function runInternal () : int { |
|
30 | 30 | $this->actualList = $this->getActualAdmins(); |
31 | 31 | $pageBotList = $this->getBotList(); |
32 | 32 | $this->botList = $pageBotList->getDecodedContent(); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @return array |
55 | 55 | */ |
56 | - protected function getActualAdmins() : array { |
|
56 | + protected function getActualAdmins () : array { |
|
57 | 57 | $params = [ |
58 | 58 | 'action' => 'query', |
59 | 59 | 'list' => 'allusers', |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @param \stdClass $data |
71 | 71 | * @return array |
72 | 72 | */ |
73 | - protected function extractAdmins( \stdClass $data ) : array { |
|
74 | - $ret = []; |
|
73 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
74 | + $ret = [ ]; |
|
75 | 75 | $blacklist = $this->getOpt( 'exclude-admins' ); |
76 | 76 | foreach ( $data->query->allusers as $u ) { |
77 | 77 | if ( in_array( $u->name, $blacklist, true ) ) { |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return array[] |
90 | 90 | */ |
91 | - protected function getMissingGroups() : array { |
|
92 | - $missing = []; |
|
91 | + protected function getMissingGroups () : array { |
|
92 | + $missing = [ ]; |
|
93 | 93 | foreach ( $this->actualList as $adm => $groups ) { |
94 | - $curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) ); |
|
94 | + $curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) ); |
|
95 | 95 | |
96 | 96 | foreach ( $curMissing as $group ) { |
97 | 97 | try { |
98 | 98 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
99 | 99 | } catch ( TaskException $e ) { |
100 | - $this->errors[] = $e->getMessage(); |
|
100 | + $this->errors[ ] = $e->getMessage(); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @return string |
113 | 113 | * @throws TaskException |
114 | 114 | */ |
115 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
115 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
116 | 116 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
117 | 117 | |
118 | 118 | $wiki = $this->getWiki(); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @param string $group |
148 | 148 | * @return string|null |
149 | 149 | */ |
150 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
150 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
151 | 151 | $ts = null; |
152 | 152 | foreach ( $data->query->logevents as $entry ) { |
153 | 153 | if ( |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @return array[] |
168 | 168 | */ |
169 | - protected function getExtraGroups() : array { |
|
170 | - $extra = []; |
|
169 | + protected function getExtraGroups () : array { |
|
170 | + $extra = [ ]; |
|
171 | 171 | foreach ( $this->botList as $name => $groups ) { |
172 | 172 | $groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ); |
173 | 173 | if ( !isset( $this->actualList[ $name ] ) ) { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param string[] $names |
184 | 184 | * @return \stdClass |
185 | 185 | */ |
186 | - private function getRenameEntries( array $names ) : \stdClass { |
|
186 | + private function getRenameEntries ( array $names ) : \stdClass { |
|
187 | 187 | $titles = array_map( static function ( $x ) { |
188 | 188 | return "Utente:$x"; |
189 | 189 | }, $names ); |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | * @param string[] $names |
208 | 208 | * @return string[] [ old_name => new_name ] |
209 | 209 | */ |
210 | - protected function getRenamedUsers( array $names ) : array { |
|
210 | + protected function getRenamedUsers ( array $names ) : array { |
|
211 | 211 | if ( !$names ) { |
212 | - return []; |
|
212 | + return [ ]; |
|
213 | 213 | } |
214 | 214 | $this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) ); |
215 | 215 | |
216 | 216 | $data = $this->getRenameEntries( $names ); |
217 | - $ret = []; |
|
217 | + $ret = [ ]; |
|
218 | 218 | foreach ( $data->query->logevents as $entry ) { |
219 | 219 | // 1 month is arbitrary |
220 | 220 | if ( strtotime( $entry->timestamp ) > strtotime( '-1 month' ) ) { |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | * @param array &$newContent |
233 | 233 | * @param array $removed |
234 | 234 | */ |
235 | - private function handleRenames( array &$newContent, array $removed ) : void { |
|
235 | + private function handleRenames ( array &$newContent, array $removed ) : void { |
|
236 | 236 | $renameMap = $this->getRenamedUsers( array_keys( $removed ) ); |
237 | 237 | foreach ( $removed as $oldName => $info ) { |
238 | 238 | if ( |
239 | 239 | array_key_exists( $oldName, $renameMap ) && |
240 | - array_key_exists( $renameMap[$oldName], $newContent ) |
|
240 | + array_key_exists( $renameMap[ $oldName ], $newContent ) |
|
241 | 241 | ) { |
242 | 242 | // This user was renamed! Add this name as alias, if they're still listed |
243 | 243 | $newName = $renameMap[ $oldName ]; |
244 | 244 | $this->getLogger()->info( "Found rename $oldName -> $newName" ); |
245 | - $aliases = array_unique( array_merge( $newContent[ $newName ]['aliases'], [ $oldName ] ) ); |
|
246 | - $newContent[ $newName ]['aliases'] = $aliases; |
|
245 | + $aliases = array_unique( array_merge( $newContent[ $newName ][ 'aliases' ], [ $oldName ] ) ); |
|
246 | + $newContent[ $newName ][ 'aliases' ] = $aliases; |
|
247 | 247 | // Transfer overrides to the new name. |
248 | 248 | $overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] ); |
249 | 249 | $newContent[ $newName ] = array_merge( $newContent[ $newName ], $overrides ); |
@@ -257,12 +257,12 @@ discard block |
||
257 | 257 | * @param array[] $extra |
258 | 258 | * @return string[] Removed users |
259 | 259 | */ |
260 | - private function handleExtraAndMissing( |
|
260 | + private function handleExtraAndMissing ( |
|
261 | 261 | array &$newContent, |
262 | 262 | array $missing, |
263 | 263 | array $extra |
264 | 264 | ) : array { |
265 | - $removed = []; |
|
265 | + $removed = [ ]; |
|
266 | 266 | foreach ( $newContent as $user => $groups ) { |
267 | 267 | if ( isset( $missing[ $user ] ) ) { |
268 | 268 | $newContent[ $user ] = array_merge( $groups, $missing[ $user ] ); |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) { |
273 | 273 | $newContent[ $user ] = $newGroups; |
274 | 274 | } else { |
275 | - $removed[$user] = $newContent[$user]; |
|
275 | + $removed[ $user ] = $newContent[ $user ]; |
|
276 | 276 | unset( $newContent[ $user ] ); |
277 | 277 | } |
278 | 278 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | * @param array[] $extra |
290 | 290 | * @return array[] |
291 | 291 | */ |
292 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
292 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
293 | 293 | $newContent = $this->botList; |
294 | 294 | |
295 | 295 | $removed = $this->handleExtraAndMissing( $newContent, $missing, $extra ); |
@@ -309,12 +309,12 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @param array[] &$newContent |
311 | 311 | */ |
312 | - protected function removeOverrides( array &$newContent ) : void { |
|
313 | - $removed = []; |
|
312 | + protected function removeOverrides ( array &$newContent ) : void { |
|
313 | + $removed = [ ]; |
|
314 | 314 | foreach ( $newContent as $user => $groups ) { |
315 | 315 | if ( PageBotList::isOverrideExpired( $groups ) ) { |
316 | 316 | unset( $newContent[ $user ][ 'override' ] ); |
317 | - $removed[] = $user; |
|
317 | + $removed[ ] = $user; |
|
318 | 318 | } |
319 | 319 | } |
320 | 320 |
@@ -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 | abstract class TaskBase extends ContextSource { |
17 | 17 | /** @var string[] */ |
18 | - protected $errors = []; |
|
18 | + protected $errors = [ ]; |
|
19 | 19 | /** @var TaskDataProvider */ |
20 | 20 | protected $dataProvider; |
21 | 21 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * @param MessageProvider $mp |
29 | 29 | * @param PageBotList $pbl |
30 | 30 | */ |
31 | - final public function __construct( |
|
31 | + final public function __construct ( |
|
32 | 32 | LoggerInterface $logger, |
33 | 33 | WikiGroup $wikiGroup, |
34 | 34 | TaskDataProvider $dataProvider, |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return TaskResult |
46 | 46 | */ |
47 | - final public function run() : TaskResult { |
|
47 | + final public function run () : TaskResult { |
|
48 | 48 | $class = ( new \ReflectionClass( $this ) )->getShortName(); |
49 | 49 | $opName = $this->getOperationName(); |
50 | 50 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return int One of the STATUS_* constants |
77 | 77 | */ |
78 | - abstract protected function runInternal() : int; |
|
78 | + abstract protected function runInternal () : int; |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * How this operation should be called in logs |
82 | 82 | * |
83 | 83 | * @return string |
84 | 84 | */ |
85 | - abstract public function getOperationName() : string; |
|
85 | + abstract public function getOperationName () : string; |
|
86 | 86 | |
87 | 87 | /** |
88 | 88 | * @return TaskDataProvider |
89 | 89 | */ |
90 | - protected function getDataProvider() : TaskDataProvider { |
|
90 | + protected function getDataProvider () : TaskDataProvider { |
|
91 | 91 | return $this->dataProvider; |
92 | 92 | } |
93 | 93 | } |
@@ -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 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @param MessageProvider $mp |
63 | 63 | * @param PageBotList $pbl |
64 | 64 | */ |
65 | - public function __construct( |
|
65 | + public function __construct ( |
|
66 | 66 | LoggerInterface $logger, |
67 | 67 | WikiGroup $wikiGroup, |
68 | 68 | MessageProvider $mp, |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK |
88 | 88 | * @return TaskResult |
89 | 89 | */ |
90 | - public function run( string $mode, string $name = null ) : TaskResult { |
|
90 | + public function run ( string $mode, string $name = null ) : TaskResult { |
|
91 | 91 | if ( $mode === self::MODE_COMPLETE ) { |
92 | 92 | return $this->runAllTasks(); |
93 | 93 | } elseif ( $name === null ) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return TaskResult |
104 | 104 | */ |
105 | - protected function runAllTasks() : TaskResult { |
|
105 | + protected function runAllTasks () : TaskResult { |
|
106 | 106 | $orderedList = [ |
107 | 107 | 'update-list', |
108 | 108 | 'start-new', |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param string $name |
125 | 125 | * @return TaskResult |
126 | 126 | */ |
127 | - protected function runTask( string $name ) : TaskResult { |
|
127 | + protected function runTask ( string $name ) : TaskResult { |
|
128 | 128 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
129 | 129 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
130 | 130 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param string $name |
139 | 139 | * @return TaskResult |
140 | 140 | */ |
141 | - protected function runSubtask( string $name ) : TaskResult { |
|
141 | + protected function runSubtask ( string $name ) : TaskResult { |
|
142 | 142 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
143 | 143 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
144 | 144 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $name |
154 | 154 | * @return Task |
155 | 155 | */ |
156 | - private function getTaskInstance( string $name ) : Task { |
|
156 | + private function getTaskInstance ( string $name ) : Task { |
|
157 | 157 | $class = self::TASKS_MAP[ $name ]; |
158 | 158 | /** @var Task $ret */ |
159 | 159 | $ret = new $class( |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @param string $class |
173 | 173 | * @return Subtask |
174 | 174 | */ |
175 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
175 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
176 | 176 | /** @var Subtask $ret */ |
177 | 177 | $ret = new $class( |
178 | 178 | $this->logger, |
@@ -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 | |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | /** |
10 | 10 | * @param string $domain |
11 | 11 | */ |
12 | - public function __construct( string $domain ) { |
|
12 | + public function __construct ( string $domain ) { |
|
13 | 13 | $this->domain = $domain; |
14 | 14 | } |
15 | 15 | |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @param array $params |
18 | 18 | * @return RequestBase |
19 | 19 | */ |
20 | - public function newFromParams( array $params ) : RequestBase { |
|
20 | + public function newFromParams ( array $params ) : RequestBase { |
|
21 | 21 | if ( extension_loaded( 'curl' ) ) { |
22 | 22 | $ret = new CurlRequest( $params, $this->domain ); |
23 | 23 | } else { |