@@ -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 | * @private Use self::get() |
20 | 20 | * @param Wiki $wiki |
21 | 21 | */ |
22 | - public function __construct( Wiki $wiki ) { |
|
22 | + public function __construct ( Wiki $wiki ) { |
|
23 | 23 | parent::__construct( Config::getInstance()->get( 'list-title' ), $wiki ); |
24 | 24 | } |
25 | 25 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param Wiki $wiki |
30 | 30 | * @return self |
31 | 31 | */ |
32 | - public static function get( Wiki $wiki ) : self { |
|
32 | + public static function get ( Wiki $wiki ) : self { |
|
33 | 33 | static $instance = null; |
34 | 34 | if ( $instance === null ) { |
35 | 35 | $instance = new self( $wiki ); |
@@ -41,16 +41,16 @@ discard block |
||
41 | 41 | * @param string[] $groups |
42 | 42 | * @return int|null |
43 | 43 | */ |
44 | - public static function getOverrideTimestamp( array $groups ) : ?int { |
|
44 | + public static function getOverrideTimestamp ( array $groups ) : ?int { |
|
45 | 45 | if ( !array_intersect_key( $groups, [ 'override-perm' => true, 'override' => true ] ) ) { |
46 | 46 | return null; |
47 | 47 | } |
48 | 48 | |
49 | 49 | // A one-time override takes precedence |
50 | 50 | if ( array_key_exists( 'override', $groups ) ) { |
51 | - $date = $groups['override']; |
|
51 | + $date = $groups[ 'override' ]; |
|
52 | 52 | } else { |
53 | - $date = $groups['override-prem'] . '/' . date( 'Y' ); |
|
53 | + $date = $groups[ 'override-prem' ] . '/' . date( 'Y' ); |
|
54 | 54 | } |
55 | 55 | return \DateTime::createFromFormat( 'd/m/Y', $date )->getTimestamp(); |
56 | 56 | } |
@@ -61,17 +61,15 @@ discard block |
||
61 | 61 | * @param array $groups |
62 | 62 | * @return int |
63 | 63 | */ |
64 | - public static function getValidFlagTimestamp( array $groups ): int { |
|
65 | - $checkuser = isset( $groups['checkuser'] ) ? |
|
66 | - \DateTime::createFromFormat( 'd/m/Y', $groups['checkuser'] )->getTimestamp() : |
|
67 | - 0; |
|
68 | - $bureaucrat = isset( $groups['bureaucrat'] ) ? |
|
69 | - \DateTime::createFromFormat( 'd/m/Y', $groups['bureaucrat'] )->getTimestamp() : |
|
70 | - 0; |
|
64 | + public static function getValidFlagTimestamp ( array $groups ): int { |
|
65 | + $checkuser = isset( $groups[ 'checkuser' ] ) ? |
|
66 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
67 | + $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
|
68 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
71 | 69 | |
72 | 70 | $timestamp = max( $bureaucrat, $checkuser ); |
73 | 71 | if ( $timestamp === 0 ) { |
74 | - $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups['sysop'] )->getTimestamp(); |
|
72 | + $timestamp = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'sysop' ] )->getTimestamp(); |
|
75 | 73 | } |
76 | 74 | return $timestamp; |
77 | 75 | } |
@@ -81,9 +79,9 @@ discard block |
||
81 | 79 | * |
82 | 80 | * @return User[] |
83 | 81 | */ |
84 | - public function getAdminsList() : array { |
|
82 | + public function getAdminsList () : array { |
|
85 | 83 | if ( $this->adminsList === null ) { |
86 | - $this->adminsList = []; |
|
84 | + $this->adminsList = [ ]; |
|
87 | 85 | foreach ( $this->getDecodedContent() as $user => $info ) { |
88 | 86 | $userObj = new User( $user, $this->wiki ); |
89 | 87 | $userObj->setInfo( $info ); |
@@ -98,7 +96,7 @@ discard block |
||
98 | 96 | * |
99 | 97 | * @return array[] |
100 | 98 | */ |
101 | - public function getDecodedContent() : array { |
|
99 | + public function getDecodedContent () : array { |
|
102 | 100 | return json_decode( $this->getContent(), true ); |
103 | 101 | } |
104 | 102 | } |
@@ -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 string $name |
19 | 19 | * @param Wiki $wiki |
20 | 20 | */ |
21 | - public function __construct( string $name, Wiki $wiki ) { |
|
21 | + public function __construct ( string $name, Wiki $wiki ) { |
|
22 | 22 | parent::__construct( $wiki ); |
23 | 23 | $this->name = $name; |
24 | 24 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | /** |
27 | 27 | * @return string |
28 | 28 | */ |
29 | - public function getName() : string { |
|
29 | + public function getName () : string { |
|
30 | 30 | return $this->name; |
31 | 31 | } |
32 | 32 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return string[] |
37 | 37 | */ |
38 | - public function getGroups() : array { |
|
38 | + public function getGroups () : array { |
|
39 | 39 | return array_diff( array_keys( $this->getUserInfo() ), PageBotList::NON_GROUP_KEYS ); |
40 | 40 | } |
41 | 41 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return string[] |
46 | 46 | */ |
47 | - public function getUserInfo() : array { |
|
47 | + public function getUserInfo () : array { |
|
48 | 48 | if ( $this->info === null ) { |
49 | 49 | $usersList = PageBotList::get( $this->wiki )->getAdminsList(); |
50 | 50 | $this->info = $usersList[ $this->name ]->getUserInfo(); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @param array|null $info |
57 | 57 | */ |
58 | - public function setInfo( ?array $info ) : void { |
|
58 | + public function setInfo ( ?array $info ) : void { |
|
59 | 59 | $this->info = $info; |
60 | 60 | } |
61 | 61 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param string $groupName |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function inGroup( string $groupName ) : bool { |
|
68 | + public function inGroup ( string $groupName ) : bool { |
|
69 | 69 | return in_array( $groupName, $this->getGroups() ); |
70 | 70 | } |
71 | 71 | |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @inheritDoc |
76 | 76 | */ |
77 | - public function getRegex() : string { |
|
77 | + public function getRegex () : string { |
|
78 | 78 | $bits = $this->getAliases(); |
79 | - $bits[] = $this->name; |
|
79 | + $bits[ ] = $this->name; |
|
80 | 80 | $regexify = function ( $el ) { |
81 | 81 | return str_replace( ' ', '[ _]', preg_quote( $el ) ); |
82 | 82 | }; |
@@ -88,21 +88,21 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string[] |
90 | 90 | */ |
91 | - public function getAliases() : array { |
|
92 | - return $this->getUserInfo()['aliases'] ?? []; |
|
91 | + public function getAliases () : array { |
|
92 | + return $this->getUserInfo()[ 'aliases' ] ?? [ ]; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
96 | 96 | * @return Page |
97 | 97 | */ |
98 | - public function getTalkPage() : Page { |
|
98 | + public function getTalkPage () : Page { |
|
99 | 99 | return new Page( "User talk:{$this->name}", $this->wiki ); |
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | 103 | * @return string |
104 | 104 | */ |
105 | - public function __toString() { |
|
105 | + public function __toString () { |
|
106 | 106 | return $this->name; |
107 | 107 | } |
108 | 108 | } |
@@ -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->getUser()->getName() ] = $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 ) { |
|
41 | + protected function addMsg ( User $user, int $ricNum ) { |
|
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 | |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @inheritDoc |
17 | 17 | */ |
18 | - public function runInternal() : int { |
|
18 | + public function runInternal () : int { |
|
19 | 19 | $users = $this->getDataProvider()->getUsersToProcess(); |
20 | 20 | |
21 | 21 | if ( !$users ) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @param User $user |
36 | 36 | */ |
37 | - protected function processUser( User $user ) { |
|
37 | + protected function processUser ( User $user ) { |
|
38 | 38 | try { |
39 | 39 | $num = $this->getLastPageNum( $user ) + 1; |
40 | 40 | } catch ( TaskException $e ) { |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @return int |
67 | 67 | * @throws TaskException |
68 | 68 | */ |
69 | - protected function getLastPageNum( User $user ) : int { |
|
69 | + protected function getLastPageNum ( User $user ) : int { |
|
70 | 70 | $this->getLogger()->debug( "Retrieving previous pages for $user" ); |
71 | 71 | |
72 | - $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[1]; |
|
72 | + $unprefixedTitle = explode( ':', $this->getOpt( 'main-page-title' ), 2 )[ 1 ]; |
|
73 | 73 | |
74 | 74 | $prefixes = [ "$unprefixedTitle/$user/" ]; |
75 | 75 | foreach ( $user->getAliases() as $alias ) { |
76 | - $prefixes[] = "$unprefixedTitle/$alias/"; |
|
76 | + $prefixes[ ] = "$unprefixedTitle/$alias/"; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $params = [ |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * @param string $title |
110 | 110 | * @param User $user |
111 | 111 | */ |
112 | - protected function createPage( string $title, User $user ) { |
|
112 | + protected function createPage ( string $title, User $user ) { |
|
113 | 113 | $this->getLogger()->info( "Creating page $title" ); |
114 | 114 | $groups = $user->getGroups(); |
115 | 115 | $textParams = [ |
116 | 116 | '$user' => $user->getName(), |
117 | - '$date' => $groups['sysop'], |
|
118 | - '$burocrate' => $groups['bureaucrat'] ?? '', |
|
119 | - '$checkuser' => $groups['checkuser'] ?? '' |
|
117 | + '$date' => $groups[ 'sysop' ], |
|
118 | + '$burocrate' => $groups[ 'bureaucrat' ] ?? '', |
|
119 | + '$checkuser' => $groups[ 'checkuser' ] ?? '' |
|
120 | 120 | ]; |
121 | 121 | |
122 | 122 | $params = [ |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param string $title |
135 | 135 | * @param string $newText |
136 | 136 | */ |
137 | - protected function createBasePage( string $title, string $newText ) { |
|
137 | + protected function createBasePage ( string $title, string $newText ) { |
|
138 | 138 | $this->getLogger()->info( "Creating base page $title" ); |
139 | 139 | |
140 | 140 | $params = [ |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * @param string $title |
152 | 152 | * @param string $newText |
153 | 153 | */ |
154 | - protected function updateBasePage( string $title, string $newText ) { |
|
154 | + protected function updateBasePage ( string $title, string $newText ) { |
|
155 | 155 | $this->getLogger()->info( "Updating base page $title" ); |
156 | 156 | |
157 | 157 | $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; |
4 | 4 | |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @inheritDoc |
21 | 21 | */ |
22 | - protected function getSubtasksMap(): array { |
|
22 | + protected function getSubtasksMap (): array { |
|
23 | 23 | // Everything is done here. |
24 | - return []; |
|
24 | + return [ ]; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @inheritDoc |
29 | 29 | */ |
30 | - public function runInternal() : int { |
|
30 | + public function runInternal () : int { |
|
31 | 31 | $this->actualList = $this->getActualAdmins(); |
32 | 32 | $pageBotList = PageBotList::get( $this->getWiki() ); |
33 | 33 | $this->botList = $pageBotList->getDecodedContent(); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | /** |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - protected function getActualAdmins() : array { |
|
57 | + protected function getActualAdmins () : array { |
|
58 | 58 | $params = [ |
59 | 59 | 'action' => 'query', |
60 | 60 | 'list' => 'allusers', |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @param \stdClass $data |
72 | 72 | * @return array |
73 | 73 | */ |
74 | - protected function extractAdmins( \stdClass $data ) : array { |
|
75 | - $ret = []; |
|
74 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
75 | + $ret = [ ]; |
|
76 | 76 | $blacklist = $this->getOpt( 'exclude-admins' ); |
77 | 77 | foreach ( $data->query->allusers as $u ) { |
78 | 78 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -89,16 +89,16 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return array[] |
91 | 91 | */ |
92 | - protected function getMissingGroups() : array { |
|
93 | - $missing = []; |
|
92 | + protected function getMissingGroups () : array { |
|
93 | + $missing = [ ]; |
|
94 | 94 | foreach ( $this->actualList as $adm => $groups ) { |
95 | - $curMissing = array_diff( $groups, array_keys( $this->botList[$adm] ?? [] ) ); |
|
95 | + $curMissing = array_diff( $groups, array_keys( $this->botList[ $adm ] ?? [ ] ) ); |
|
96 | 96 | |
97 | 97 | foreach ( $curMissing as $group ) { |
98 | 98 | try { |
99 | 99 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
100 | 100 | } catch ( TaskException $e ) { |
101 | - $this->errors[] = $e->getMessage(); |
|
101 | + $this->errors[ ] = $e->getMessage(); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @return string |
114 | 114 | * @throws TaskException |
115 | 115 | */ |
116 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
116 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
117 | 117 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
118 | 118 | |
119 | 119 | $url = DEFAULT_URL; |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @param string $group |
150 | 150 | * @return string|null |
151 | 151 | */ |
152 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
152 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
153 | 153 | $ts = null; |
154 | 154 | foreach ( $data->query->logevents as $entry ) { |
155 | 155 | if ( isset( $entry->params ) ) { |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return array[] |
170 | 170 | */ |
171 | - protected function getExtraGroups() : array { |
|
172 | - $extra = []; |
|
171 | + protected function getExtraGroups () : array { |
|
172 | + $extra = [ ]; |
|
173 | 173 | foreach ( $this->botList as $name => $groups ) { |
174 | 174 | $groups = array_diff_key( $groups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ); |
175 | 175 | if ( !isset( $this->actualList[ $name ] ) ) { |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | * @param string[] $names |
188 | 188 | * @return string[] [ old_name => new_name ] |
189 | 189 | */ |
190 | - protected function checkRenamedUsers( array $names ) : array { |
|
190 | + protected function checkRenamedUsers ( array $names ) : array { |
|
191 | 191 | if ( !$names ) { |
192 | - return []; |
|
192 | + return [ ]; |
|
193 | 193 | } |
194 | 194 | $this->getLogger()->info( 'Checking rename for ' . implode( ', ', $names ) ); |
195 | 195 | |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | ]; |
208 | 208 | |
209 | 209 | $data = RequestBase::newFromParams( $params )->execute(); |
210 | - $ret = []; |
|
210 | + $ret = [ ]; |
|
211 | 211 | foreach ( $data->query->logevents as $entry ) { |
212 | 212 | $time = strtotime( $entry->timestamp ); |
213 | 213 | // 1 month is arbitrary |
@@ -227,10 +227,10 @@ discard block |
||
227 | 227 | * @param array[] $extra |
228 | 228 | * @return array[] |
229 | 229 | */ |
230 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
230 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
231 | 231 | $newContent = $this->botList; |
232 | 232 | $renameMap = $this->checkRenamedUsers( array_keys( $extra ) ); |
233 | - $removed = []; |
|
233 | + $removed = [ ]; |
|
234 | 234 | foreach ( $newContent as $user => $groups ) { |
235 | 235 | if ( isset( $missing[ $user ] ) ) { |
236 | 236 | $newContent[ $user ] = array_merge( $groups, $missing[ $user ] ); |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | if ( array_diff_key( $newGroups, array_fill_keys( PageBotList::NON_GROUP_KEYS, 1 ) ) ) { |
241 | 241 | $newContent[ $user ] = $newGroups; |
242 | 242 | } else { |
243 | - $removed[$user] = $newContent[$user]; |
|
243 | + $removed[ $user ] = $newContent[ $user ]; |
|
244 | 244 | unset( $newContent[ $user ] ); |
245 | 245 | } |
246 | 246 | } |
@@ -251,17 +251,17 @@ discard block |
||
251 | 251 | foreach ( $removed as $oldName => $info ) { |
252 | 252 | if ( |
253 | 253 | array_key_exists( $oldName, $renameMap ) && |
254 | - array_key_exists( $renameMap[$oldName], $newContent ) |
|
254 | + array_key_exists( $renameMap[ $oldName ], $newContent ) |
|
255 | 255 | ) { |
256 | 256 | // This user was renamed! Add this name as alias, if they're still listed |
257 | 257 | $newName = $renameMap[ $oldName ]; |
258 | 258 | $this->getLogger()->info( "Found rename $oldName -> $newName" ); |
259 | 259 | if ( array_key_exists( 'aliases', $newContent[ $newName ] ) ) { |
260 | - if ( !in_array( $oldName, $newContent[ $newName ]['aliases'] ) ) { |
|
261 | - $newContent[ $newName ]['aliases'][] = $oldName; |
|
260 | + if ( !in_array( $oldName, $newContent[ $newName ][ 'aliases' ] ) ) { |
|
261 | + $newContent[ $newName ][ 'aliases' ][ ] = $oldName; |
|
262 | 262 | } |
263 | 263 | } else { |
264 | - $newContent[ $newName ]['aliases'] = [ $oldName ]; |
|
264 | + $newContent[ $newName ][ 'aliases' ] = [ $oldName ]; |
|
265 | 265 | } |
266 | 266 | // Transfer overrides to the new name. |
267 | 267 | $overrides = array_diff_key( $info, [ 'override' => 1, 'override-perm' => 1 ] ); |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | * @param array[] $newContent |
282 | 282 | * @return array[] |
283 | 283 | */ |
284 | - protected function removeOverrides( array $newContent ) : array { |
|
285 | - $removed = []; |
|
284 | + protected function removeOverrides ( array $newContent ) : array { |
|
285 | + $removed = [ ]; |
|
286 | 286 | foreach ( $newContent as $user => $groups ) { |
287 | - if ( !isset( $groups['override'] ) ) { |
|
287 | + if ( !isset( $groups[ 'override' ] ) ) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | $flagTS = PageBotList::getValidFlagTimestamp( $groups ); |
292 | 292 | $usualTS = strtotime( date( 'Y' ) . '-' . date( 'm-d', $flagTS ) ); |
293 | - $overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups['override'] )->getTimestamp(); |
|
293 | + $overrideTS = \DateTime::createFromFormat( 'd/m/Y', $groups[ 'override' ] )->getTimestamp(); |
|
294 | 294 | $delay = 60 * 60 * 24 * 3; |
295 | 295 | |
296 | 296 | if ( time() > $usualTS + $delay && time() > $overrideTS + $delay ) { |
297 | 297 | unset( $newContent[ $user ][ 'override' ] ); |
298 | - $removed[] = $user; |
|
298 | + $removed[ ] = $user; |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 |
@@ -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 | |
@@ -14,16 +14,16 @@ discard block |
||
14 | 14 | /** @var User[]|null */ |
15 | 15 | private $processUsers; |
16 | 16 | /** @var PageRiconferma[] */ |
17 | - private $createdPages = []; |
|
17 | + private $createdPages = [ ]; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Get a list of users to execute tasks on. |
21 | 21 | * |
22 | 22 | * @return User[] |
23 | 23 | */ |
24 | - public function getUsersToProcess() : array { |
|
24 | + public function getUsersToProcess () : array { |
|
25 | 25 | if ( $this->processUsers === null ) { |
26 | - $this->processUsers = []; |
|
26 | + $this->processUsers = [ ]; |
|
27 | 27 | foreach ( PageBotList::get( $this->getWiki() )->getAdminsList() as $name => $user ) { |
28 | 28 | if ( $this->shouldAddUser( $user ) ) { |
29 | 29 | $this->processUsers[ $name ] = $user; |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @param User $user |
41 | 41 | * @return bool |
42 | 42 | */ |
43 | - private function shouldAddUser( User $user ) : bool { |
|
43 | + private function shouldAddUser ( User $user ) : bool { |
|
44 | 44 | $override = true; |
45 | 45 | $timestamp = PageBotList::getOverrideTimestamp( $user->getUserInfo() ); |
46 | 46 | |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return PageRiconferma[] |
61 | 61 | */ |
62 | - public function getOpenPages() : array { |
|
62 | + public function getOpenPages () : array { |
|
63 | 63 | static $list = null; |
64 | 64 | if ( $list === null ) { |
65 | - $list = []; |
|
65 | + $list = [ ]; |
|
66 | 66 | $mainTitle = $this->getOpt( 'main-page-title' ); |
67 | 67 | $params = [ |
68 | 68 | 'action' => 'query', |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $pages = RequestBase::newFromParams( $params )->execute()->query->pages; |
77 | 77 | foreach ( reset( $pages )->templates as $page ) { |
78 | 78 | if ( preg_match( "!$titleReg\/[^\/]+\/\d!", $page->title ) ) { |
79 | - $list[] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
79 | + $list[ ] = new PageRiconferma( $page->title, $this->getWiki() ); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | } |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return PageRiconferma[] |
91 | 91 | */ |
92 | - public function getPagesToClose() : array { |
|
92 | + public function getPagesToClose () : array { |
|
93 | 93 | static $list = null; |
94 | 94 | if ( $list === null ) { |
95 | - $list = []; |
|
95 | + $list = [ ]; |
|
96 | 96 | foreach ( $this->getOpenPages() as $page ) { |
97 | 97 | if ( time() > $page->getEndTimestamp() ) { |
98 | - $list[] = $page; |
|
98 | + $list[ ] = $page; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | } |
@@ -107,21 +107,21 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @param string $name |
109 | 109 | */ |
110 | - public function removeUser( string $name ) { |
|
110 | + public function removeUser ( string $name ) { |
|
111 | 111 | unset( $this->processUsers[ $name ] ); |
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
115 | 115 | * @return PageRiconferma[] |
116 | 116 | */ |
117 | - public function getCreatedPages() : array { |
|
117 | + public function getCreatedPages () : array { |
|
118 | 118 | return $this->createdPages; |
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @param PageRiconferma $page |
123 | 123 | */ |
124 | - public function addCreatedPages( PageRiconferma $page ) { |
|
125 | - $this->createdPages[] = $page; |
|
124 | + public function addCreatedPages ( PageRiconferma $page ) { |
|
125 | + $this->createdPages[ ] = $page; |
|
126 | 126 | } |
127 | 127 | } |