@@ -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 @@ |
||
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 @@ |
||
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\Utils; |
4 | 4 | |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | * @param IRegexable ...$elements |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - public static function regexFromArray( |
|
13 | + public static function regexFromArray ( |
|
14 | 14 | string $delimiter = '/', |
15 | 15 | IRegexable ...$elements |
16 | 16 | ) : string { |
17 | - $bits = []; |
|
17 | + $bits = [ ]; |
|
18 | 18 | foreach ( $elements as $el ) { |
19 | - $bits[] = $el->getRegex( $delimiter ); |
|
19 | + $bits[ ] = $el->getRegex( $delimiter ); |
|
20 | 20 | } |
21 | 21 | return '(?:' . implode( '|', $bits ) . ')'; |
22 | 22 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Utils; |
4 | 4 | |
@@ -9,5 +9,5 @@ discard block |
||
9 | 9 | * @param string $delimiter |
10 | 10 | * @return string |
11 | 11 | */ |
12 | - public function getRegex( string $delimiter ) : string; |
|
12 | + public function getRegex ( string $delimiter ) : string; |
|
13 | 13 | } |
@@ -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 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param MessageProvider $mp |
37 | 37 | * @param PageBotList $pbl |
38 | 38 | */ |
39 | - public function __construct( |
|
39 | + public function __construct ( |
|
40 | 40 | LoggerInterface $logger, |
41 | 41 | WikiGroup $wikiGroup, |
42 | 42 | MessageProvider $mp, |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @return LoggerInterface |
54 | 54 | */ |
55 | - protected function getLogger() : LoggerInterface { |
|
55 | + protected function getLogger () : LoggerInterface { |
|
56 | 56 | return $this->logger; |
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
60 | 60 | * @inheritDoc |
61 | 61 | */ |
62 | - public function setLogger( LoggerInterface $logger ) : void { |
|
62 | + public function setLogger ( LoggerInterface $logger ) : void { |
|
63 | 63 | $this->logger = $logger; |
64 | 64 | } |
65 | 65 | |
@@ -69,21 +69,21 @@ discard block |
||
69 | 69 | * @param string $optname |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - protected function getOpt( string $optname ) { |
|
72 | + protected function getOpt ( string $optname ) { |
|
73 | 73 | return $this->getConfig()->get( $optname ); |
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @return Config |
78 | 78 | */ |
79 | - protected function getConfig() : Config { |
|
79 | + protected function getConfig () : Config { |
|
80 | 80 | return $this->config; |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
84 | 84 | * @param Config $cfg |
85 | 85 | */ |
86 | - protected function setConfig( Config $cfg ) : void { |
|
86 | + protected function setConfig ( Config $cfg ) : void { |
|
87 | 87 | $this->config = $cfg; |
88 | 88 | } |
89 | 89 | |
@@ -91,35 +91,35 @@ discard block |
||
91 | 91 | * Shorthand |
92 | 92 | * @return Wiki |
93 | 93 | */ |
94 | - protected function getWiki() : Wiki { |
|
94 | + protected function getWiki () : Wiki { |
|
95 | 95 | return $this->getWikiGroup()->getMainWiki(); |
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * @return WikiGroup |
100 | 100 | */ |
101 | - protected function getWikiGroup() : WikiGroup { |
|
101 | + protected function getWikiGroup () : WikiGroup { |
|
102 | 102 | return $this->wikiGroup; |
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * @param WikiGroup $wikiGroup |
107 | 107 | */ |
108 | - protected function setWikiGroup( WikiGroup $wikiGroup ) : void { |
|
108 | + protected function setWikiGroup ( WikiGroup $wikiGroup ) : void { |
|
109 | 109 | $this->wikiGroup = $wikiGroup; |
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
113 | 113 | * @return MessageProvider |
114 | 114 | */ |
115 | - protected function getMessageProvider() : MessageProvider { |
|
115 | + protected function getMessageProvider () : MessageProvider { |
|
116 | 116 | return $this->messageProvider; |
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * @param MessageProvider $mp |
121 | 121 | */ |
122 | - protected function setMessageProvider( MessageProvider $mp ) : void { |
|
122 | + protected function setMessageProvider ( MessageProvider $mp ) : void { |
|
123 | 123 | $this->messageProvider = $mp; |
124 | 124 | } |
125 | 125 | |
@@ -129,21 +129,21 @@ discard block |
||
129 | 129 | * @param string $key |
130 | 130 | * @return Message |
131 | 131 | */ |
132 | - protected function msg( string $key ) : Message { |
|
132 | + protected function msg ( string $key ) : Message { |
|
133 | 133 | return $this->messageProvider->getMessage( $key ); |
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
137 | 137 | * @return PageBotList |
138 | 138 | */ |
139 | - public function getBotList() : PageBotList { |
|
139 | + public function getBotList () : PageBotList { |
|
140 | 140 | return $this->pageBotList; |
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
144 | 144 | * @return RequestFactory |
145 | 145 | */ |
146 | - public function getRequestFactory() : RequestFactory { |
|
146 | + public function getRequestFactory () : RequestFactory { |
|
147 | 147 | return $this->getWiki()->getRequestFactory(); |
148 | 148 | } |
149 | 149 | |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @param string $title |
154 | 154 | * @return Page |
155 | 155 | */ |
156 | - protected function getPage( string $title ) : Page { |
|
156 | + protected function getPage ( string $title ) : Page { |
|
157 | 157 | return new Page( $title, $this->getWiki() ); |
158 | 158 | } |
159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param string $name |
164 | 164 | * @return User |
165 | 165 | */ |
166 | - protected function getUser( string $name ) : User { |
|
166 | + protected function getUser ( string $name ) : User { |
|
167 | 167 | $ui = $this->getBotList()->getUserInfo( $name ); |
168 | 168 | return new User( $ui, $this->getWiki() ); |
169 | 169 | } |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param Wiki $wiki |
21 | 21 | * @param string $msgTitle |
22 | 22 | */ |
23 | - public function __construct( Wiki $wiki, string $msgTitle ) { |
|
23 | + public function __construct ( Wiki $wiki, string $msgTitle ) { |
|
24 | 24 | $this->wiki = $wiki; |
25 | 25 | $this->msgTitle = $msgTitle; |
26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | /** |
29 | 29 | * @throws MessagesPageDoesNotExistException |
30 | 30 | */ |
31 | - private function grabWikiMessages() : void { |
|
31 | + private function grabWikiMessages () : void { |
|
32 | 32 | if ( self::$messages !== null ) { |
33 | 33 | return; |
34 | 34 | } |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | * @return Message |
46 | 46 | * @throws MessageNotFoundException |
47 | 47 | */ |
48 | - public function getMessage( string $key ) : Message { |
|
48 | + public function getMessage ( string $key ) : Message { |
|
49 | 49 | $this->grabWikiMessages(); |
50 | 50 | if ( !isset( self::$messages[ $key ] ) ) { |
51 | 51 | throw new MessageNotFoundException( "Message '$key' does not exist." ); |
52 | 52 | } |
53 | 53 | // @phan-suppress-next-line PhanTypeArraySuspiciousNullable |
54 | - return new Message( self::$messages[$key] ); |
|
54 | + return new Message( self::$messages[ $key ] ); |
|
55 | 55 | } |
56 | 56 | } |
@@ -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\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; |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return PageRiconferma[] |
43 | 43 | */ |
44 | - private function getFailures() : array { |
|
45 | - $ret = []; |
|
44 | + private function getFailures () : array { |
|
45 | + $ret = [ ]; |
|
46 | 46 | $allPages = $this->getDataProvider()->getPagesToClose(); |
47 | 47 | foreach ( $allPages as $page ) { |
48 | 48 | if ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) { |
49 | - $ret[] = $page; |
|
49 | + $ret[ ] = $page; |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | return $ret; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @param User[] $users |
57 | 57 | */ |
58 | - protected function updateBurList( array $users ) : void { |
|
58 | + protected function updateBurList ( array $users ) : void { |
|
59 | 59 | $this->getLogger()->info( 'Updating bur list. Removing: ' . implode( ', ', $users ) ); |
60 | 60 | $remList = RegexUtils::regexFromArray( '!', ...$users ); |
61 | 61 | $burList = $this->getPage( $this->getOpt( 'bur-list-title' ) ); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param PageRiconferma[] $pages |
80 | 80 | */ |
81 | - protected function requestRemoval( array $pages ) : void { |
|
81 | + protected function requestRemoval ( array $pages ) : void { |
|
82 | 82 | $this->getLogger()->info( 'Requesting flag removal for: ' . implode( ', ', $pages ) ); |
83 | 83 | |
84 | 84 | $metaWiki = $this->getWikiGroup()->getCentralWiki(); |
@@ -115,21 +115,21 @@ 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 | |
130 | 130 | /** @var string $curMonth */ |
131 | 131 | $curMonth = date( 'F' ); |
132 | - $month = ucfirst( Message::MONTHS[$curMonth] ); |
|
132 | + $month = ucfirst( Message::MONTHS[ $curMonth ] ); |
|
133 | 133 | |
134 | 134 | $annunciPage = $this->getPage( $this->getOpt( 'annunci-page-title' ) ); |
135 | 135 | $content = $annunciPage->getContent( $section ); |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param PageRiconferma[] $pages |
159 | 159 | */ |
160 | - protected function updateUltimeNotizie( array $pages ) : void { |
|
160 | + protected function updateUltimeNotizie ( array $pages ) : void { |
|
161 | 161 | $this->getLogger()->info( 'Updating ultime notizie' ); |
162 | 162 | $notiziePage = $this->getPage( $this->getOpt( 'ultimenotizie-page-title' ) ); |
163 | 163 | |
164 | - $names = []; |
|
164 | + $names = [ ]; |
|
165 | 165 | $text = ''; |
166 | 166 | $msg = $this->msg( 'ultimenotizie-text' ); |
167 | 167 | foreach ( $pages as $page ) { |
168 | 168 | $user = $page->getUserName(); |
169 | - $names[] = $user; |
|
169 | + $names[ ] = $user; |
|
170 | 170 | $text .= $msg->params( [ '$user' => $user, '$title' => $page->getTitle() ] )->text(); |
171 | 171 | } |
172 | 172 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param PageRiconferma[] $pages |
196 | 196 | */ |
197 | - protected function updateTimeline( array $pages ) : void { |
|
197 | + protected function updateTimeline ( array $pages ) : void { |
|
198 | 198 | $this->getLogger()->info( 'Updating timeline' ); |
199 | 199 | $timelinePage = $this->getPage( $this->getOpt( 'timeline-page-title' ) ); |
200 | 200 | $content = $timelinePage->getContent(); |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @param PageRiconferma[] $pages |
224 | 224 | */ |
225 | - private function updateCronologia( array $pages ) : void { |
|
225 | + private function updateCronologia ( array $pages ) : void { |
|
226 | 226 | $this->getLogger()->info( 'Updating cronologia' ); |
227 | 227 | $timelinePage = $this->getPage( $this->getOpt( 'cronologia-page-title' ) ); |
228 | 228 | $content = $timelinePage->getContent(); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param PageRiconferma[] $pages |
251 | 251 | */ |
252 | - private function blockOnPrivate( array $pages ) : void { |
|
252 | + private function blockOnPrivate ( array $pages ) : void { |
|
253 | 253 | $this->getLogger()->info( 'Blocking on private wiki: ' . implode( ', ', $pages ) ); |
254 | 254 | |
255 | 255 | $privWiki = $this->getWikiGroup()->getPrivateWiki(); |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | * @param PageRiconferma[] $pages |
267 | 267 | * @return User[] |
268 | 268 | */ |
269 | - private function getFailedBureaucrats( array $pages ) : array { |
|
270 | - $ret = []; |
|
269 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
270 | + $ret = [ ]; |
|
271 | 271 | foreach ( $pages as $page ) { |
272 | 272 | $user = $this->getUser( $page->getUserName() ); |
273 | 273 | if ( $user->inGroup( 'bureaucrat' ) ) { |
274 | - $ret[] = $user; |
|
274 | + $ret[ ] = $user; |
|
275 | 275 | } |
276 | 276 | } |
277 | 277 | return $ret; |