@@ -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; |
4 | 4 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @inheritDoc |
16 | 16 | */ |
17 | - public function runInternal() : int { |
|
17 | + public function runInternal () : int { |
|
18 | 18 | $orderedList = [ |
19 | 19 | 'create-pages', |
20 | 20 | 'open-updates', |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * @inheritDoc |
34 | 34 | */ |
35 | - protected function getSubtasksMap() : array { |
|
35 | + protected function getSubtasksMap () : array { |
|
36 | 36 | return [ |
37 | 37 | 'create-pages' => CreatePages::class, |
38 | 38 | 'open-updates' => OpenUpdates::class, |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Request; |
4 | 4 | |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @inheritDoc |
13 | 13 | * @throws APIRequestException |
14 | 14 | */ |
15 | - protected function reallyMakeRequest( string $params ) : string { |
|
15 | + protected function reallyMakeRequest ( string $params ) : string { |
|
16 | 16 | $curl = curl_init(); |
17 | 17 | if ( $curl === false ) { |
18 | 18 | throw new APIRequestException( 'Cannot open cURL handler.' ); |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * @internal Only used as CB for cURL (CURLOPT_HEADERFUNCTION) |
56 | 56 | * @suppress PhanUnreferencedPublicMethod,PhanUnusedPublicNoOverrideMethodParameter |
57 | 57 | */ |
58 | - public function headersHandler( $ch, string $header ) : int { |
|
58 | + public function headersHandler ( $ch, string $header ) : int { |
|
59 | 59 | $bits = explode( ':', $header, 2 ); |
60 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
61 | - $this->newCookies[] = $bits[1]; |
|
60 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
61 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return strlen( $header ); |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare( strict_types=1 ); |
|
1 | +<?php declare(strict_types=1); |
|
2 | 2 | |
3 | 3 | namespace BotRiconferme\Logger; |
4 | 4 | |
@@ -8,5 +8,5 @@ discard block |
||
8 | 8 | * Logger aware of flushing. Can be declared empty if the buffer is flushed immediately. |
9 | 9 | */ |
10 | 10 | interface IFlushingAwareLogger extends LoggerInterface { |
11 | - public function flush() : void; |
|
11 | + public function flush () : void; |
|
12 | 12 | } |
@@ -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 | */ |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | $type = current( array_keys( $taskOpt ) ); |
55 | 55 | try { |
56 | 56 | if ( $type === 'task' ) { |
57 | - $bot->runTask( $taskOpt['task'] ); |
|
57 | + $bot->runTask( $taskOpt[ 'task' ] ); |
|
58 | 58 | } elseif ( $type === 'subtask' ) { |
59 | - $bot->runSubtask( $taskOpt['subtask'] ); |
|
59 | + $bot->runSubtask( $taskOpt[ 'subtask' ] ); |
|
60 | 60 | } else { |
61 | 61 | $bot->runAll(); |
62 | 62 | } |
@@ -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()->getCreatedPages(); |
18 | 18 | |
19 | 19 | if ( !$pages ) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param PageRiconferma[] $pages |
37 | 37 | */ |
38 | - protected function addToMainPage( array $pages ) : void { |
|
38 | + protected function addToMainPage ( array $pages ) : void { |
|
39 | 39 | $this->getLogger()->info( |
40 | 40 | 'Adding the following to main: ' . implode( ', ', $pages ) |
41 | 41 | ); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param PageRiconferma[] $pages |
70 | 70 | */ |
71 | - protected function addToVotazioni( array $pages ) : void { |
|
71 | + protected function addToVotazioni ( array $pages ) : void { |
|
72 | 72 | $this->getLogger()->info( |
73 | 73 | 'Adding the following to votes: ' . implode( ', ', $pages ) |
74 | 74 | ); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param int $amount |
106 | 106 | * @throws TaskException |
107 | 107 | */ |
108 | - protected function addToNews( int $amount ) : void { |
|
108 | + protected function addToNews ( int $amount ) : void { |
|
109 | 109 | $this->getLogger()->info( "Increasing the news counter by $amount" ); |
110 | 110 | $newsPage = $this->getPage( $this->getOpt( 'news-page-title' ) ); |
111 | 111 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | $matches = $newsPage->getMatch( $reg ); |
120 | 120 | |
121 | - $newNum = (int)$matches[2] + $amount; |
|
121 | + $newNum = (int)$matches[ 2 ] + $amount; |
|
122 | 122 | $newContent = preg_replace( $reg, '${1}' . $newNum, $content ); |
123 | 123 | |
124 | 124 | $summary = $this->msg( 'news-page-summary' ) |
@@ -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 | $users = $this->getDataProvider()->getUsersToProcess(); |
21 | 21 | |
22 | 22 | if ( !$users ) { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param User $user |
37 | 37 | */ |
38 | - protected function processUser( User $user ) : void { |
|
38 | + protected function processUser ( User $user ) : void { |
|
39 | 39 | $this->getLogger()->info( "Processing user $user" ); |
40 | 40 | try { |
41 | 41 | $num = $this->getLastPageNum( $user ) + 1; |
@@ -70,14 +70,14 @@ discard block |
||
70 | 70 | * @return int |
71 | 71 | * @throws TaskException |
72 | 72 | */ |
73 | - protected function getLastPageNum( User $user ) : int { |
|
73 | + protected function getLastPageNum ( User $user ) : int { |
|
74 | 74 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
75 | 75 | |
76 | - $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1]; |
|
76 | + $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ]; |
|
77 | 77 | |
78 | 78 | $prefixes = [ "$unprefixedTitle/$user/" ]; |
79 | 79 | foreach ( $user->getAliases() as $alias ) { |
80 | - $prefixes[] = "$unprefixedTitle/$alias/"; |
|
80 | + $prefixes[ ] = "$unprefixedTitle/$alias/"; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | $params = [ |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | * @param string $title |
112 | 112 | * @param User $user |
113 | 113 | */ |
114 | - protected function createPage( string $title, User $user ) : void { |
|
114 | + protected function createPage ( string $title, User $user ) : void { |
|
115 | 115 | $this->getLogger()->info( "Creating page $title" ); |
116 | 116 | $groups = $user->getGroupsWithDates(); |
117 | 117 | $textParams = [ |
118 | 118 | '$user' => $user->getName(), |
119 | - '$date' => $groups['sysop'], |
|
120 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
121 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
119 | + '$date' => $groups[ 'sysop' ], |
|
120 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
121 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
122 | 122 | ]; |
123 | 123 | |
124 | 124 | $params = [ |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @param Page $basePage |
137 | 137 | * @param string $newText |
138 | 138 | */ |
139 | - protected function createBasePage( Page $basePage, string $newText ) : void { |
|
139 | + protected function createBasePage ( Page $basePage, string $newText ) : void { |
|
140 | 140 | $this->getLogger()->info( "Creating base page $basePage" ); |
141 | 141 | |
142 | 142 | $params = [ |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @param Page $basePage |
153 | 153 | * @param string $newText |
154 | 154 | */ |
155 | - protected function updateBasePage( Page $basePage, string $newText ) : void { |
|
155 | + protected function updateBasePage ( Page $basePage, string $newText ) : void { |
|
156 | 156 | $this->getLogger()->info( "Updating base page $basePage" ); |
157 | 157 | |
158 | 158 | $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\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 ) { |
@@ -32,18 +32,18 @@ discard block |
||
32 | 32 | * @param PageRiconferma[] $pages |
33 | 33 | * @see OpenUpdates::addToMainPage() |
34 | 34 | */ |
35 | - protected function removeFromMainPage( array $pages ) : void { |
|
35 | + protected function removeFromMainPage ( array $pages ) : void { |
|
36 | 36 | $this->getLogger()->info( |
37 | 37 | 'Removing from main: ' . implode( ', ', $pages ) |
38 | 38 | ); |
39 | 39 | |
40 | 40 | $mainPage = $this->getPage( $this->getOpt( 'main-page-title' ) ); |
41 | - $remove = []; |
|
41 | + $remove = [ ]; |
|
42 | 42 | foreach ( $pages as $page ) { |
43 | 43 | // Order matters here. It's not guaranteed that there'll be a newline, but avoid |
44 | 44 | // regexps for that single character. |
45 | - $remove[] = '{{' . $page->getTitle() . "}}\n"; |
|
46 | - $remove[] = '{{' . $page->getTitle() . '}}'; |
|
45 | + $remove[ ] = '{{' . $page->getTitle() . "}}\n"; |
|
46 | + $remove[ ] = '{{' . $page->getTitle() . '}}'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | $newContent = str_replace( $remove, '', $mainPage->getContent() ); |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param PageRiconferma[] $pages |
74 | 74 | */ |
75 | - protected function addToArchive( array $pages ) : void { |
|
75 | + protected function addToArchive ( array $pages ) : void { |
|
76 | 76 | $this->getLogger()->info( |
77 | 77 | 'Adding to archive: ' . implode( ', ', $pages ) |
78 | 78 | ); |
79 | 79 | |
80 | - $simple = $votes = []; |
|
80 | + $simple = $votes = [ ]; |
|
81 | 81 | foreach ( $pages as $page ) { |
82 | 82 | if ( $page->isVote() ) { |
83 | - $votes[] = $page; |
|
83 | + $votes[ ] = $page; |
|
84 | 84 | } else { |
85 | - $simple[] = $page; |
|
85 | + $simple[ ] = $page; |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | * @param string $archiveTitle |
104 | 104 | * @param PageRiconferma[] $pages |
105 | 105 | */ |
106 | - private function reallyAddToArchive( string $archiveTitle, array $pages ) : void { |
|
106 | + private function reallyAddToArchive ( string $archiveTitle, array $pages ) : void { |
|
107 | 107 | $archivePage = $this->getPage( "$archiveTitle/" . date( 'Y' ) ); |
108 | 108 | $existed = $archivePage->exists(); |
109 | 109 | |
110 | 110 | $append = "\n"; |
111 | - $archivedList = []; |
|
111 | + $archivedList = [ ]; |
|
112 | 112 | foreach ( $pages as $page ) { |
113 | 113 | $append .= '{{' . $page->getTitle() . "}}\n"; |
114 | - $archivedList[] = $page->getUserNum(); |
|
114 | + $archivedList[ ] = $page->getUserNum(); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $summary = $this->msg( 'close-archive-summary' ) |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @param string $archiveTitle |
134 | 134 | */ |
135 | - private function addArchiveYear( string $archiveTitle ) : void { |
|
135 | + private function addArchiveYear ( string $archiveTitle ) : void { |
|
136 | 136 | $page = $this->getPage( $archiveTitle ); |
137 | 137 | $year = date( 'Y' ); |
138 | 138 |
@@ -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: $outcomeText" : 'riconferma tacita'; |
68 | 67 | |
69 | 68 | $newContent = str_replace( 'riconferma in corso', $text, $current ); |