@@ -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\Page; |
4 | 4 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * @param string $listTitle |
20 | 20 | * @param Wiki $wiki |
21 | 21 | */ |
22 | - public function __construct( string $listTitle, Wiki $wiki ) { |
|
22 | + public function __construct ( string $listTitle, Wiki $wiki ) { |
|
23 | 23 | parent::__construct( $listTitle, $wiki ); |
24 | 24 | } |
25 | 25 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param string $listTitle |
31 | 31 | * @return self |
32 | 32 | */ |
33 | - public static function get( Wiki $wiki, string $listTitle ) : self { |
|
33 | + public static function get ( Wiki $wiki, string $listTitle ) : self { |
|
34 | 34 | static $instance = null; |
35 | 35 | if ( $instance === null ) { |
36 | 36 | $instance = new self( $listTitle, $wiki ); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @param UserInfo $ui |
43 | 43 | * @return int|null |
44 | 44 | */ |
45 | - public function getOverrideTimestamp( UserInfo $ui ) : ?int { |
|
45 | + public function getOverrideTimestamp ( UserInfo $ui ) : ?int { |
|
46 | 46 | $info = $ui->getInfo(); |
47 | 47 | if ( !array_intersect_key( $info, [ 'override-perm' => true, 'override' => true ] ) ) { |
48 | 48 | return null; |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | // A one-time override takes precedence |
52 | 52 | if ( array_key_exists( 'override', $info ) ) { |
53 | - $date = $info['override']; |
|
53 | + $date = $info[ 'override' ]; |
|
54 | 54 | } else { |
55 | - $date = $info['override-prem'] . '/' . date( 'Y' ); |
|
55 | + $date = $info[ 'override-prem' ] . '/' . date( 'Y' ); |
|
56 | 56 | } |
57 | 57 | return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp(); |
58 | 58 | } |
@@ -63,17 +63,17 @@ discard block |
||
63 | 63 | * @param string $user |
64 | 64 | * @return int |
65 | 65 | */ |
66 | - public function getNextTimestamp( string $user ) : int { |
|
66 | + public function getNextTimestamp ( string $user ) : int { |
|
67 | 67 | $userInfo = $this->getUserInfo( $user )->getInfo(); |
68 | - if ( isset( $userInfo['override-perm'] ) ) { |
|
68 | + if ( isset( $userInfo[ 'override-perm' ] ) ) { |
|
69 | 69 | $date = \DateTime::createFromFormat( |
70 | 70 | 'd/m/Y', |
71 | - $userInfo['override-perm'] . '/' . date( 'Y' ) |
|
71 | + $userInfo[ 'override-perm' ] . '/' . date( 'Y' ) |
|
72 | 72 | ); |
73 | 73 | } else { |
74 | 74 | $date = null; |
75 | - if ( isset( $userInfo['override'] ) ) { |
|
76 | - $date = \DateTime::createFromFormat( 'd/m/Y', $userInfo['override'] ); |
|
75 | + if ( isset( $userInfo[ 'override' ] ) ) { |
|
76 | + $date = \DateTime::createFromFormat( 'd/m/Y', $userInfo[ 'override' ] ); |
|
77 | 77 | } |
78 | 78 | if ( !$date || $date <= new \DateTime ) { |
79 | 79 | $ts = self::getValidFlagTimestamp( $userInfo ); |
@@ -92,17 +92,15 @@ discard block |
||
92 | 92 | * @param array $groups |
93 | 93 | * @return int |
94 | 94 | */ |
95 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
96 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
97 | - \DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
98 | - 0; |
|
99 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
100 | - \DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
101 | - 0; |
|
95 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
96 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
97 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
98 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
99 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
102 | 100 | |
103 | 101 | $timestamp = max( $bureaucrat, $checkuser ); |
104 | 102 | if ( $timestamp === 0 ) { |
105 | - $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
103 | + $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
106 | 104 | } |
107 | 105 | return $timestamp; |
108 | 106 | } |
@@ -111,14 +109,14 @@ discard block |
||
111 | 109 | * @param array $groups |
112 | 110 | * @return bool |
113 | 111 | */ |
114 | - public static function isOverrideExpired( array $groups ) : bool { |
|
115 | - if ( !isset( $groups['override'] ) ) { |
|
112 | + public static function isOverrideExpired ( array $groups ) : bool { |
|
113 | + if ( !isset( $groups[ 'override' ] ) ) { |
|
116 | 114 | return false; |
117 | 115 | } |
118 | 116 | |
119 | 117 | $flagTS = self::getValidFlagTimestamp( $groups ); |
120 | 118 | $usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) ); |
121 | - $overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp(); |
|
119 | + $overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp(); |
|
122 | 120 | $delay = 60 * 60 * 24 * 3; |
123 | 121 | |
124 | 122 | return time() > $usualTS + $delay && time() > $overrideTS + $delay; |
@@ -129,9 +127,9 @@ discard block |
||
129 | 127 | * |
130 | 128 | * @return UserInfo[] |
131 | 129 | */ |
132 | - public function getAdminsList() : array { |
|
130 | + public function getAdminsList () : array { |
|
133 | 131 | if ( $this->adminsList === null ) { |
134 | - $this->adminsList = []; |
|
132 | + $this->adminsList = [ ]; |
|
135 | 133 | foreach ( $this->getDecodedContent() as $user => $info ) { |
136 | 134 | $this->adminsList[ $user ] = new UserInfo( $user, $info ); |
137 | 135 | } |
@@ -143,8 +141,8 @@ discard block |
||
143 | 141 | * @param string $user |
144 | 142 | * @return UserInfo |
145 | 143 | */ |
146 | - public function getUserInfo( string $user ) : UserInfo { |
|
147 | - return $this->getAdminsList()[$user]; |
|
144 | + public function getUserInfo ( string $user ) : UserInfo { |
|
145 | + return $this->getAdminsList()[ $user ]; |
|
148 | 146 | } |
149 | 147 | |
150 | 148 | /** |
@@ -152,7 +150,7 @@ discard block |
||
152 | 150 | * |
153 | 151 | * @return array[] |
154 | 152 | */ |
155 | - public function getDecodedContent() : array { |
|
153 | + public function getDecodedContent () : array { |
|
156 | 154 | return json_decode( $this->getContent(), true ); |
157 | 155 | } |
158 | 156 | } |
@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @param UserInfo $ui |
22 | 22 | * @param Wiki $wiki |
23 | 23 | */ |
24 | - public function __construct( UserInfo $ui, Wiki $wiki ) { |
|
24 | + public function __construct ( UserInfo $ui, Wiki $wiki ) { |
|
25 | 25 | $this->wiki = $wiki; |
26 | 26 | $this->name = $ui->getName(); |
27 | 27 | $this->ui = $ui; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - public function getName() : string { |
|
33 | + public function getName () : string { |
|
34 | 34 | return $this->name; |
35 | 35 | } |
36 | 36 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return string[] |
41 | 41 | */ |
42 | - public function getGroups() : array { |
|
42 | + public function getGroups () : array { |
|
43 | 43 | return $this->ui->extractGroups(); |
44 | 44 | } |
45 | 45 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return string[] [ group => date ] |
50 | 50 | */ |
51 | - public function getGroupsWithDates() : array { |
|
51 | + public function getGroupsWithDates () : array { |
|
52 | 52 | return $this->ui->extractGroupsWithDates(); |
53 | 53 | } |
54 | 54 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string $groupName |
59 | 59 | * @return bool |
60 | 60 | */ |
61 | - public function inGroup( string $groupName ) : bool { |
|
61 | + public function inGroup ( string $groupName ) : bool { |
|
62 | 62 | return in_array( $groupName, $this->getGroups(), true ); |
63 | 63 | } |
64 | 64 | |
@@ -67,9 +67,9 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @inheritDoc |
69 | 69 | */ |
70 | - public function getRegex( string $delimiter = '/' ) : string { |
|
70 | + public function getRegex ( string $delimiter = '/' ) : string { |
|
71 | 71 | $bits = $this->getAliases(); |
72 | - $bits[] = $this->name; |
|
72 | + $bits[ ] = $this->name; |
|
73 | 73 | $regexify = static function ( $el ) use ( $delimiter ) { |
74 | 74 | return str_replace( ' ', '[ _]', preg_quote( $el, $delimiter ) ); |
75 | 75 | }; |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return string[] |
83 | 83 | */ |
84 | - public function getAliases() : array { |
|
84 | + public function getAliases () : array { |
|
85 | 85 | return $this->ui->getAliases(); |
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
89 | 89 | * @return Page |
90 | 90 | */ |
91 | - public function getTalkPage() : Page { |
|
91 | + public function getTalkPage () : Page { |
|
92 | 92 | return new Page( "User talk:{$this->name}", $this->wiki ); |
93 | 93 | } |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * Get the default base page, e.g. WP:A/Riconferma annuale/XXX |
97 | 97 | * @return Page |
98 | 98 | */ |
99 | - public function getBasePage() : Page { |
|
99 | + public function getBasePage () : Page { |
|
100 | 100 | $prefix = Config::getInstance()->get( 'main-page-title' ); |
101 | 101 | return new Page( "$prefix/$this", $this->wiki ); |
102 | 102 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @throws MissingPageException |
109 | 109 | * @return Page |
110 | 110 | */ |
111 | - public function getExistingBasePage() : Page { |
|
111 | + public function getExistingBasePage () : Page { |
|
112 | 112 | $basePage = $this->getBasePage(); |
113 | 113 | if ( !$basePage->exists() ) { |
114 | 114 | $basePage = null; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - public function __toString() { |
|
135 | + public function __toString () { |
|
136 | 136 | return $this->name; |
137 | 137 | } |
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\Wiki; |
4 | 4 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @param Wiki $mainWiki |
16 | 16 | * @param Wiki $centralWiki |
17 | 17 | */ |
18 | - public function __construct( Wiki $mainWiki, Wiki $centralWiki ) { |
|
18 | + public function __construct ( Wiki $mainWiki, Wiki $centralWiki ) { |
|
19 | 19 | $this->mainWiki = $mainWiki; |
20 | 20 | $this->centralWiki = $centralWiki; |
21 | 21 | } |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | /** |
24 | 24 | * @return Wiki |
25 | 25 | */ |
26 | - public function getMainWiki() : Wiki { |
|
26 | + public function getMainWiki () : Wiki { |
|
27 | 27 | return $this->mainWiki; |
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @return Wiki |
32 | 32 | */ |
33 | - public function getCentralWiki() : Wiki { |
|
33 | + public function getCentralWiki () : Wiki { |
|
34 | 34 | return $this->centralWiki; |
35 | 35 | } |
36 | 36 | } |
@@ -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\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\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 = RegexUtils::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\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 = RegexUtils::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; |
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 = RegexUtils::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\Wiki; |
4 | 4 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param LoggerInterface $logger |
35 | 35 | * @param RequestFactory $requestFactory |
36 | 36 | */ |
37 | - public function __construct( |
|
37 | + public function __construct ( |
|
38 | 38 | LoginInfo $li, |
39 | 39 | LoggerInterface $logger, |
40 | 40 | RequestFactory $requestFactory |
@@ -47,28 +47,28 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @return LoginInfo |
49 | 49 | */ |
50 | - public function getLoginInfo() : LoginInfo { |
|
50 | + public function getLoginInfo () : LoginInfo { |
|
51 | 51 | return $this->loginInfo; |
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @return RequestFactory |
56 | 56 | */ |
57 | - public function getRequestFactory() : RequestFactory { |
|
57 | + public function getRequestFactory () : RequestFactory { |
|
58 | 58 | return $this->requestFactory; |
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param string $ident |
63 | 63 | */ |
64 | - public function setLocalUserIdentifier( string $ident ) : void { |
|
64 | + public function setLocalUserIdentifier ( string $ident ) : void { |
|
65 | 65 | $this->localUserIdentifier = $ident; |
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * @return string |
70 | 70 | */ |
71 | - public function getLocalUserIdentifier() : string { |
|
71 | + public function getLocalUserIdentifier () : string { |
|
72 | 72 | return $this->localUserIdentifier; |
73 | 73 | } |
74 | 74 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @throws MissingPageException |
82 | 82 | * @throws MissingSectionException |
83 | 83 | */ |
84 | - public function getPageContent( string $title, int $section = null ) : string { |
|
84 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
85 | 85 | $msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' ); |
86 | 86 | $this->logger->debug( $msg ); |
87 | 87 | $params = [ |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | ]; |
94 | 94 | |
95 | 95 | if ( $section !== null ) { |
96 | - $params['rvsection'] = $section; |
|
96 | + $params[ 'rvsection' ] = $section; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $req = $this->buildRequest( $params ); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | throw new MissingPageException( $title ); |
104 | 104 | } |
105 | 105 | |
106 | - $mainSlot = $page->revisions[0]->slots->main; |
|
106 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
107 | 107 | |
108 | 108 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
109 | 109 | throw new MissingSectionException( $title, $section ); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param array $params |
118 | 118 | * @throws EditException |
119 | 119 | */ |
120 | - public function editPage( array $params ) : void { |
|
120 | + public function editPage ( array $params ) : void { |
|
121 | 121 | $this->login(); |
122 | 122 | |
123 | 123 | $params = [ |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ] + $params; |
127 | 127 | |
128 | 128 | if ( BOT_EDITS === true ) { |
129 | - $params['bot'] = 1; |
|
129 | + $params[ 'bot' ] = 1; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | $res = $this->buildRequest( $params )->setPost()->execute(); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
145 | 145 | * @throws LoginException |
146 | 146 | */ |
147 | - public function login() : void { |
|
147 | + public function login () : void { |
|
148 | 148 | if ( $this->loginInfo === null ) { |
149 | 149 | throw new CannotLoginException( 'Missing login data' ); |
150 | 150 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | self::$loggedIn = true; |
176 | 176 | // Clear tokens cache |
177 | - $this->tokens = []; |
|
177 | + $this->tokens = [ ]; |
|
178 | 178 | $this->logger->info( 'Login succeeded' ); |
179 | 179 | } |
180 | 180 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param string $type |
185 | 185 | * @return string |
186 | 186 | */ |
187 | - public function getToken( string $type ) : string { |
|
187 | + public function getToken ( string $type ) : string { |
|
188 | 188 | if ( !isset( $this->tokens[ $type ] ) ) { |
189 | 189 | $params = [ |
190 | 190 | 'action' => 'query', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param string $title |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function getPageCreationTS( string $title ) : int { |
|
210 | + public function getPageCreationTS ( string $title ) : int { |
|
211 | 211 | $params = [ |
212 | 212 | 'action' => 'query', |
213 | 213 | 'prop' => 'revisions', |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | $res = $this->buildRequest( $params )->execute(); |
222 | 222 | $data = $res->query->pages; |
223 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
223 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @param string $title |
230 | 230 | * @param string $reason |
231 | 231 | */ |
232 | - public function protectPage( string $title, string $reason ) : void { |
|
232 | + public function protectPage ( string $title, string $reason ) : void { |
|
233 | 233 | $this->logger->info( "Protecting page $title" ); |
234 | 234 | $this->login(); |
235 | 235 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param array $params |
251 | 251 | * @return RequestBase |
252 | 252 | */ |
253 | - private function buildRequest( array $params ) : RequestBase { |
|
253 | + private function buildRequest ( array $params ) : RequestBase { |
|
254 | 254 | return $this->requestFactory->newFromParams( $params ); |
255 | 255 | } |
256 | 256 | } |