@@ -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\Task\Subtask; |
4 | 4 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | /** |
14 | 14 | * @inheritDoc |
15 | 15 | */ |
16 | - public function runInternal() : int { |
|
16 | + public function runInternal () : int { |
|
17 | 17 | $pages = $this->getDataProvider()->getPagesToClose(); |
18 | 18 | |
19 | 19 | if ( !$pages ) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @param PageRiconferma $page |
37 | 37 | */ |
38 | - protected function addVoteCloseText( PageRiconferma $page ) : void { |
|
38 | + protected function addVoteCloseText ( PageRiconferma $page ) : void { |
|
39 | 39 | $content = $page->getContent(); |
40 | 40 | $beforeReg = '!è necessario ottenere una maggioranza .+ votanti\.!u'; |
41 | 41 | $newContent = preg_replace( $beforeReg, '$0' . "\n" . $page->getOutcomeText(), $content ); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param PageRiconferma $page |
51 | 51 | * @see CreatePages::updateBasePage() |
52 | 52 | */ |
53 | - protected function updateBasePage( PageRiconferma $page ) : void { |
|
53 | + protected function updateBasePage ( PageRiconferma $page ) : void { |
|
54 | 54 | $this->getLogger()->info( "Updating base page for $page" ); |
55 | 55 | |
56 | 56 | if ( $page->getNum() === 1 ) { |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $current = $basePage->getContent(); |
63 | 63 | |
64 | 64 | $outcomeText = ( $page->getOutcome() & PageRiconferma::OUTCOME_FAIL ) ? |
65 | - 'non riconfermato' : |
|
66 | - 'riconfermato'; |
|
65 | + 'non riconfermato' : 'riconfermato'; |
|
67 | 66 | $text = $page->isVote() ? "votazione di riconferma: $outcomeText" : 'riconferma tacita'; |
68 | 67 | |
69 | 68 | $newContent = preg_replace( '/^(votazione di )?riconferma in corso/m', $text, $current ); |
@@ -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,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 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @param PageRiconferma[] $pages |
194 | 194 | */ |
195 | - protected function updateTimeline( array $pages ) : void { |
|
195 | + protected function updateTimeline ( array $pages ) : void { |
|
196 | 196 | $this->getLogger()->info( 'Updating timeline' ); |
197 | 197 | $timelinePage = $this->getPage( $this->getOpt( 'timeline-page-title' ) ); |
198 | 198 | $content = $timelinePage->getContent(); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param PageRiconferma[] $pages |
222 | 222 | */ |
223 | - private function updateCronologia( array $pages ) : void { |
|
223 | + private function updateCronologia ( array $pages ) : void { |
|
224 | 224 | $this->getLogger()->info( 'Updating cronologia' ); |
225 | 225 | $timelinePage = $this->getPage( $this->getOpt( 'cronologia-page-title' ) ); |
226 | 226 | $content = $timelinePage->getContent(); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @param PageRiconferma[] $pages |
249 | 249 | */ |
250 | - private function blockOnPrivate( array $pages ) : void { |
|
250 | + private function blockOnPrivate ( array $pages ) : void { |
|
251 | 251 | $this->getLogger()->info( 'Blocking on private wiki: ' . implode( ', ', $pages ) ); |
252 | 252 | |
253 | 253 | $privWiki = $this->getWikiGroup()->getPrivateWiki(); |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | * @param PageRiconferma[] $pages |
265 | 265 | * @return User[] |
266 | 266 | */ |
267 | - private function getFailedBureaucrats( array $pages ) : array { |
|
268 | - $ret = []; |
|
267 | + private function getFailedBureaucrats ( array $pages ) : array { |
|
268 | + $ret = [ ]; |
|
269 | 269 | foreach ( $pages as $page ) { |
270 | 270 | $user = $this->getUser( $page->getUserName() ); |
271 | 271 | if ( $user->inGroup( 'bureaucrat' ) ) { |
272 | - $ret[] = $user; |
|
272 | + $ret[ ] = $user; |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | 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\Wiki; |
4 | 4 | |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param Wiki $centralWiki |
19 | 19 | * @param Wiki $privateWiki |
20 | 20 | */ |
21 | - public function __construct( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) { |
|
21 | + public function __construct ( Wiki $mainWiki, Wiki $centralWiki, Wiki $privateWiki ) { |
|
22 | 22 | $this->mainWiki = $mainWiki; |
23 | 23 | $this->centralWiki = $centralWiki; |
24 | 24 | $this->privateWiki = $privateWiki; |
@@ -27,21 +27,21 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @return Wiki |
29 | 29 | */ |
30 | - public function getMainWiki() : Wiki { |
|
30 | + public function getMainWiki () : Wiki { |
|
31 | 31 | return $this->mainWiki; |
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @return Wiki |
36 | 36 | */ |
37 | - public function getCentralWiki() : Wiki { |
|
37 | + public function getCentralWiki () : Wiki { |
|
38 | 38 | return $this->centralWiki; |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | 42 | * @return Wiki |
43 | 43 | */ |
44 | - public function getPrivateWiki() : Wiki { |
|
44 | + public function getPrivateWiki () : Wiki { |
|
45 | 45 | return $this->privateWiki; |
46 | 46 | } |
47 | 47 | } |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Wiki; |
4 | 4 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param LoggerInterface $logger |
37 | 37 | * @param RequestFactory $requestFactory |
38 | 38 | */ |
39 | - public function __construct( |
|
39 | + public function __construct ( |
|
40 | 40 | LoginInfo $li, |
41 | 41 | LoggerInterface $logger, |
42 | 42 | RequestFactory $requestFactory |
@@ -49,35 +49,35 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @return LoginInfo |
51 | 51 | */ |
52 | - public function getLoginInfo() : LoginInfo { |
|
52 | + public function getLoginInfo () : LoginInfo { |
|
53 | 53 | return $this->loginInfo; |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * @return RequestFactory |
58 | 58 | */ |
59 | - public function getRequestFactory() : RequestFactory { |
|
59 | + public function getRequestFactory () : RequestFactory { |
|
60 | 60 | return $this->requestFactory; |
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @param string $prefix |
65 | 65 | */ |
66 | - public function setPagePrefix( string $prefix ) : void { |
|
66 | + public function setPagePrefix ( string $prefix ) : void { |
|
67 | 67 | $this->pagePrefix = $prefix; |
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @param string $ident |
72 | 72 | */ |
73 | - public function setLocalUserIdentifier( string $ident ) : void { |
|
73 | + public function setLocalUserIdentifier ( string $ident ) : void { |
|
74 | 74 | $this->localUserIdentifier = $ident; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function getLocalUserIdentifier() : string { |
|
80 | + public function getLocalUserIdentifier () : string { |
|
81 | 81 | return $this->localUserIdentifier; |
82 | 82 | } |
83 | 83 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @param string $title |
86 | 86 | * @param int|null $section |
87 | 87 | */ |
88 | - private function logRead( string $title, int $section = null ) : void { |
|
88 | + private function logRead ( string $title, int $section = null ) : void { |
|
89 | 89 | $fullTitle = $this->pagePrefix . $title; |
90 | 90 | $msg = "Retrieving content of $fullTitle" . ( $section !== null ? ", section $section" : '' ); |
91 | 91 | $this->logger->info( $msg ); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @throws MissingPageException |
101 | 101 | * @throws MissingSectionException |
102 | 102 | */ |
103 | - public function getPageContent( string $title, int $section = null ) : string { |
|
103 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
104 | 104 | $this->logRead( $title, $section ); |
105 | 105 | $params = [ |
106 | 106 | 'action' => 'query', |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | ]; |
112 | 112 | |
113 | 113 | if ( $section !== null ) { |
114 | - $params['rvsection'] = $section; |
|
114 | + $params[ 'rvsection' ] = $section; |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $req = $this->buildRequest( $params ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | throw new MissingPageException( $title ); |
122 | 122 | } |
123 | 123 | |
124 | - $mainSlot = $page->revisions[0]->slots->main; |
|
124 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
125 | 125 | |
126 | 126 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
127 | 127 | throw new MissingSectionException( $title, $section ); |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @param array $params |
136 | 136 | * @throws EditException |
137 | 137 | */ |
138 | - public function editPage( array $params ) : void { |
|
138 | + public function editPage ( array $params ) : void { |
|
139 | 139 | $this->login(); |
140 | 140 | |
141 | 141 | $params = [ |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | ] + $params; |
145 | 145 | |
146 | 146 | if ( BOT_EDITS === true ) { |
147 | - $params['bot'] = 1; |
|
147 | + $params[ 'bot' ] = 1; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | $res = $this->buildRequest( $params )->setPost()->execute(); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
163 | 163 | * @throws LoginException |
164 | 164 | */ |
165 | - public function login() : void { |
|
165 | + public function login () : void { |
|
166 | 166 | if ( $this->loginInfo === null ) { |
167 | 167 | throw new CannotLoginException( 'Missing login data' ); |
168 | 168 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | |
193 | 193 | $this->loggedIn = true; |
194 | 194 | // Clear tokens cache |
195 | - $this->tokens = []; |
|
195 | + $this->tokens = [ ]; |
|
196 | 196 | $this->logger->info( 'Login succeeded' ); |
197 | 197 | } |
198 | 198 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param string $type |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - public function getToken( string $type ) : string { |
|
205 | + public function getToken ( string $type ) : string { |
|
206 | 206 | if ( !isset( $this->tokens[ $type ] ) ) { |
207 | 207 | $params = [ |
208 | 208 | 'action' => 'query', |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | * @param string $title |
226 | 226 | * @return int |
227 | 227 | */ |
228 | - public function getPageCreationTS( string $title ) : int { |
|
228 | + public function getPageCreationTS ( string $title ) : int { |
|
229 | 229 | $params = [ |
230 | 230 | 'action' => 'query', |
231 | 231 | 'prop' => 'revisions', |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | |
239 | 239 | $res = $this->buildRequest( $params )->execute(); |
240 | 240 | $data = $res->query->pages; |
241 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
241 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | * @param string $title |
248 | 248 | * @param string $reason |
249 | 249 | */ |
250 | - public function protectPage( string $title, string $reason ) : void { |
|
250 | + public function protectPage ( string $title, string $reason ) : void { |
|
251 | 251 | $fullTitle = $this->pagePrefix . $title; |
252 | 252 | $this->logger->info( "Protecting page $fullTitle" ); |
253 | 253 | $this->login(); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | * @param string $username |
271 | 271 | * @param string $reason |
272 | 272 | */ |
273 | - public function blockUser( string $username, string $reason ) : void { |
|
273 | + public function blockUser ( string $username, string $reason ) : void { |
|
274 | 274 | $this->logger->info( "Blocking user $username" ); |
275 | 275 | $this->login(); |
276 | 276 | |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | * @param array $params |
297 | 297 | * @return RequestBase |
298 | 298 | */ |
299 | - private function buildRequest( array $params ) : RequestBase { |
|
299 | + private function buildRequest ( array $params ) : RequestBase { |
|
300 | 300 | return $this->requestFactory->newFromParams( $params ); |
301 | 301 | } |
302 | 302 | } |
@@ -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; |
4 | 4 | |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public static function isCLI() : bool { |
|
68 | + public static function isCLI () : bool { |
|
69 | 69 | return PHP_SAPI === 'cli'; |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Populate options and check for required ones |
74 | 74 | */ |
75 | - public function __construct() { |
|
75 | + public function __construct () { |
|
76 | 76 | $opts = getopt( self::SHORT_OPTS, self::LONG_OPTS ); |
77 | 77 | $this->checkRequiredOpts( $opts ); |
78 | 78 | $this->checkConflictingOpts( $opts ); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | /** |
84 | 84 | * @param array $opts |
85 | 85 | */ |
86 | - private function checkRequiredOpts( array $opts ) : void { |
|
86 | + private function checkRequiredOpts ( array $opts ) : void { |
|
87 | 87 | $missingOpts = array_diff( self::REQUIRED_OPTS, array_keys( $opts ) ); |
88 | 88 | if ( $missingOpts ) { |
89 | 89 | exit( 'Required options missing: ' . implode( ', ', $missingOpts ) ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param array $opts |
107 | 107 | */ |
108 | - private function checkConflictingOpts( array $opts ) : void { |
|
108 | + private function checkConflictingOpts ( array $opts ) : void { |
|
109 | 109 | $this->checkNotBothSet( $opts, 'password', 'use-password-file' ); |
110 | 110 | if ( array_key_exists( 'use-password-file', $opts ) && !file_exists( self::PASSWORD_FILE ) ) { |
111 | 111 | exit( 'Please create the password file (' . self::PASSWORD_FILE . ')' ); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $first |
127 | 127 | * @param string $second |
128 | 128 | */ |
129 | - private function checkNotBothSet( array $opts, string $first, string $second ) : void { |
|
129 | + private function checkNotBothSet ( array $opts, string $first, string $second ) : void { |
|
130 | 130 | if ( array_key_exists( $first, $opts ) && array_key_exists( $second, $opts ) ) { |
131 | 131 | exit( "Can only use one of '$first' and '$second'" ); |
132 | 132 | } |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * @param array &$opts |
137 | 137 | */ |
138 | - private function canonicalize( array &$opts ) : void { |
|
138 | + private function canonicalize ( array &$opts ) : void { |
|
139 | 139 | if ( array_key_exists( 'use-password-file', $opts ) ) { |
140 | 140 | $pw = trim( file_get_contents( self::PASSWORD_FILE ) ); |
141 | - $opts['password'] = $pw; |
|
142 | - unset( $opts['use-password-file'] ); |
|
141 | + $opts[ 'password' ] = $pw; |
|
142 | + unset( $opts[ 'use-password-file' ] ); |
|
143 | 143 | } |
144 | 144 | if ( array_key_exists( 'use-private-password-file', $opts ) ) { |
145 | 145 | $pw = trim( file_get_contents( self::PRIVATE_PASSWORD_FILE ) ); |
146 | - $opts['private-password'] = $pw; |
|
147 | - unset( $opts['use-private-password-file'] ); |
|
146 | + $opts[ 'private-password' ] = $pw; |
|
147 | + unset( $opts[ 'use-private-password-file' ] ); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -153,14 +153,14 @@ discard block |
||
153 | 153 | * @param mixed|null $default |
154 | 154 | * @return mixed |
155 | 155 | */ |
156 | - public function getOpt( string $opt, $default = null ) { |
|
157 | - return $this->opts[$opt] ?? $default; |
|
156 | + public function getOpt ( string $opt, $default = null ) { |
|
157 | + return $this->opts[ $opt ] ?? $default; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | 161 | * @return array Either [ 'task' => taskname ] or [ 'subtask' => subtaskname ] |
162 | 162 | */ |
163 | - public function getTaskOpt() : array { |
|
163 | + public function getTaskOpt () : array { |
|
164 | 164 | return array_intersect_key( |
165 | 165 | $this->opts, |
166 | 166 | [ 'task' => true, 'subtask' => true ] |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | /** |
171 | 171 | * @return string|null |
172 | 172 | */ |
173 | - public function getURL() : ?string { |
|
173 | + public function getURL () : ?string { |
|
174 | 174 | return $this->getOpt( 'force-url' ); |
175 | 175 | } |
176 | 176 | } |