@@ -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 | |
@@ -18,15 +18,15 @@ discard block |
||
| 18 | 18 | /** |
| 19 | 19 | * @inheritDoc |
| 20 | 20 | */ |
| 21 | - protected function getSubtasksMap(): array { |
|
| 21 | + protected function getSubtasksMap (): array { |
|
| 22 | 22 | // Everything is done here. |
| 23 | - return []; |
|
| 23 | + return [ ]; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * @inheritDoc |
| 28 | 28 | */ |
| 29 | - public function runInternal() : int { |
|
| 29 | + public function runInternal () : int { |
|
| 30 | 30 | $this->actualList = $this->getActualAdmins(); |
| 31 | 31 | $this->botList = $this->getDataProvider()->getUsersList(); |
| 32 | 32 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * @return array |
| 57 | 57 | */ |
| 58 | - protected function getActualAdmins() : array { |
|
| 58 | + protected function getActualAdmins () : array { |
|
| 59 | 59 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 60 | 60 | $params = [ |
| 61 | 61 | 'action' => 'query', |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @param \stdClass $data |
| 74 | 74 | * @return array |
| 75 | 75 | */ |
| 76 | - protected function extractAdmins( \stdClass $data ) : array { |
|
| 77 | - $ret = []; |
|
| 76 | + protected function extractAdmins ( \stdClass $data ) : array { |
|
| 77 | + $ret = [ ]; |
|
| 78 | 78 | $blacklist = $this->getConfig()->get( 'exclude-admins' ); |
| 79 | 79 | foreach ( $data->query->allusers as $u ) { |
| 80 | 80 | if ( in_array( $u->name, $blacklist ) ) { |
@@ -91,22 +91,22 @@ discard block |
||
| 91 | 91 | * |
| 92 | 92 | * @return array[] |
| 93 | 93 | */ |
| 94 | - protected function getMissingGroups() : array { |
|
| 95 | - $missing = []; |
|
| 94 | + protected function getMissingGroups () : array { |
|
| 95 | + $missing = [ ]; |
|
| 96 | 96 | foreach ( $this->actualList as $adm => $groups ) { |
| 97 | - $groupsList = []; |
|
| 97 | + $groupsList = [ ]; |
|
| 98 | 98 | if ( !isset( $this->botList[ $adm ] ) ) { |
| 99 | 99 | $groupsList = $groups; |
| 100 | - } elseif ( count( $groups ) > count( $this->botList[$adm] ) ) { |
|
| 100 | + } elseif ( count( $groups ) > count( $this->botList[ $adm ] ) ) { |
|
| 101 | 101 | // Only some groups are missing |
| 102 | - $groupsList = array_diff_key( $groups, $this->botList[$adm] ); |
|
| 102 | + $groupsList = array_diff_key( $groups, $this->botList[ $adm ] ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | foreach ( $groupsList as $group ) { |
| 106 | 106 | try { |
| 107 | 107 | $missing[ $adm ][ $group ] = $this->getFlagDate( $adm, $group ); |
| 108 | 108 | } catch ( TaskException $e ) { |
| 109 | - $this->errors[] = $e->getMessage(); |
|
| 109 | + $this->errors[ ] = $e->getMessage(); |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @return string |
| 122 | 122 | * @throws TaskException |
| 123 | 123 | */ |
| 124 | - protected function getFlagDate( string $admin, string $group ) : string { |
|
| 124 | + protected function getFlagDate ( string $admin, string $group ) : string { |
|
| 125 | 125 | $this->getLogger()->info( "Retrieving $group flag date for $admin" ); |
| 126 | 126 | |
| 127 | 127 | $url = DEFAULT_URL; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param string $group |
| 157 | 157 | * @return string|null |
| 158 | 158 | */ |
| 159 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 159 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 160 | 160 | $ts = null; |
| 161 | 161 | foreach ( $data->query->logevents as $entry ) { |
| 162 | 162 | if ( !isset( $entry->params ) ) { |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return array[] |
| 180 | 180 | */ |
| 181 | - protected function getExtraGroups() : array { |
|
| 182 | - $extra = []; |
|
| 181 | + protected function getExtraGroups () : array { |
|
| 182 | + $extra = [ ]; |
|
| 183 | 183 | foreach ( $this->botList as $name => $groups ) { |
| 184 | 184 | if ( !isset( $this->actualList[ $name ] ) ) { |
| 185 | 185 | $extra[ $name ] = $groups; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @param array[] $extra |
| 198 | 198 | * @return array[] |
| 199 | 199 | */ |
| 200 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 200 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 201 | 201 | $newContent = $this->botList; |
| 202 | 202 | foreach ( $newContent as $user => $groups ) { |
| 203 | 203 | if ( isset( $missing[ $user ] ) ) { |
@@ -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 | |
@@ -15,14 +15,14 @@ discard block |
||
| 15 | 15 | /** @var array[] */ |
| 16 | 16 | private $allUsers; |
| 17 | 17 | /** @var PageRiconferma[] */ |
| 18 | - private $createdPages = []; |
|
| 18 | + private $createdPages = [ ]; |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Get the full content of the JSON users list |
| 22 | 22 | * |
| 23 | 23 | * @return array[] |
| 24 | 24 | */ |
| 25 | - public function getUsersList() : array { |
|
| 25 | + public function getUsersList () : array { |
|
| 26 | 26 | if ( $this->allUsers === null ) { |
| 27 | 27 | $this->getLogger()->debug( 'Retrieving users list' ); |
| 28 | 28 | $this->allUsers = PageBotList::get()->getAdminsList(); |
@@ -36,9 +36,9 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return array[] |
| 38 | 38 | */ |
| 39 | - public function getUsersToProcess() : array { |
|
| 39 | + public function getUsersToProcess () : array { |
|
| 40 | 40 | if ( $this->processUsers === null ) { |
| 41 | - $this->processUsers = []; |
|
| 41 | + $this->processUsers = [ ]; |
|
| 42 | 42 | foreach ( $this->getUsersList() as $user => $groups ) { |
| 43 | 43 | $timestamp = $this->getValidTimestamp( $groups ); |
| 44 | 44 | |
@@ -60,13 +60,11 @@ discard block |
||
| 60 | 60 | * @param array $groups |
| 61 | 61 | * @return int |
| 62 | 62 | */ |
| 63 | - private function getValidTimestamp( array $groups ) : int { |
|
| 63 | + private function getValidTimestamp ( array $groups ) : int { |
|
| 64 | 64 | $checkuser = isset( $groups[ 'checkuser' ] ) ? |
| 65 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : |
|
| 66 | - 0; |
|
| 65 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'checkuser' ] )->getTimestamp() : 0; |
|
| 67 | 66 | $bureaucrat = isset( $groups[ 'bureaucrat' ] ) ? |
| 68 | - \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : |
|
| 69 | - 0; |
|
| 67 | + \DateTime::createFromFormat( 'd/m/Y', $groups[ 'bureaucrat' ] )->getTimestamp() : 0; |
|
| 70 | 68 | |
| 71 | 69 | $timestamp = max( $bureaucrat, $checkuser ); |
| 72 | 70 | if ( $timestamp === 0 ) { |
@@ -80,7 +78,7 @@ discard block |
||
| 80 | 78 | * |
| 81 | 79 | * @return PageRiconferma[] |
| 82 | 80 | */ |
| 83 | - public function getOpenPages() : array { |
|
| 81 | + public function getOpenPages () : array { |
|
| 84 | 82 | static $list = null; |
| 85 | 83 | if ( $list === null ) { |
| 86 | 84 | $baseTitle = $this->getConfig()->get( 'main-page-title' ); |
@@ -94,10 +92,10 @@ discard block |
||
| 94 | 92 | |
| 95 | 93 | $res = RequestBase::newFromParams( $params )->execute(); |
| 96 | 94 | $pages = $res->query->pages; |
| 97 | - $list = []; |
|
| 95 | + $list = [ ]; |
|
| 98 | 96 | foreach ( reset( $pages )->templates as $page ) { |
| 99 | 97 | if ( preg_match( "!$baseTitle\/[^\/]+\/\d!", $page->title ) !== false ) { |
| 100 | - $list[] = new PageRiconferma( $page->title ); |
|
| 98 | + $list[ ] = new PageRiconferma( $page->title ); |
|
| 101 | 99 | } |
| 102 | 100 | } |
| 103 | 101 | } |
@@ -110,14 +108,14 @@ discard block |
||
| 110 | 108 | * |
| 111 | 109 | * @return PageRiconferma[] |
| 112 | 110 | */ |
| 113 | - public function getPagesToClose() : array { |
|
| 111 | + public function getPagesToClose () : array { |
|
| 114 | 112 | static $list = null; |
| 115 | 113 | if ( $list === null ) { |
| 116 | 114 | $allPages = $this->getOpenPages(); |
| 117 | - $list = []; |
|
| 115 | + $list = [ ]; |
|
| 118 | 116 | foreach ( $allPages as $page ) { |
| 119 | 117 | if ( time() > $page->getEndTimestamp() ) { |
| 120 | - $list[] = $page; |
|
| 118 | + $list[ ] = $page; |
|
| 121 | 119 | } |
| 122 | 120 | } |
| 123 | 121 | } |
@@ -129,21 +127,21 @@ discard block |
||
| 129 | 127 | * |
| 130 | 128 | * @param string $name |
| 131 | 129 | */ |
| 132 | - public function removeUser( string $name ) { |
|
| 130 | + public function removeUser ( string $name ) { |
|
| 133 | 131 | unset( $this->processUsers[ $name ] ); |
| 134 | 132 | } |
| 135 | 133 | |
| 136 | 134 | /** |
| 137 | 135 | * @return PageRiconferma[] |
| 138 | 136 | */ |
| 139 | - public function getCreatedPages() : array { |
|
| 137 | + public function getCreatedPages () : array { |
|
| 140 | 138 | return $this->createdPages; |
| 141 | 139 | } |
| 142 | 140 | |
| 143 | 141 | /** |
| 144 | 142 | * @param PageRiconferma $page |
| 145 | 143 | */ |
| 146 | - public function addCreatedPages( PageRiconferma $page ) { |
|
| 147 | - $this->createdPages[] = $page; |
|
| 144 | + public function addCreatedPages ( PageRiconferma $page ) { |
|
| 145 | + $this->createdPages[ ] = $page; |
|
| 148 | 146 | } |
| 149 | 147 | } |