@@ -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 | |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param string $title |
| 22 | 22 | * @param Wiki $wiki For the site where the page lives |
| 23 | 23 | */ |
| 24 | - public function __construct( string $title, Wiki $wiki ) { |
|
| 24 | + public function __construct ( string $title, Wiki $wiki ) { |
|
| 25 | 25 | $this->wiki = $wiki; |
| 26 | 26 | $this->title = $title; |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | /** |
| 30 | 30 | * @return string |
| 31 | 31 | */ |
| 32 | - public function getTitle() : string { |
|
| 32 | + public function getTitle () : string { |
|
| 33 | 33 | return $this->title; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * @param int|null $section A section number to retrieve the content of that section |
| 40 | 40 | * @return string |
| 41 | 41 | */ |
| 42 | - public function getContent( int $section = null ) : string { |
|
| 42 | + public function getContent ( int $section = null ) : string { |
|
| 43 | 43 | if ( $this->content === null ) { |
| 44 | 44 | $this->content = $this->wiki->getPageContent( $this->title, $section ); |
| 45 | 45 | } |
@@ -52,18 +52,18 @@ discard block |
||
| 52 | 52 | * @param array $params |
| 53 | 53 | * @throws \LogicException |
| 54 | 54 | */ |
| 55 | - public function edit( array $params ) : void { |
|
| 55 | + public function edit ( array $params ) : void { |
|
| 56 | 56 | $params = [ |
| 57 | 57 | 'title' => $this->getTitle() |
| 58 | 58 | ] + $params; |
| 59 | 59 | |
| 60 | 60 | $this->wiki->editPage( $params ); |
| 61 | - if ( isset( $params['text'] ) ) { |
|
| 62 | - $this->content = $params['text']; |
|
| 63 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 64 | - $this->content .= $params['appendtext']; |
|
| 65 | - } elseif ( isset( $params['prependtext'] ) ) { |
|
| 66 | - $this->content = $params['prependtext'] . $this->content; |
|
| 61 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 62 | + $this->content = $params[ 'text' ]; |
|
| 63 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 64 | + $this->content .= $params[ 'appendtext' ]; |
|
| 65 | + } elseif ( isset( $params[ 'prependtext' ] ) ) { |
|
| 66 | + $this->content = $params[ 'prependtext' ] . $this->content; |
|
| 67 | 67 | } else { |
| 68 | 68 | throw new \LogicException( |
| 69 | 69 | 'Unrecognized text param for edit. Params: ' . var_export( $params, true ) |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * |
| 77 | 77 | * @return bool |
| 78 | 78 | */ |
| 79 | - public function exists() : bool { |
|
| 79 | + public function exists () : bool { |
|
| 80 | 80 | $res = $this->wiki->getRequestFactory()->newFromParams( [ |
| 81 | 81 | 'action' => 'query', |
| 82 | 82 | 'titles' => $this->getTitle() |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | * @param string $regex |
| 92 | 92 | * @return bool |
| 93 | 93 | */ |
| 94 | - public function matches( string $regex ) : bool { |
|
| 94 | + public function matches ( string $regex ) : bool { |
|
| 95 | 95 | return (bool)preg_match( $regex, $this->getContent() ); |
| 96 | 96 | } |
| 97 | 97 | |
@@ -103,8 +103,8 @@ discard block |
||
| 103 | 103 | * @return string[] |
| 104 | 104 | * @throws MissingMatchException |
| 105 | 105 | */ |
| 106 | - public function getMatch( string $regex ) : array { |
|
| 107 | - $ret = []; |
|
| 106 | + public function getMatch ( string $regex ) : array { |
|
| 107 | + $ret = [ ]; |
|
| 108 | 108 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 109 | 109 | throw new MissingMatchException( "The content of $this does not match the given regex $regex" ); |
| 110 | 110 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * |
| 117 | 117 | * @inheritDoc |
| 118 | 118 | */ |
| 119 | - public function getRegex( string $delimiter = '/' ) : string { |
|
| 119 | + public function getRegex ( string $delimiter = '/' ) : string { |
|
| 120 | 120 | return str_replace( ' ', '[ _]', preg_quote( $this->title, $delimiter ) ); |
| 121 | 121 | } |
| 122 | 122 | |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | * |
| 126 | 126 | * @return string |
| 127 | 127 | */ |
| 128 | - public function __toString() { |
|
| 128 | + public function __toString () { |
|
| 129 | 129 | return $this->getTitle(); |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -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\Wiki; |
| 4 | 4 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | * @param LoggerInterface $logger |
| 37 | 37 | * @param RequestFactory $requestFactory |
| 38 | 38 | */ |
| 39 | - public function __construct( |
|
| 39 | + public function __construct ( |
|
| 40 | 40 | LoginInfo $li, |
| 41 | 41 | LoggerInterface $logger, |
| 42 | 42 | RequestFactory $requestFactory |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | /** |
| 50 | 50 | * @return LoginInfo |
| 51 | 51 | */ |
| 52 | - public function getLoginInfo() : LoginInfo { |
|
| 52 | + public function getLoginInfo () : LoginInfo { |
|
| 53 | 53 | return $this->loginInfo; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @param bool $bot |
| 58 | 58 | */ |
| 59 | - public function setEditsAsBot( bool $bot ) : void { |
|
| 59 | + public function setEditsAsBot ( bool $bot ) : void { |
|
| 60 | 60 | // FIXME same as setLoginInfo |
| 61 | 61 | $this->botEdits = $bot; |
| 62 | 62 | } |
@@ -64,28 +64,28 @@ discard block |
||
| 64 | 64 | /** |
| 65 | 65 | * @return bool |
| 66 | 66 | */ |
| 67 | - public function getEditsAsBot() : bool { |
|
| 67 | + public function getEditsAsBot () : bool { |
|
| 68 | 68 | return $this->botEdits; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * @return RequestFactory |
| 73 | 73 | */ |
| 74 | - public function getRequestFactory() : RequestFactory { |
|
| 74 | + public function getRequestFactory () : RequestFactory { |
|
| 75 | 75 | return $this->requestFactory; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @param string $ident |
| 80 | 80 | */ |
| 81 | - public function setLocalUserIdentifier( string $ident ) : void { |
|
| 81 | + public function setLocalUserIdentifier ( string $ident ) : void { |
|
| 82 | 82 | $this->localUserIdentifier = $ident; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * @return string |
| 87 | 87 | */ |
| 88 | - public function getLocalUserIdentifier() : string { |
|
| 88 | + public function getLocalUserIdentifier () : string { |
|
| 89 | 89 | return $this->localUserIdentifier; |
| 90 | 90 | } |
| 91 | 91 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * @throws MissingPageException |
| 99 | 99 | * @throws MissingSectionException |
| 100 | 100 | */ |
| 101 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 101 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 102 | 102 | $msg = "Retrieving content of $title" . ( $section !== null ? ", section $section" : '' ); |
| 103 | 103 | $this->logger->debug( $msg ); |
| 104 | 104 | $params = [ |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | ]; |
| 111 | 111 | |
| 112 | 112 | if ( $section !== null ) { |
| 113 | - $params['rvsection'] = $section; |
|
| 113 | + $params[ 'rvsection' ] = $section; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | $req = $this->buildRequest( $params ); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | throw new MissingPageException( $title ); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 123 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 124 | 124 | |
| 125 | 125 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
| 126 | 126 | throw new MissingSectionException( $title, $section ); |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param array $params |
| 135 | 135 | * @throws EditException |
| 136 | 136 | */ |
| 137 | - public function editPage( array $params ) : void { |
|
| 137 | + public function editPage ( array $params ) : void { |
|
| 138 | 138 | $this->login(); |
| 139 | 139 | |
| 140 | 140 | $params = [ |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | ] + $params; |
| 144 | 144 | |
| 145 | 145 | if ( $this->getEditsAsBot() ) { |
| 146 | - $params['bot'] = 1; |
|
| 146 | + $params[ 'bot' ] = 1; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $res = $this->buildRequest( $params )->setPost()->execute(); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 162 | 162 | * @throws LoginException |
| 163 | 163 | */ |
| 164 | - public function login() : void { |
|
| 164 | + public function login () : void { |
|
| 165 | 165 | if ( $this->loginInfo === null ) { |
| 166 | 166 | throw new CannotLoginException( 'Missing login data' ); |
| 167 | 167 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | self::$loggedIn = true; |
| 193 | 193 | // Clear tokens cache |
| 194 | - $this->tokens = []; |
|
| 194 | + $this->tokens = [ ]; |
|
| 195 | 195 | $this->logger->info( 'Login succeeded' ); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @param string $type |
| 202 | 202 | * @return string |
| 203 | 203 | */ |
| 204 | - public function getToken( string $type ) : string { |
|
| 204 | + public function getToken ( string $type ) : string { |
|
| 205 | 205 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 206 | 206 | $params = [ |
| 207 | 207 | 'action' => 'query', |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | * @param string $title |
| 225 | 225 | * @return int |
| 226 | 226 | */ |
| 227 | - public function getPageCreationTS( string $title ) : int { |
|
| 227 | + public function getPageCreationTS ( string $title ) : int { |
|
| 228 | 228 | $params = [ |
| 229 | 229 | 'action' => 'query', |
| 230 | 230 | 'prop' => 'revisions', |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $res = $this->buildRequest( $params )->execute(); |
| 239 | 239 | $data = $res->query->pages; |
| 240 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 240 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /** |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @param string $title |
| 247 | 247 | * @param string $reason |
| 248 | 248 | */ |
| 249 | - public function protectPage( string $title, string $reason ) : void { |
|
| 249 | + public function protectPage ( string $title, string $reason ) : void { |
|
| 250 | 250 | $this->logger->info( "Protecting page $title" ); |
| 251 | 251 | $this->login(); |
| 252 | 252 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @param array $params |
| 268 | 268 | * @return RequestBase |
| 269 | 269 | */ |
| 270 | - private function buildRequest( array $params ) : RequestBase { |
|
| 270 | + private function buildRequest ( array $params ) : RequestBase { |
|
| 271 | 271 | return $this->requestFactory->newFromParams( $params ); |
| 272 | 272 | } |
| 273 | 273 | } |