@@ -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 | |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @param string|null $name Only used in MODE_TASK and MODE_SUBTASK |
| 53 | 53 | * @return TaskResult |
| 54 | 54 | */ |
| 55 | - public function run( string $mode, string $name = null ) : TaskResult { |
|
| 55 | + public function run ( string $mode, string $name = null ) : TaskResult { |
|
| 56 | 56 | $this->provider = new TaskDataProvider; |
| 57 | 57 | |
| 58 | 58 | if ( $mode === self::MODE_COMPLETE ) { |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return TaskResult |
| 71 | 71 | */ |
| 72 | - protected function runAllTasks() : TaskResult { |
|
| 72 | + protected function runAllTasks () : TaskResult { |
|
| 73 | 73 | $orderedList = [ |
| 74 | 74 | 'update-list', |
| 75 | 75 | 'start-new', |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $name |
| 92 | 92 | * @return TaskResult |
| 93 | 93 | */ |
| 94 | - protected function runTask( string $name ) : TaskResult { |
|
| 94 | + protected function runTask ( string $name ) : TaskResult { |
|
| 95 | 95 | if ( !isset( self::TASKS_MAP[ $name ] ) ) { |
| 96 | 96 | throw new \InvalidArgumentException( "'$name' is not a valid task." ); |
| 97 | 97 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @param string $name |
| 107 | 107 | * @return TaskResult |
| 108 | 108 | */ |
| 109 | - protected function runSubtask( string $name ) : TaskResult { |
|
| 109 | + protected function runSubtask ( string $name ) : TaskResult { |
|
| 110 | 110 | if ( !isset( self::SUBTASKS_MAP[ $name ] ) ) { |
| 111 | 111 | throw new \InvalidArgumentException( "'$name' is not a valid subtask." ); |
| 112 | 112 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param string $class |
| 122 | 122 | * @return Task |
| 123 | 123 | */ |
| 124 | - private function getTaskInstance( string $class ) : Task { |
|
| 124 | + private function getTaskInstance ( string $class ) : Task { |
|
| 125 | 125 | return new $class( $this->provider ); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $class |
| 132 | 132 | * @return Subtask |
| 133 | 133 | */ |
| 134 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 134 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 135 | 135 | return new $class( $this->provider ); |
| 136 | 136 | } |
| 137 | 137 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @inheritDoc |
| 13 | 13 | */ |
| 14 | - public function log( $level, $message, array $context = [] ) { |
|
| 14 | + public function log ( $level, $message, array $context = [ ] ) { |
|
| 15 | 15 | printf( "%s [%s] - %s\n", date( 'd M H:i:s' ), $level, $message ); |
| 16 | 16 | } |
| 17 | 17 | } |
@@ -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 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @param string $key |
| 30 | 30 | */ |
| 31 | - public function __construct( string $key ) { |
|
| 31 | + public function __construct ( string $key ) { |
|
| 32 | 32 | $this->key = $key; |
| 33 | 33 | $this->value = Config::getInstance()->getWikiMessage( $key ); |
| 34 | 34 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param array $args |
| 38 | 38 | * @return self |
| 39 | 39 | */ |
| 40 | - public function params( array $args ) : self { |
|
| 40 | + public function params ( array $args ) : self { |
|
| 41 | 41 | $this->value = strtr( $this->value, $args ); |
| 42 | 42 | return $this; |
| 43 | 43 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * @return string |
| 47 | 47 | */ |
| 48 | - public function text() : string { |
|
| 48 | + public function text () : string { |
|
| 49 | 49 | $this->parsePlurals(); |
| 50 | 50 | return $this->value; |
| 51 | 51 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * Replace {{$plur|<amount>|sing|plur}} |
| 55 | 55 | */ |
| 56 | - protected function parsePlurals() { |
|
| 56 | + protected function parsePlurals () { |
|
| 57 | 57 | $reg = '!\{\{\$plur\|(?P<amount>\d+)\|(?P<sing>[^}|]+)\|(?P<plur>[^|}]+)}}!'; |
| 58 | 58 | |
| 59 | 59 | if ( preg_match( $reg, $this->value ) === 0 ) { |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $this->value = preg_replace_callback( |
| 63 | 63 | $reg, |
| 64 | 64 | function ( $matches ) { |
| 65 | - return intval( $matches['amount'] ) > 1 ? trim( $matches['plur'] ) : trim( $matches['sing'] ); |
|
| 65 | + return intval( $matches[ 'amount' ] ) > 1 ? trim( $matches[ 'plur' ] ) : trim( $matches[ 'sing' ] ); |
|
| 66 | 66 | }, |
| 67 | 67 | $this->value |
| 68 | 68 | ); |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param int $timestamp |
| 75 | 75 | * @return string |
| 76 | 76 | */ |
| 77 | - public static function getTimeWithArticle( int $timestamp ) : string { |
|
| 77 | + public static function getTimeWithArticle ( int $timestamp ) : string { |
|
| 78 | 78 | $oldLoc = setlocale( LC_TIME, 'it_IT', 'Italian_Italy', 'Italian' ); |
| 79 | 79 | $timeString = strftime( '%e %B alle %R', $timestamp ); |
| 80 | 80 | // Remove the left space if day has a single digit |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $timeString |
| 92 | 92 | * @return int |
| 93 | 93 | */ |
| 94 | - public static function getTimestampFromLocalTime( string $timeString ) : int { |
|
| 94 | + public static function getTimestampFromLocalTime ( string $timeString ) : int { |
|
| 95 | 95 | $englishTime = str_ireplace( |
| 96 | 96 | array_values( self::MONTHS ), |
| 97 | 97 | array_keys( self::MONTHS ), |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | * @param string $emptyText |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public static function commaList( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 113 | + public static function commaList ( array $data, string $emptyText = 'nessuno' ) : string { |
|
| 114 | 114 | if ( count( $data ) > 1 ) { |
| 115 | 115 | $last = array_pop( $data ); |
| 116 | 116 | $ret = implode( ', ', $data ) . " e $last"; |
| 117 | 117 | } elseif ( $data ) { |
| 118 | - $ret = (string)$data[0]; |
|
| 118 | + $ret = (string)$data[ 0 ]; |
|
| 119 | 119 | } else { |
| 120 | 120 | $ret = $emptyText; |
| 121 | 121 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | return $ret; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function __toString() { |
|
| 126 | + public function __toString () { |
|
| 127 | 127 | return $this->text(); |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -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 array[] */ |
| 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 array[] |
| 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()->getAdminsList() as $user => $groups ) { |
| 28 | 28 | if ( $this->shouldAddUser( $groups ) ) { |
| 29 | 29 | $this->processUsers[ $user ] = $groups; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @param string[] $groups |
| 41 | 41 | * @return bool |
| 42 | 42 | */ |
| 43 | - private function shouldAddUser( array $groups ) : bool { |
|
| 43 | + private function shouldAddUser ( array $groups ) : bool { |
|
| 44 | 44 | $override = true; |
| 45 | 45 | $timestamp = PageBotList::getOverrideTimestamp( $groups ); |
| 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->getConfig()->get( '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 ); |
|
| 79 | + $list[ ] = new PageRiconferma( $page->title ); |
|
| 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 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @return string |
| 13 | 13 | */ |
| 14 | - abstract public function getRegex() : string; |
|
| 14 | + abstract public function getRegex () : string; |
|
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * Get a regex matching any element in the given array |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | * @return string |
| 21 | 21 | * @todo Is this the right place? |
| 22 | 22 | */ |
| 23 | - public static function regexFromArray( array $elements ) : string { |
|
| 24 | - $bits = []; |
|
| 23 | + public static function regexFromArray ( array $elements ) : string { |
|
| 24 | + $bits = [ ]; |
|
| 25 | 25 | foreach ( $elements as $el ) { |
| 26 | - $bits[] = $el->getRegex(); |
|
| 26 | + $bits[ ] = $el->getRegex(); |
|
| 27 | 27 | } |
| 28 | 28 | return '(?:' . implode( '|', $bits ) . ')'; |
| 29 | 29 | } |
@@ -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 | $this->botList = PageBotList::get()->getAdminsList(); |
| 33 | 33 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @return array |
| 55 | 55 | */ |
| 56 | - protected function getActualAdmins() : array { |
|
| 56 | + protected function getActualAdmins () : array { |
|
| 57 | 57 | $this->getLogger()->debug( 'Retrieving admins - API' ); |
| 58 | 58 | $params = [ |
| 59 | 59 | 'action' => 'query', |
@@ -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->getConfig()->get( '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; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param string $group |
| 149 | 149 | * @return string|null |
| 150 | 150 | */ |
| 151 | - private function extractTimestamp( \stdClass $data, string $group ) : ?string { |
|
| 151 | + private function extractTimestamp ( \stdClass $data, string $group ) : ?string { |
|
| 152 | 152 | $ts = null; |
| 153 | 153 | foreach ( $data->query->logevents as $entry ) { |
| 154 | 154 | if ( isset( $entry->params ) ) { |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return array[] |
| 169 | 169 | */ |
| 170 | - protected function getExtraGroups() : array { |
|
| 171 | - $extra = []; |
|
| 170 | + protected function getExtraGroups () : array { |
|
| 171 | + $extra = [ ]; |
|
| 172 | 172 | foreach ( $this->botList as $name => $groups ) { |
| 173 | 173 | // These are not groups |
| 174 | 174 | unset( $groups[ 'override' ], $groups[ 'override-perm' ] ); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * @param array[] $extra |
| 189 | 189 | * @return array[] |
| 190 | 190 | */ |
| 191 | - protected function getNewContent( array $missing, array $extra ) : array { |
|
| 191 | + protected function getNewContent ( array $missing, array $extra ) : array { |
|
| 192 | 192 | $newContent = $this->botList; |
| 193 | 193 | foreach ( $newContent as $user => $groups ) { |
| 194 | 194 | if ( isset( $missing[ $user ] ) ) { |
@@ -213,15 +213,15 @@ discard block |
||
| 213 | 213 | * @param array[] $newContent |
| 214 | 214 | * @return array[] |
| 215 | 215 | */ |
| 216 | - protected function removeOverrides( array $newContent ) : array { |
|
| 217 | - $removed = []; |
|
| 216 | + protected function removeOverrides ( array $newContent ) : array { |
|
| 217 | + $removed = [ ]; |
|
| 218 | 218 | foreach ( $newContent as $user => $groups ) { |
| 219 | 219 | $ts = PageBotList::getValidFlagTimestamp( $groups ); |
| 220 | - if ( isset( $groups['override'] ) && ( date( 'd/m', $ts ) === |
|
| 220 | + if ( isset( $groups[ 'override' ] ) && ( date( 'd/m', $ts ) === |
|
| 221 | 221 | date( 'd/m', strtotime( '- 1 days' ) ) ) |
| 222 | 222 | ) { |
| 223 | 223 | unset( $newContent[ $user ][ 'override' ] ); |
| 224 | - $removed[] = $user; |
|
| 224 | + $removed[ ] = $user; |
|
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | abstract class TaskBase extends ContextSource { |
| 13 | 13 | /** @var string[] */ |
| 14 | - protected $errors = []; |
|
| 14 | + protected $errors = [ ]; |
|
| 15 | 15 | /** @var TaskDataProvider */ |
| 16 | 16 | protected $dataProvider; |
| 17 | 17 | |
@@ -20,14 +20,14 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @param TaskDataProvider $dataProvider |
| 22 | 22 | */ |
| 23 | - final public function __construct( TaskDataProvider $dataProvider ) { |
|
| 23 | + final public function __construct ( TaskDataProvider $dataProvider ) { |
|
| 24 | 24 | set_exception_handler( [ $this, 'handleException' ] ); |
| 25 | 25 | set_error_handler( [ $this, 'handleError' ] ); |
| 26 | 26 | parent::__construct(); |
| 27 | 27 | $this->dataProvider = $dataProvider; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | - public function __destruct() { |
|
| 30 | + public function __destruct () { |
|
| 31 | 31 | restore_error_handler(); |
| 32 | 32 | restore_exception_handler(); |
| 33 | 33 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * |
| 38 | 38 | * @return TaskResult |
| 39 | 39 | */ |
| 40 | - final public function run() : TaskResult { |
|
| 40 | + final public function run () : TaskResult { |
|
| 41 | 41 | $class = ( new \ReflectionClass( $this ) )->getShortName(); |
| 42 | 42 | $opName = $this->getOperationName(); |
| 43 | 43 | $this->getLogger()->info( "Starting $opName $class" ); |
@@ -68,14 +68,14 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @return int One of the STATUS_* constants |
| 70 | 70 | */ |
| 71 | - abstract protected function runInternal() : int; |
|
| 71 | + abstract protected function runInternal () : int; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * How this operation should be called in logs |
| 75 | 75 | * |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - abstract public function getOperationName() : string; |
|
| 78 | + abstract public function getOperationName () : string; |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Exception handler. |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param \Throwable $ex |
| 84 | 84 | * @protected |
| 85 | 85 | */ |
| 86 | - public function handleException( \Throwable $ex ) { |
|
| 86 | + public function handleException ( \Throwable $ex ) { |
|
| 87 | 87 | $this->getLogger()->error( |
| 88 | 88 | ( new \ReflectionClass( $ex ) )->getShortName() . ': ' . |
| 89 | 89 | $ex->getMessage() . "\nin " . $ex->getFile() . ' line ' . |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | * @throws \ErrorException |
| 102 | 102 | * @protected |
| 103 | 103 | */ |
| 104 | - public function handleError( $errno, $errstr, $errfile, $errline ) { |
|
| 104 | + public function handleError ( $errno, $errstr, $errfile, $errline ) { |
|
| 105 | 105 | throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline ); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| 109 | 109 | * @return TaskDataProvider |
| 110 | 110 | */ |
| 111 | - protected function getDataProvider() : TaskDataProvider { |
|
| 111 | + protected function getDataProvider () : TaskDataProvider { |
|
| 112 | 112 | return $this->dataProvider; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -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 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | /** |
| 28 | 28 | * @param string $domain The URL of the wiki, if different from default |
| 29 | 29 | */ |
| 30 | - public function __construct( string $domain = DEFAULT_URL ) { |
|
| 30 | + public function __construct ( string $domain = DEFAULT_URL ) { |
|
| 31 | 31 | $this->logger = new Logger; |
| 32 | 32 | $this->domain = $domain; |
| 33 | 33 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * @throws MissingPageException |
| 42 | 42 | * @throws MissingSectionException |
| 43 | 43 | */ |
| 44 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 44 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 45 | 45 | $msg = "Retrieving content of page $title" . ( $section !== null ? ", section $section" : '' ); |
| 46 | 46 | $this->logger->debug( $msg ); |
| 47 | 47 | $params = [ |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | 55 | if ( $section !== null ) { |
| 56 | - $params['rvsection'] = $section; |
|
| 56 | + $params[ 'rvsection' ] = $section; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | throw new MissingPageException( $title ); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 66 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 67 | 67 | |
| 68 | 68 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
| 69 | 69 | throw new MissingSectionException( $title, $section ); |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @param array $params |
| 78 | 78 | * @throws EditException |
| 79 | 79 | */ |
| 80 | - public function editPage( array $params ) { |
|
| 80 | + public function editPage ( array $params ) { |
|
| 81 | 81 | $this->login(); |
| 82 | 82 | |
| 83 | 83 | $params = [ |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 105 | 105 | * @throws LoginException |
| 106 | 106 | */ |
| 107 | - public function login() { |
|
| 107 | + public function login () { |
|
| 108 | 108 | if ( self::$loggedIn ) { |
| 109 | 109 | return; |
| 110 | 110 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | self::$loggedIn = true; |
| 132 | 132 | // Clear tokens cache |
| 133 | - $this->tokens = []; |
|
| 133 | + $this->tokens = [ ]; |
|
| 134 | 134 | $this->logger->info( 'Login succeeded' ); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | * @param string $type |
| 141 | 141 | * @return string |
| 142 | 142 | */ |
| 143 | - public function getToken( string $type ) : string { |
|
| 143 | + public function getToken ( string $type ) : string { |
|
| 144 | 144 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 145 | 145 | $params = [ |
| 146 | 146 | 'action' => 'query', |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param string $title |
| 164 | 164 | * @return int |
| 165 | 165 | */ |
| 166 | - public function getPageCreationTS( string $title ) : int { |
|
| 166 | + public function getPageCreationTS ( string $title ) : int { |
|
| 167 | 167 | $params = [ |
| 168 | 168 | 'action' => 'query', |
| 169 | 169 | 'prop' => 'revisions', |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
| 178 | 178 | $data = $res->query->pages; |
| 179 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 179 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | /** |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | * @param string $title |
| 186 | 186 | * @param string $reason |
| 187 | 187 | */ |
| 188 | - public function protectPage( string $title, string $reason ) { |
|
| 188 | + public function protectPage ( string $title, string $reason ) { |
|
| 189 | 189 | $this->logger->info( "Protecting page $title" ); |
| 190 | 190 | $this->login(); |
| 191 | 191 | |
@@ -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.' ); |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | * @return int |
| 55 | 55 | * @internal Only used as CB for cURL |
| 56 | 56 | */ |
| 57 | - public function headersHandler( $ch, string $header ) : int { |
|
| 57 | + public function headersHandler ( $ch, string $header ) : int { |
|
| 58 | 58 | $bits = explode( ':', $header, 2 ); |
| 59 | - if ( trim( $bits[0] ) === 'Set-Cookie' ) { |
|
| 60 | - $this->newCookies[] = $bits[1]; |
|
| 59 | + if ( trim( $bits[ 0 ] ) === 'Set-Cookie' ) { |
|
| 60 | + $this->newCookies[ ] = $bits[ 1 ]; |
|
| 61 | 61 | } |
| 62 | 62 | // @phan-suppress-next-line PhanTypeMismatchReturn WTF? Why does phan thinks this is a string? |
| 63 | 63 | return strlen( $header ); |