@@ -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 | get_class( $ex ) . ': ' . |
| 89 | 89 | $ex->getMessage() . "\nTrace:\n" . |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | * @param int $errline |
| 101 | 101 | * @protected |
| 102 | 102 | */ |
| 103 | - public function handleError( $errno, $errstr, $errfile, $errline ) { |
|
| 103 | + public function handleError ( $errno, $errstr, $errfile, $errline ) { |
|
| 104 | 104 | throw new \ErrorException( $errstr, 0, $errno, $errfile, $errline ); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * @return TaskDataProvider |
| 109 | 109 | */ |
| 110 | - protected function getDataProvider() : TaskDataProvider { |
|
| 110 | + protected function getDataProvider () : TaskDataProvider { |
|
| 111 | 111 | return $this->dataProvider; |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -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,13 +14,13 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @return string[] |
| 16 | 16 | */ |
| 17 | - abstract protected function getSubtasksMap() : array; |
|
| 17 | + abstract protected function getSubtasksMap () : array; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * @param string $subtask Defined in self::SUBTASKS_MAP |
| 21 | 21 | * @return TaskResult |
| 22 | 22 | */ |
| 23 | - protected function runSubtask( string $subtask ) : TaskResult { |
|
| 23 | + protected function runSubtask ( string $subtask ) : TaskResult { |
|
| 24 | 24 | $map = $this->getSubtasksMap(); |
| 25 | 25 | if ( !isset( $map[ $subtask ] ) ) { |
| 26 | 26 | throw new \InvalidArgumentException( "'$subtask' is not a valid task." ); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @inheritDoc |
| 35 | 35 | */ |
| 36 | - final public function getOperationName(): string { |
|
| 36 | + final public function getOperationName (): string { |
|
| 37 | 37 | return 'task'; |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * @param string $class |
| 44 | 44 | * @return Subtask |
| 45 | 45 | */ |
| 46 | - private function getSubtaskInstance( string $class ) : Subtask { |
|
| 46 | + private function getSubtaskInstance ( string $class ) : Subtask { |
|
| 47 | 47 | return new $class( $this->getDataProvider() ); |
| 48 | 48 | } |
| 49 | 49 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare( strict_types=1 ); |
|
| 1 | +<?php declare(strict_types=1); |
|
| 2 | 2 | /** |
| 3 | 3 | * Entry point for the bot, called by CLI |
| 4 | 4 | */ |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | /* URL (for debugging purpose) */ |
| 39 | 39 | $urlParam = getopt( '', [ 'force-url:' ] ); |
| 40 | -$url = $urlParam['force-url'] ?? 'https://it.wikipedia.org/w/api.php'; |
|
| 40 | +$url = $urlParam[ 'force-url' ] ?? 'https://it.wikipedia.org/w/api.php'; |
|
| 41 | 41 | |
| 42 | 42 | define( 'DEFAULT_URL', $url ); |
| 43 | 43 | |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | if ( count( $taskOpts ) === 2 ) { |
| 89 | 89 | throw new InvalidArgumentException( 'Cannot specify both task and subtask.' ); |
| 90 | -} elseif ( isset( $taskOpts['task'] ) ) { |
|
| 90 | +} elseif ( isset( $taskOpts[ 'task' ] ) ) { |
|
| 91 | 91 | $bot->runTask( $taskOpts[ 'task' ] ); |
| 92 | -} elseif ( isset( $taskOpts['subtask'] ) ) { |
|
| 92 | +} elseif ( isset( $taskOpts[ 'subtask' ] ) ) { |
|
| 93 | 93 | $bot->runSubtask( $taskOpts[ 'subtask' ] ); |
| 94 | 94 | } else { |
| 95 | 95 | $bot->runAll(); |
@@ -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 | |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | /** @var Controller */ |
| 20 | 20 | private $controller; |
| 21 | 21 | |
| 22 | - public function __construct() { |
|
| 22 | + public function __construct () { |
|
| 23 | 23 | $this->setLogger( new Logger ); |
| 24 | 24 | $this->setConfig( Config::getInstance() ); |
| 25 | 25 | $this->setController( new Controller ); |
@@ -28,42 +28,42 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @return LoggerInterface |
| 30 | 30 | */ |
| 31 | - protected function getLogger() : LoggerInterface { |
|
| 31 | + protected function getLogger () : LoggerInterface { |
|
| 32 | 32 | return $this->logger; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @inheritDoc |
| 37 | 37 | */ |
| 38 | - public function setLogger( LoggerInterface $logger ) { |
|
| 38 | + public function setLogger ( LoggerInterface $logger ) { |
|
| 39 | 39 | $this->logger = $logger; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @return Config |
| 44 | 44 | */ |
| 45 | - protected function getConfig() : Config { |
|
| 45 | + protected function getConfig () : Config { |
|
| 46 | 46 | return $this->config; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param Config $cfg |
| 51 | 51 | */ |
| 52 | - protected function setConfig( Config $cfg ) { |
|
| 52 | + protected function setConfig ( Config $cfg ) { |
|
| 53 | 53 | $this->config = $cfg; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @return Controller |
| 58 | 58 | */ |
| 59 | - protected function getController() : Controller { |
|
| 59 | + protected function getController () : Controller { |
|
| 60 | 60 | return $this->controller; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @param Controller $controller |
| 65 | 65 | */ |
| 66 | - protected function setController( Controller $controller ) { |
|
| 66 | + protected function setController ( Controller $controller ) { |
|
| 67 | 67 | $this->controller = $controller; |
| 68 | 68 | } |
| 69 | 69 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param string $key |
| 74 | 74 | * @return Message |
| 75 | 75 | */ |
| 76 | - protected function msg( string $key ) : Message { |
|
| 76 | + protected function msg ( string $key ) : Message { |
|
| 77 | 77 | return new Message( $key ); |
| 78 | 78 | } |
| 79 | 79 | } |
@@ -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 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * @return string |
| 41 | 41 | * @throws MissingPageException |
| 42 | 42 | */ |
| 43 | - public function getPageContent( string $title, int $section = null ) : string { |
|
| 43 | + public function getPageContent ( string $title, int $section = null ) : string { |
|
| 44 | 44 | $this->logger->debug( "Retrieving content of page $title" ); |
| 45 | 45 | $params = [ |
| 46 | 46 | 'action' => 'query', |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | ]; |
| 52 | 52 | |
| 53 | 53 | if ( $section !== null ) { |
| 54 | - $params['rvsection'] = $section; |
|
| 54 | + $params[ 'rvsection' ] = $section; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | $req = RequestBase::newFromParams( $params )->setUrl( $this->domain ); |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | throw new MissingPageException( $title ); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $mainSlot = $page->revisions[0]->slots->main; |
|
| 64 | + $mainSlot = $page->revisions[ 0 ]->slots->main; |
|
| 65 | 65 | |
| 66 | 66 | if ( $section !== null && isset( $mainSlot->nosuchsection ) ) { |
| 67 | 67 | throw new MissingSectionException( $title, $section ); |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | * @param array $params |
| 76 | 76 | * @throws EditException |
| 77 | 77 | */ |
| 78 | - public function editPage( array $params ) { |
|
| 78 | + public function editPage ( array $params ) { |
|
| 79 | 79 | $this->login(); |
| 80 | 80 | |
| 81 | 81 | $params = [ |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | * Login wrapper. Checks if we're already logged in and clears tokens cache |
| 98 | 98 | * @throws LoginException |
| 99 | 99 | */ |
| 100 | - public function login() { |
|
| 100 | + public function login () { |
|
| 101 | 101 | if ( self::$loggedIn ) { |
| 102 | 102 | $this->logger->debug( 'Already logged in' ); |
| 103 | 103 | return; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | self::$loggedIn = true; |
| 126 | 126 | // Clear tokens cache |
| 127 | - $this->tokens = []; |
|
| 127 | + $this->tokens = [ ]; |
|
| 128 | 128 | $this->logger->info( 'Login succeeded' ); |
| 129 | 129 | } |
| 130 | 130 | |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | * @param string $type |
| 135 | 135 | * @return string |
| 136 | 136 | */ |
| 137 | - public function getToken( string $type ) : string { |
|
| 137 | + public function getToken ( string $type ) : string { |
|
| 138 | 138 | if ( !isset( $this->tokens[ $type ] ) ) { |
| 139 | 139 | $params = [ |
| 140 | 140 | 'action' => 'query', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $title |
| 158 | 158 | * @return int |
| 159 | 159 | */ |
| 160 | - public function getPageCreationTS( string $title ) : int { |
|
| 160 | + public function getPageCreationTS ( string $title ) : int { |
|
| 161 | 161 | $params = [ |
| 162 | 162 | 'action' => 'query', |
| 163 | 163 | 'prop' => 'revisions', |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | |
| 171 | 171 | $res = RequestBase::newFromParams( $params )->setUrl( $this->domain )->execute(); |
| 172 | 172 | $data = $res->query->pages; |
| 173 | - return strtotime( reset( $data )->revisions[0]->timestamp ); |
|
| 173 | + return strtotime( reset( $data )->revisions[ 0 ]->timestamp ); |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param string $title |
| 180 | 180 | * @param string $reason |
| 181 | 181 | */ |
| 182 | - public function protectPage( string $title, string $reason ) { |
|
| 182 | + public function protectPage ( string $title, string $reason ) { |
|
| 183 | 183 | $this->logger->info( "Protecting page $title" ); |
| 184 | 184 | $this->login(); |
| 185 | 185 | |
@@ -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 | /** |
| 22 | 22 | * @param string $title |
| 23 | 23 | */ |
| 24 | - public function __construct( string $title ) { |
|
| 24 | + public function __construct ( string $title ) { |
|
| 25 | 25 | parent::__construct( $title ); |
| 26 | 26 | $this->supportSection = $this->isVote() ? 3 : 0; |
| 27 | 27 | $this->opposeSection = $this->isVote() ? 4 : 3; |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return string |
| 34 | 34 | */ |
| 35 | - public function getUser() : string { |
|
| 36 | - return explode( '/', $this->title )[2]; |
|
| 35 | + public function getUser () : string { |
|
| 36 | + return explode( '/', $this->title )[ 2 ]; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @return int |
| 43 | 43 | */ |
| 44 | - public function getNum() : int { |
|
| 44 | + public function getNum () : int { |
|
| 45 | 45 | $bits = explode( '/', $this->getTitle() ); |
| 46 | 46 | return intval( end( $bits ) ); |
| 47 | 47 | } |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | - public function getUserNum() : string { |
|
| 55 | - return explode( '/', $this->getTitle(), 3 )[2]; |
|
| 54 | + public function getUserNum () : string { |
|
| 55 | + return explode( '/', $this->getTitle(), 3 )[ 2 ]; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return string |
| 62 | 62 | */ |
| 63 | - public function getBaseTitle() : string { |
|
| 63 | + public function getBaseTitle () : string { |
|
| 64 | 64 | // @phan-suppress-next-line PhanTypeMismatchArgumentInternal Phan bug |
| 65 | 65 | return substr( $this->getTitle(), 0, strrpos( $this->getTitle(), '/' ) ); |
| 66 | 66 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @return int |
| 72 | 72 | */ |
| 73 | - public function getOpposingCount() : int { |
|
| 73 | + public function getOpposingCount () : int { |
|
| 74 | 74 | return $this->getCountForSection( $this->opposeSection ); |
| 75 | 75 | } |
| 76 | 76 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @return int |
| 81 | 81 | * @throws \BadMethodCallException |
| 82 | 82 | */ |
| 83 | - public function getSupportCount() : int { |
|
| 83 | + public function getSupportCount () : int { |
|
| 84 | 84 | if ( !$this->isVote() ) { |
| 85 | 85 | throw new \BadMethodCallException( 'Cannot get support for a non-vote page.' ); |
| 86 | 86 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | * @param int $secNum |
| 94 | 94 | * @return int |
| 95 | 95 | */ |
| 96 | - protected function getCountForSection( int $secNum ) : int { |
|
| 96 | + protected function getCountForSection ( int $secNum ) : int { |
|
| 97 | 97 | $content = $this->controller->getPageContent( $this->title, $secNum ); |
| 98 | 98 | // Let's hope that this is good enough... |
| 99 | 99 | return substr_count( $content, "\n\# *(?![#*])" ); |
@@ -104,9 +104,9 @@ discard block |
||
| 104 | 104 | * |
| 105 | 105 | * @return int |
| 106 | 106 | */ |
| 107 | - protected function getQuorum() : int { |
|
| 107 | + protected function getQuorum () : int { |
|
| 108 | 108 | $reg = "!soddisfare il \[\[[^|\]]+\|quorum]] di '''(\d+) voti'''!"; |
| 109 | - return intval( $this->getMatch( $reg )[1] ); |
|
| 109 | + return intval( $this->getMatch( $reg )[ 1 ] ); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return bool |
| 116 | 116 | */ |
| 117 | - public function hasOpposition() : bool { |
|
| 117 | + public function hasOpposition () : bool { |
|
| 118 | 118 | return $this->getOpposingCount() >= 15; |
| 119 | 119 | } |
| 120 | 120 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @return int One of the OUTCOME_* constants |
| 125 | 125 | * @throws \BadMethodCallException |
| 126 | 126 | */ |
| 127 | - public function getOutcome() : int { |
|
| 127 | + public function getOutcome () : int { |
|
| 128 | 128 | if ( !$this->isVote() ) { |
| 129 | 129 | throw new \BadMethodCallException( 'Cannot get outcome for a non-vote page.' ); |
| 130 | 130 | } |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @throws \BadMethodCallException |
| 145 | 145 | * @throws \LogicException |
| 146 | 146 | */ |
| 147 | - public function getOutcomeText() : string { |
|
| 147 | + public function getOutcomeText () : string { |
|
| 148 | 148 | if ( !$this->isVote() ) { |
| 149 | 149 | throw new \BadMethodCallException( 'No need for an outcome text.' ); |
| 150 | 150 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return bool |
| 180 | 180 | */ |
| 181 | - public function isVote() : bool { |
|
| 181 | + public function isVote () : bool { |
|
| 182 | 182 | $sectionReg = '/<!-- SEZIONE DA UTILIZZARE PER/'; |
| 183 | 183 | return !$this->matches( $sectionReg ); |
| 184 | 184 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return int |
| 190 | 190 | */ |
| 191 | - public function getEndTimestamp() : int { |
|
| 191 | + public function getEndTimestamp () : int { |
|
| 192 | 192 | if ( $this->isVote() ) { |
| 193 | 193 | $reg = "!La votazione ha inizio il.+ e ha termine.+ '''([^']+)''' alle ore '''([^']+)'''!"; |
| 194 | 194 | list( , $day, $hours ) = $this->getMatch( $reg ); |
@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param string $title |
| 21 | 21 | * @param string $domain The site where the page lives, if different from default |
| 22 | 22 | */ |
| 23 | - public function __construct( string $title, string $domain = DEFAULT_URL ) { |
|
| 23 | + public function __construct ( string $title, string $domain = DEFAULT_URL ) { |
|
| 24 | 24 | $this->title = $title; |
| 25 | 25 | $this->controller = new Controller( $domain ); |
| 26 | 26 | } |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | /** |
| 29 | 29 | * @return string |
| 30 | 30 | */ |
| 31 | - public function getTitle() : string { |
|
| 31 | + public function getTitle () : string { |
|
| 32 | 32 | return $this->title; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @param int|null $section A section number to retrieve the content of that section |
| 39 | 39 | * @return string |
| 40 | 40 | */ |
| 41 | - public function getContent( int $section = null ) : string { |
|
| 41 | + public function getContent ( int $section = null ) : string { |
|
| 42 | 42 | if ( $this->content === null ) { |
| 43 | 43 | $this->content = $this->controller->getPageContent( $this->title, $section ); |
| 44 | 44 | } |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | * |
| 51 | 51 | * @param array $params |
| 52 | 52 | */ |
| 53 | - public function edit( array $params ) { |
|
| 53 | + public function edit ( array $params ) { |
|
| 54 | 54 | $params = [ |
| 55 | 55 | 'title' => $this->getTitle() |
| 56 | 56 | ] + $params; |
| 57 | 57 | |
| 58 | 58 | $this->controller->editPage( $params ); |
| 59 | - if ( isset( $params['text'] ) ) { |
|
| 60 | - $this->content = $params['text']; |
|
| 61 | - } elseif ( isset( $params['appendtext'] ) ) { |
|
| 62 | - $this->content .= $params['appendtext']; |
|
| 59 | + if ( isset( $params[ 'text' ] ) ) { |
|
| 60 | + $this->content = $params[ 'text' ]; |
|
| 61 | + } elseif ( isset( $params[ 'appendtext' ] ) ) { |
|
| 62 | + $this->content .= $params[ 'appendtext' ]; |
|
| 63 | 63 | } else { |
| 64 | 64 | // Clear the cache anyway |
| 65 | 65 | ( new Logger )->warning( 'Resetting content cache. Params: ' . var_export( $params, true ) ); |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @param string $regex |
| 74 | 74 | * @return bool |
| 75 | 75 | */ |
| 76 | - public function matches( string $regex ) : bool { |
|
| 76 | + public function matches ( string $regex ) : bool { |
|
| 77 | 77 | return (bool)preg_match( $regex, $this->getContent() ); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | * @return string[] |
| 86 | 86 | * @throws \Exception |
| 87 | 87 | */ |
| 88 | - public function getMatch( string $regex ) : array { |
|
| 89 | - $ret = []; |
|
| 88 | + public function getMatch ( string $regex ) : array { |
|
| 89 | + $ret = [ ]; |
|
| 90 | 90 | if ( preg_match( $regex, $this->getContent(), $ret ) === 0 ) { |
| 91 | 91 | throw new \Exception( 'The content does not match the given regex' ); |
| 92 | 92 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return string |
| 100 | 100 | */ |
| 101 | - public function __toString() { |
|
| 101 | + public function __toString () { |
|
| 102 | 102 | return $this->getTitle(); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -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 | |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | /** |
| 12 | 12 | * @private Use self::get() |
| 13 | 13 | */ |
| 14 | - public function __construct() { |
|
| 14 | + public function __construct () { |
|
| 15 | 15 | parent::__construct( Config::getInstance()->get( 'list-title' ) ); |
| 16 | 16 | } |
| 17 | 17 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @return self |
| 22 | 22 | */ |
| 23 | - public static function get() : self { |
|
| 23 | + public static function get () : self { |
|
| 24 | 24 | static $instance = null; |
| 25 | 25 | if ( $instance === null ) { |
| 26 | 26 | $instance = new self; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * |
| 34 | 34 | * @return array[] |
| 35 | 35 | */ |
| 36 | - public function getAdminsList() : array { |
|
| 36 | + public function getAdminsList () : array { |
|
| 37 | 37 | return json_decode( $this->getContent(), true ); |
| 38 | 38 | } |
| 39 | 39 | } |